Samrez Ikram
Samrez Ikram

Reputation: 601

GitHub API: how efficiently get the total count of Issues per repository?

https://api.github.com/repos/{org}/{repo}/issues

What query can allow us to find total count of issues?

Upvotes: 1

Views: 1371

Answers (1)

Bertrand Martel
Bertrand Martel

Reputation: 45362

Using Rest API, you can use the search api:

GET https://api.github.com/search/issues?q=repo:bertrandmartel/tableau-scraping%20is:issue

https://api.github.com/search/issues?q=repo:bertrandmartel/tableau-scraping%20is:issue

Output

{
  "total_count": 8,
  ....
}

You can also use Github graphql API using the following request :

{
  repository(owner: "mui-org", name: "material-ui") {
    issues {
      totalCount
    }
  }
}

try this in the explorer

With curl:

curl -H "Authorization: token YOUR_TOKEN" \
     -H  "Content-Type:application/json" \
     -d '{ 
          "query": "{ repository(owner: \"mui-org\", name: \"material-ui\") { issues { totalCount } } }"
      }' https://api.github.com/graphql

Sample output:

{
  "data": {
    "repository": {
      "issues": {
        "totalCount": 12760
      }
    }
  }
}

Upvotes: 3

Related Questions