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

ghrepos

v3.0.0

Published

Interact with the GitHub repos API

Readme

ghrepos

A Node.js library to interact with the GitHub repos API

NPM

Requirements

  • Node.js >= 20

Example usage

import * as ghrepos from 'ghrepos'

const auth = { token: 'your-github-token' }

// list all repos for a user
const repos = await ghrepos.listUser(auth, 'rvagg')
console.log(repos)

// list all repos for an org
const orgRepos = await ghrepos.listOrg(auth, 'nodejs')
console.log(orgRepos)

// get branch data
const branch = await ghrepos.getBranch(auth, 'nodejs', 'node', 'main')
console.log(branch)

// get commit comments
const comments = await ghrepos.getCommitComments(auth, 'nodejs', 'node', '75318e46b')
console.log(comments)

The auth data is compatible with ghauth so you can connect them together:

import ghauth from 'ghauth'
import * as ghrepos from 'ghrepos'

const auth = await ghauth({
  configName: 'repo-lister',
  scopes: ['user']
})

const repos = await ghrepos.listUser(auth, 'rvagg')
console.log('Repos for rvagg:')
repos.forEach((r) => {
  console.log('%s: %s (fork: %s)', r.name, r.description, r.fork)
})

API

All methods return Promises.

ghrepos.listUser(auth, user, options)

List all repos for a user. If user is falsy, lists repos for the authenticated user.

ghrepos.listOrg(auth, org, options)

List all repos for an organisation.

ghrepos.listRefs(auth, org, repo, options)

Get git ref data for all refs in a repo.

ghrepos.listTags(auth, org, repo, options)

List git tags for a repo.

ghrepos.listBranches(auth, org, repo, options)

List git branches for a repo.

ghrepos.listCommits(auth, org, repo, options)

List git commits for a repo.

ghrepos.getRef(auth, org, repo, ref, options)

Get git ref data for a particular ref string. The refs/ prefix is automatically stripped if present.

ghrepos.getBranch(auth, org, repo, branch, options)

Get git branch data for a given branch name.

ghrepos.getCommit(auth, org, repo, sha, options)

Get git commit data for a given SHA.

ghrepos.getCommitComments(auth, org, repo, sha, options)

Get commit comments for a given SHA.

ghrepos.createLister(type)

Creates a function that lists sub-resources under /repos/:org/:repo/:type, e.g. 'issues', 'pulls' or 'releases'. The returned function has the signature: async function (auth, org, repo, options).

ghrepos.baseUrl(org, repo, options)

Returns the base API URL for a repo: https://api.github.com/repos/:org/:repo.

Authentication

See ghauth for an easy way to obtain and cache GitHub authentication tokens. The auth object returned by ghauth is directly compatible with all ghrepos methods.

See also

  • ghissues - interact with the GitHub issues API
  • ghusers - interact with the GitHub users API
  • ghteams - interact with the GitHub teams API
  • ghpulls - interact with the GitHub pull requests API
  • ghauth - GitHub authentication

License

ghrepos is Copyright (c) 2014-2025 Rod Vagg @rvagg and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.