π GitHub contribution streak & stat fetcher with zero dependencies
Contribution can be installed from the command line with npm:
$ npm install contribution
Import fetchStats
from Contribution using CommonJS require
or ES Module import
:
// CommonJS require
const { fetchStats } = require('contribution');
// ES Module import
import { fetchStats } from 'contribution';
Contribution can be used with callbacks, promises or async/await:
// Callbacks
fetchStats('jamieweavis', {
onSuccess: (data) => console.log(data),
onFailure: (error) => console.log(error),
});
// Promises
fetchStats('jamieweavis')
.then((data) => console.log(data))
.catch((error) => console.log(error));
// Async/await
async function getContributionData() {
try {
const data = await fetchStats('jamieweavis');
console.log(data);
} catch (error) {
console.log(error);
}
}
Type: Function
Returns: Promise
Resolves: Object
Resolves an object with the following structure:
{
streak: {
best: Number,
current: Number,
},
contributions: {
best: Number,
current: Number,
total: Number,
}
}
Type: String
The GitHub username to fetch contribution data for.
Type: Object
Type: Function
Parameters: data
Callback function to handle the returned data. Passed a data
object which has the same structure as the resolved data object above.
Type: Function
Parameters: error
Callback function to handle an error. Passed an error
object which corresponds to a HTTP Response with error.statusCode
etc.
Type: Boolean
Default: false
Whether to proxy the request through the cors-anywhere API to enable fetching data x-origin. Set this option to true if you are using contribution
through the browser.
- streaker - π GitHub contribution streak & stat tracking menu bar app
- streaker-cli - π GitHub contribution streak & stat tracking CLI app
This project is licensed under the MIT License - see the LICENSE.md file for details.