Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why api github search don't find all repositories

Tags:

json

rest

github

Why does the github API not show me the list of all repositories?

Example:

https://github.com/github

https://api.github.com/search/repositories?q=user:github+sort:updated

Using the first link we can see 296 repositories, using second I receive "total_count": 173. How can I search all 296 repositories using the github API?

like image 837
F4nug98 Avatar asked Dec 06 '25 16:12

F4nug98


2 Answers

I believe that API hides archived repos from the results. +archived:true that should show you another 42 or so. But that doesn't add upto 296 so I use the user API (https://api.github.com/users/github/repos) instead which can return more that one type of repository at a time.

It seems theres's some dependency on the search API that hides some repos that is not documented.

https://api.github.com/users/github/repos?type=all&per_page=100 ==> 100 https://api.github.com/users/github/repos?type=all&per_page=100&page=2 ==> 100 https://api.github.com/users/github/repos?type=all&per_page=100&page=3 ==> 96

curl https://api.github.com/users/github/repos\?type\=all\&per_page\=100 | jq length
curl https://api.github.com/users/github/repos\?type\=all\&per_page\=100\&page\=2 | jq length
curl https://api.github.com/users/github/repos\?type\=all\&per_page\=100\&page\=3 | jq length

Sorted by updated

sds-users:() ➜  (11/04 19:18) /tmp curl "https://api.github.com/users/github/repos?type=all&per_page=10&sort=updated" | jq '.[].updated_at'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 54509  100 54509    0     0  76340      0 --:--:-- --:--:-- --:--:-- 76450
"2019-04-11T18:15:05Z"
"2019-04-11T18:05:00Z"
"2019-04-11T18:02:57Z"
"2019-04-11T17:41:47Z"
"2019-04-11T17:35:55Z"
"2019-04-11T16:46:28Z"
"2019-04-11T16:20:20Z"
"2019-04-11T16:17:09Z"
"2019-04-11T15:48:31Z"
"2019-04-11T15:27:31Z"
sds-users:() ➜  (11/04 19:18) /tmp
like image 195
Praveen Premaratne Avatar answered Dec 08 '25 11:12

Praveen Premaratne


The public webpage includes archived repositories. The API query does not.

like image 39
zanerock Avatar answered Dec 08 '25 10:12

zanerock



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!