25

I would like to get all commit messages for separate file in github REST api. But all I got - only to get all commits for separate branch. Then I tried to get following:

http://api.github.com/users/<username>/<project>/commits/<branch>/<path/to/file>

But that didn't help also. Is this at least possible?

vmeln
  • 1,289
  • 1
  • 16
  • 40

2 Answers2

40

Try this (as described in the API docs here):

http://api.github.com/repos/:owner/:repo/commits?path=PATH_TO_FILE

e.g.

https://api.github.com/repos/izuzak/pmrpc/commits?path=README.markdown

Ivan Zuzak
  • 18,068
  • 3
  • 69
  • 61
9

Using GraphQL API v4, for a file on the default branch, it would be :

{
  repository(owner: "izuzak", name: "pmrpc") {
    defaultBranchRef{
      target {
        ...on Commit{
            history(first:100,path: "README.markdown"){
            nodes {
              author {
                email
              }
              message
              oid
            }
          }
        }
      }
    }
  }
}

Try it in the explorer

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159