Skip to content

xan105/github-user-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Example

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
  }
*/

Install

npm install @xan105/github-user-stats

API

⚠️ This module is only available as an ECMAScript module (ESM).

Named export

getUserStats(username: string): Promise<object>

Fetch a given github user stats.

Return

{
  repos: number, //public repos
  gists: number, 
  followers: number,
  following: number,
  stars: number,
  forks: number
}

❌ Throws on error.

Related

Inspired by:

About

GitHub user stats such as total stars, forks, repos (public) using standard fetch

Topics

Resources

License

Stars

Watchers

Forks