y.luis.rojo
y.luis.rojo

Reputation: 1824

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.

Upvotes: 6

Views: 4357

Answers (1)

Bertrand Martel
Bertrand Martel

Reputation: 45503

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

The result gives total_count field with the required value

It matches the result you can find using Github search :

Upvotes: 11

Related Questions