Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 6

Strange response from Github api

I have a strange issue.  I am using the github api to retrieve information concerning all of the gists for the user whose PAT is used to authenticate to Github.  I am doing this in powershell.  Below is the code:

$header = @{}
$header.add("Authorization", "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
$url = "https://api.github.com/gists"
$data = Invoke-RestMethod -Uri $url -Headers $header -Method Get

The part that is strange is that the api is only returning the first 30 gist items for the account, which is noticeable because this account has about 50 gists that it owns and hosts.  Any idea why this might be the case?  I find it very interesting that the api is only returning EXACTLY 30 entries each time.  Does the gist API endpoint use pagination or something?

5 Replies
Pilot Lvl 1
Message 2 of 6

Re: Strange response from Github api

Did you make sure that all 50 of the user's Gists are public? Per the GitHub Rest API v3 documentation:

List the authenticated user's gists or if called anonymously, this will return all public gists:
GET /gists

^ this endpoint will only return public Gists of a specified user.

Gavin R. Isgar - Freelance Software Developer
Copilot Lvl 2
Message 3 of 6

Re: Strange response from Github api

Maybe the api is returning the wrong version?  https://developer.github.com/v3/

Pilot Lvl 1
Message 4 of 6

Re: Strange response from Github api

Although that might be possible, I doubt that in this case. I say that because the endpoint is set to automatically grab information through their third-version of the GitHub REST API.

 

Gavin R. Isgar - Freelance Software Developer
Copilot Lvl 3
Message 5 of 6

Re: Strange response from Github api

Hello all.  I am sure that all the gists are public.  Its odd, I know, but it will only return the first 30 of the 50 + public gists.

Copilot Lvl 3
Message 6 of 6

Re: Strange response from Github api

Given the code provided in the first post, where "data" returns all of the public gists for a user, this is the "Count" property for the variable.

 

7c95qYg