I have a personal blog I built using rails. I want to add a section to my site that displays my current streak of github contributions. What would be the best way about doing this?
edit: for clarification, here is what I want:
just the number of days is all that is necessary for me.
The current streak is the number of consecutive days ending with the current day on which you have made at least one contribution.
Setting a stop date is one way to make your GitHub streak your own. You can also decide which days are part of the streak and which are not. For example, if you're a full-time programmer, you may want to take weekends off.
Whenever you commit to a project's default branch or the gh-pages branch, open an issue, or propose a Pull Request, we'll count that as a contribution. Repositories are sorted by your recent impact. A commit today is worth more than a commit last week.
On GitHub.com, navigate to the main page of the repository. Under your repository name, click Insights. In the left sidebar, click Contributors. Optionally, to view contributors during a specific time period, click, then drag until the time period is selected.
Considering the GitHub API for Users doesn't yet expose that particular information (number of days for current stream of contributions), you might have to:
scrape it (extract it by reading the user's GitHub page)
As klamping mentions in his answer (upvoted), the url to scrap would be:https://github.com/users/<username>/contributions_calendar_data
https://github.com/users/<username>/contributions
(for public repos only, though)
SherlockStd has an updated (May 2017) parsing code below:
https://github-stats.com/api/user/streak/current/:username
try projects which are using https://github.com/users/<username>/contributions
(as listed in Marques Johansson's answer, upvoted)_calendar_data
git-cal
is a simple script to view commits calendar (similar to GitHub contributions calendar) on command line.
Each block in the graph corresponds to a day and is shaded with one of the 5 possible colors, each representing relative number of commits on that day.
You can find various example of scraping that information:
github_team_calendar.py
weekend-commits.js
As in:
$.getJSON('https://github.com/users/' + location.pathname.replace(/\//g, '') + '/contributions_calendar_data', weekendWork);
leaderboard.rb
:Like:
leaderboard = members.map do |u| user_stats = get("https://github.com/users/#{u}/contributions_calendar_data") total = user_stats.map { |s| s[1] }.reduce(&:+) [u, total] end
The URL for the plain JSON data was: https://github.com/users/[username]/contributions_calendar_data [Edit: Looks like this URL no longer works)
There is a URL which generates the SVG, which other answers have indicated. That is here: https://github.com/users/[username]/contributions
Simply replace [username] with your github username in the URL and you should be able to see the chart. See other answers for more in-depth explanations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With