Get GitHub user stats such as total stars, forks, repos (public) using standard fetch().
This is an isomorphic ECMAScript module (ESM) you can use it in Node or in the Browser.
GitHub API ratelimit is taken into account.
📦 Scoped @xan105
packages are for my own personal use but feel free to use them.
import { getUserStats } from "@xan105/github-user-stats"
console.time("request");
const stats = await getStats("xan105");
console.timeEnd("request");
console.log(stats);
/*
request: 1.432s
{
repos: 41,
gists: 0,
followers: 45,
following: 4,
stars: 559,
forks: 73
}
*/
Again but with a high number of repos
import { getUserStats } from "@xan105/github-user-stats"
console.time("request");
const stats = await getStats("microsoft");
console.timeEnd("request");
console.log(stats);
/*
request: 3.961s
{
repos: 5522,
gists: 0,
followers: 33898,
following: 0,
stars: 2204633,
forks: 501477
}
*/
npm install @xan105/github-user-stats
Fetch a given github user stats.
Return
{
repos: number, //public repos
gists: number,
followers: number,
following: number,
stars: number,
forks: number
}
❌ Throws on error.
Inspired by: