Open Source/2024/Active
Github-Api
A library for the GitHub API that fetches data from the API.
Overview
Github-Api is an unofficial, lightweight wrapper around GitHub's public REST API (api.github.com). It exposes a single Github class whose methods each map to one GitHub endpoint and return a Promise resolving to the parsed JSON response, using the native fetch API internally rather than a heavier HTTP client.
It's unauthenticated — the class doesn't accept a token, so every request goes through GitHub's unauthenticated rate limits. That makes it best suited for quick scripts, prototypes, or demos that need a handful of public GitHub data points (a user's profile, their repos, their gists) without setting up OAuth or a personal access token.
Key Features
Methods on the Github class, grouped by what they cover:
- User data —
getUser(username),getRepos(username),getStarred(username),getFollowers(username),getFollowing(username),getOrganizations(username),getSubscriptions(username),getEvents(username),getReceivedEvents(username),getContributions(username) - Gists —
getGists(username),getGist(gistId),getGistComments(gistId),getGistForks(gistId),getGistStar(gistId) - Misc —
getLicenses()for the list of licenses GitHub recognizes
All instance methods delegate to a static Github.getData(url) helper that performs the fetch call and JSON-parses the response.
Installation
npm install @chethanyadav456/github-apiUsage
const GithubAPI = require('@chethanyadav456/github-api');
const github = new GithubAPI();
// Fetch a user's profile
github.getUser('chethanyadav456').then(data => {
console.log(data);
});
// Fetch a user's public repositories
github.getRepos('chethanyadav456').then(data => {
console.log(data);
});