6

I am trying to build an app to track GitHub "Streaks" (How many days in a row a user has committed to GitHub.) I'm trying to use the GitHub API to do this, but I can't figure out where.

If I can't pull back the streak, if I could find a way to see if they had committed on a given day (like yesterday) I could recursively determine the streak by continuing to check the previous day until there wasn't a commit.

I can find details about a specific commit https://developer.github.com/v3/repos/commits/

And I can retrieve data for a single user: https://developer.github.com/v3/users/#get-a-single-user

But I can't seem to find how to query the API to determine if the user made a commit on a given day.

2
  • I see there are several "date" fields in the response coming from developer.github.com/v3/repos/commits. Couldn't you use that ones? Commented Oct 20, 2017 at 18:52
  • I think I would need the owner and the repository in order to do that? /repos/:owner/:repo/commits I don't have a specific repo I'm looking for, I'm just curious if they have made any commit. Commented Oct 20, 2017 at 19:10

1 Answer 1

8

You can try using the GitHub Search Commits API for this. For example, to find the commits for user km-poonacha on 2017-08-28 you can make the following request.

curl -H 'Accept: application/vnd.github.cloak-preview' \https://api.github.com/search/commits?q=author:km-poonacha+author-date:2017-08-28

Ref. Searching commits

Sign up to request clarification or add additional context in comments.

3 Comments

This is great! Is there a way to just get back the "total_count": 12, so that I don't get the additional payload of all commits since I don't care about them?
i think the best way to restrict the payload is to use &per_page=1 parameter and restrict the number of search results to be shown to its lowest value "1". I am not too sure, but i dont think you can just get the total_count parameter.
That makes sense, it's not a huge payload, so it's not the end of the world, it's just much larger than needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.