Luca G. Soave
Luca G. Soave

Reputation: 12679

How can I list all Github users with V3 APIs?

I can get just the first 100 users :

lsoave@ubuntu:~$ curl -i https://api.github.com/users|grep -c login
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  104k  100  104k    0     0  92808      0  0:00:01  0:00:01 --:--:--  100k
100
lsoave@ubuntu:~$ 

but I need the full list and /users?page= ( where n goes from 0 to ) get the same 100 user list :

lsoave@ubuntu:~$ curl -i https://api.github.com/users?page=0 | grep login | tail -10
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  104k  100  104k    0     0  90797      0  0:00:01  0:00:01 --:--:--  101k
    "login": "danielharan",
    "login": "kvnsmth",
    "login": "collectiveidea",
    "login": "canadaduane",
    "login": "nate",
    "login": "dstrelau",
    "login": "sunny",
    "login": "dkubb",
    "login": "jnicklas",
    "login": "richcollins",

lsoave@ubuntu:~$ curl -i https://api.github.com/users?page=1 | grep login | tail -10
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  104k  100  104k    0     0    99k      0  0:00:01  0:00:01 --:--:--  110k
    "login": "danielharan",
    "login": "kvnsmth",
    "login": "collectiveidea",
    "login": "canadaduane",
    "login": "nate",
    "login": "dstrelau",
    "login": "sunny",
    "login": "dkubb",
    "login": "jnicklas",
    "login": "richcollins",

lsoave@ubuntu:~$ curl -i https://api.github.com/users?page=2 | grep login | tail -10
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  104k  100  104k    0     0  95960      0  0:00:01  0:00:01 --:--:--  104k
    "login": "danielharan",
    "login": "kvnsmth",
    "login": "collectiveidea",
    "login": "canadaduane",
    "login": "nate",
    "login": "dstrelau",
    "login": "sunny",
    "login": "dkubb",
    "login": "jnicklas",
    "login": "richcollins",

lsoave@ubuntu:~$ curl -i https://api.github.com/users?page=3 | grep login | tail -10
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  104k  100  104k    0     0    99k      0  0:00:01  0:00:01 --:--:--  110k
    "login": "danielharan",
    "login": "kvnsmth",
    "login": "collectiveidea",
    "login": "canadaduane",
    "login": "nate",
    "login": "dstrelau",
    "login": "sunny",
    "login": "dkubb",
    "login": "jnicklas",
    "login": "richcollins",

Upvotes: 1

Views: 228

Answers (1)

Kartik
Kartik

Reputation: 9853

You need to use the since parameter instead of page

Ideally, you get the id of the last user on the list (in this case it's 135) and you make the next call with that id and the new response will contain the users exceeding that userid

https://api.github.com/users?since=135

Upvotes: 2

Related Questions