npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rodbe/github-api

v2.4.0

Published

Typed and customizable wrapper for the GitHub API

Downloads

622

Readme

🐙 @rodbe/github-api

Typed and customizable wrapper for the GitHub REST API. Handles pagination automatically and supports custom mappers to transform responses into the shape your app needs.

📦 Installation

npm install @rodbe/github-api
# or
pnpm add @rodbe/github-api

✅ Requirements

📖 API

All functions accept a token parameter (GitHub personal access token) and an optional mapper function to transform each item in the response.

getOrgs({ token, mapper? }) 🏢

Fetches all organizations for the authenticated user. Handles pagination automatically.

import { getOrgs } from '@rodbe/github-api';

const { organizations, errors } = await getOrgs({ token: 'ghp_...' });

// With a custom mapper
const { organizations } = await getOrgs({
  token: 'ghp_...',
  mapper: org => ({ id: org.id, name: org.login, avatar: org.avatar_url }),
});

Returns: { organizations: T[], errors: Error[] }


getReposByUser({ token, mapper? }) 👤

Fetches all repositories for the authenticated user (owned, member, forked, etc.).

import { getReposByUser } from '@rodbe/github-api';

const repos = await getReposByUser({ token: 'ghp_...' });

// With a custom mapper
const repos = await getReposByUser({
  token: 'ghp_...',
  mapper: repo => ({ name: repo.name, isPrivate: repo.private, stars: repo.stargazers_count }),
});

Returns: T[]


getReposByOrg({ token, org, mapper? }) 🏗️

Fetches all repositories for a specific organization.

import { getReposByOrg } from '@rodbe/github-api';

const repos = await getReposByOrg({ token: 'ghp_...', org: 'my-org' });

// With a custom mapper
const repos = await getReposByOrg({
  token: 'ghp_...',
  org: 'my-org',
  mapper: repo => ({ name: repo.name, url: repo.html_url }),
});

Returns: T[]


getReposByOrgs({ token, orgs, mapper? }) 🏗️🏗️

Fetches repositories for multiple organizations in a single call. Returns a record keyed by org name.

import { getReposByOrgs } from '@rodbe/github-api';

const result = await getReposByOrgs({
  token: 'ghp_...',
  orgs: ['org-a', 'org-b'],
});

result['org-a']; // OrgRepository[]
result['org-b']; // OrgRepository[]

// With a custom mapper
const result = await getReposByOrgs({
  token: 'ghp_...',
  orgs: ['org-a', 'org-b'] as const,
  mapper: repo => repo.name,
});

Returns: Record<Org, T[]>


getStarredRepos({ token, mapper? })

Fetches all repositories starred by the authenticated user.

import { getStarredRepos } from '@rodbe/github-api';

const starred = await getStarredRepos({ token: 'ghp_...' });

// With a custom mapper
const starred = await getStarredRepos({
  token: 'ghp_...',
  mapper: repo => ({ name: repo.name, language: repo.language }),
});

Returns: T[]


🔄 Custom mappers

Every function accepts an optional mapper callback that receives the raw GitHub API object and returns a value of any shape. The return type of the function is inferred automatically from the mapper's return type.

// Without mapper → returns UserRepository[]
const repos = await getReposByUser({ token });

// With mapper → returns { name: string; stars: number }[]
const repos = await getReposByUser({
  token,
  mapper: repo => ({ name: repo.name, stars: repo.stargazers_count }),
});

🧩 Types

The following types are exported and can be used in your own code:

| Type | Description | | ---------------- | ------------------------------------- | | Organization | GitHub organization object | | UserRepository | Repository returned by user endpoints | | OrgRepository | Repository returned by org endpoints | | Owner | Repository owner object | | Permissions | Repository permissions object | | License | Repository license object |

📄 License

MIT