Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub API get total number of users/organizations

Using GitHub API, how can I count the total number of users/organizations at the time of the request?

Users and Organizations API responses do not contain last Link header.

Note: Following next Link header until the last one, is not a solution for me because of the rate limits for a free account.

like image 419
y.luis Avatar asked Nov 27 '17 01:11

y.luis


People also ask

How do I get stats on GitHub?

Github readme stats allows you to simply add a markdown image link and it will show you realtime stats for your github account. And the cool thing is since it's just an image you can embed it anywhere even on Dev.to posts!

How do I find my GitHub users list?

You can view a list of members in your enterprise who don't have an email address from a verified domain associated with their user account on GitHub.com. In the top-right corner of GitHub.com, click your profile photo, then click Your enterprises. In the list of enterprises, click the enterprise you want to view.


1 Answers

GraphQL API v4

You can get user count & organization count using GraphQL API v4 :

{
  user: search(type: USER, query: "type:user") {
    userCount
  }
  org: search(type: USER, query: "type:org") {
    userCount
  }
}

Try it in the explorer

which gives :

{
  "data": {
    "user": {
      "userCount": 24486303
    },
    "org": {
      "userCount": 1629433
    }
  }
}

REST API v3

  • search query with type:user : https://api.github.com/search/users?q=type%3Auser
  • search query with type:org : https://api.github.com/search/users?q=type%3Aorg

The result gives total_count field with the required value

It matches the result you can find using Github search :

  • for user : https://github.com/search?q=type%3Auser&type=Users&utf8=%E2%9C%93
  • for org : https://github.com/search?utf8=%E2%9C%93&q=type%3Aorg&type=Users
like image 142
Bertrand Martel Avatar answered Oct 20 '22 17:10

Bertrand Martel