Finding common user contributions from the Github API

I am trying to extract the information below for any user from github.

enter image description here

Is there a / api method open in github-api where we can get this information directly?

+10
git github github-api
source share
4 answers

This is probably not the solution you are looking for, but the created array contains all the necessary information:

curl https://github.com/users/ankit8898/contributions_calendar_data 

I am sure that you are looking for a solution that is more elegant than that.

UPDATE It seems that this is not the last way to get the participants data. Please look elsewhere on StackOverflow for the correct answer.

+2
source share

You can get the calendar with SVG https://github.com/users/<USER>/contributions with to the URL parameter, like:

https://github.com/users/bertrandmartel/contributions?to=2016-12-31

You can use a basic xml parser to summarize all svg contributions.

Example with curl & xmlstarlet for 2016:

 curl -s "https://github.com/users/bertrandmartel/contributions?to=2016-12-31" | \ xmlstarlet sel -t -v "sum(/svg/g/g/rect/@data-count)" 
+1
source share

You can use this function to extract deposits for the past year (client):

 function getContributions(){ const svgGraph = document.getElementsByClassName('js-calendar-graph')[0]; const daysRects = svgGraph.getElementsByClassName('day'); const days = []; for (let d of daysRects){ days.push({ date: d.getAttribute('data-date'), count: d.getAttribute('data-count') }); } return days; } 

I also wrote a small module node that can β€œextract” contributions
@ simonwep / GitHub contributions

Maybe this will help you (even I was 4 years late)

0
source share

You can use the GitHub Events API for this:

Example (node.js)

 const got = require('got') async function getEvents(username) { const events = [] let page = 1 do { const url = 'https://api.github.com/users/${username}/events?page=${page}' var { body } = await got(url, { json: true }) page++ events.push(...body) } while(!body.length) return events } (async () => { const events = await getEvents('handtrix') console.log('Overall Events', events.length) console.log('PullRequests', events.filter(event => event.type === 'PullRequestEvent').length) console.log('Forks', events.filter(event => event.type === 'ForkEvent').length) console.log('Issues', events.filter(event => event.type === 'IssuesEvent').length) console.log('Reviews', events.filter(event => event.type === 'PullRequestReviewEvent').length) })() 

Documentation

0
source share

All Articles