Search code examples
githubgithub-apigithub-api-v3

Tracking commits with the GitHub API


I'm looking to work with the GitHub API, but I'm having trouble finding what I need in the documentation.

There's two things I can't find.

  • I see that I can list all the commits in a repository, but I'm not sure how to get each commit's details without calling the single commit endpoint a bunch of times.
    Specifically, the amount of changes in each file.
  • The other thing I can't seem to figure out is how I can get a webhook/event sent to my application whenever a commit is made on a repository. I've made it to the webhooks page, but can't seem to find the event I'm looking for.
    Is what I need even possible? Or am I just missing something in the docs?

Solution

  • You cannot get diff for each commits in one go with the API.
    You can get a global diff between arbitrary commits with an URL, or, through the API, comparing two commits, which returns a diff URL. But that won't track each intermediate commit diff.

    Regarding webhook, the event you want is the push event: it will be triggered by any new commit pushed to your repository.