github api: How to efficiently find the number of commits for a repository?

Update May 2013: see "File CRUD and repository statistics now available in the API"

You now can Get the last year of commit activity data

GET /repos/:owner/:repo/stats/commit_activity

Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday.

Not completely what you are looking for, but closer.


Original answer (April 2010)

No, the current API doesn't support a 'log --all' for listing all commmits from all branches.

The only alternative is presented in "Github API: Retrieve all commits for all branches for a repo", and list through all pages of all commits, branch after branch.

This seems so cumbersome than another alternative would actually to clone the Github repo and apply git commands on that local clone!
(mainly git shortlog)


Note: you can also checkout that python script created by Arcsector.


With GraphQL API v4, you can get total commit count per branch with totalCount for each branch:

{
  repository(owner: "google", name: "gson") {
    name
    refs(first: 100, refPrefix: "refs/heads/") {
      edges {
        node {
          name
          target {
            ... on Commit {
              id
              history(first: 0) {
                totalCount
              }
            }
          }
        }
      }
    }
  }
}

Test it in the explorer