Get all public User contributions aka "calendar data" (github api v3)

Viewed 922

I have found many threads - even a couple projects which embed the contribution calendar using api's other than the github api - yet none of these methods or threads actually answer the question. One comes close but it's a no go.

I am simply trying to access the total number of contributions for a user as shown in your calendar on the github profile page as shown below...

enter image description here

The api docs describe collecting Repo Contrib data so i've tried blindly poking at the api with educated guesses to no avail. Does anyone per-chance know if there in fact is a viable endpoint for this data? Do I really need to calculate this info myself or do some dirty html scraping nonsense? This seems dumb... Anyone?

UPDATE: Here's a solution using cheerio and regex for anyone looking for a quick web scraping solution

const axios = require('axios')
const cheerio = require('cheerio')
const url = 'https://github.com/archae0pteryx'

function getCommits(url) {
    return new Promise((resolve, reject) => {
        axios.get(url).then(res => {
            const load = cheerio.load(res.data)
            const parsed = load('div.js-contribution-graph > h2').text()
            const reg = /\d+/g
            const x = parsed.match(reg)
            resolve(x)
        }).catch(err => reject(err))
    })
}


getCommits(url)
    .then(x => console.log(x))
    .catch(err => console.error(err))
1 Answers
Related