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

@uni-git/provider-github

v0.0.1

Published

GitHub provider for unified Git API

Downloads

2

Readme

@uni-git/provider-github

GitHub provider for the Uni-Git unified Git API library.

This package provides a complete GitHub API implementation supporting GitHub.com and GitHub Enterprise Server, with multiple authentication methods including personal access tokens, fine-grained tokens, and GitHub Apps.

Installation

npm install @uni-git/provider-github
# or
yarn add @uni-git/provider-github
# or
pnpm add @uni-git/provider-github

Peer Dependencies:

  • @octokit/rest - GitHub REST API client
  • @octokit/auth-app - GitHub App authentication (if using App auth)
npm install @octokit/rest @octokit/auth-app

Usage

Basic Setup

import { GitHubProvider } from '@uni-git/provider-github';

// Personal Access Token
const provider = new GitHubProvider({
  auth: {
    kind: "token",
    token: process.env.GITHUB_TOKEN
  }
});

// GitHub Enterprise Server
const enterpriseProvider = new GitHubProvider({
  auth: {
    kind: "token", 
    token: process.env.GITHUB_TOKEN
  },
  baseUrl: "https://github.company.com/api/v3"
});

Authentication Methods

Personal Access Token (Classic)

const provider = new GitHubProvider({
  auth: {
    kind: "token",
    token: "ghp_xxxxxxxxxxxxxxxxxxxx"
  }
});

Required Scopes:

  • repo - Repository access (includes private repos)
  • read:org - Organization membership access

Fine-Grained Personal Access Token

const provider = new GitHubProvider({
  auth: {
    kind: "token",
    token: "github_pat_xxxxxxxxxxxxxxxxxxxx"
  }
});

Required Permissions:

  • Repository permissions: Contents (Read), Metadata (Read), Pull requests (Read)
  • Account permissions: Organization permissions (Read)

GitHub App

const provider = new GitHubProvider({
  auth: {
    kind: "app",
    appId: 12345,
    privateKey: process.env.GITHUB_APP_PRIVATE_KEY,
    installationId: 67890 // Optional - auto-detected if not provided
  }
});

Required App Permissions:

  • Repository permissions: Contents (Read), Metadata (Read), Pull requests (Read)
  • Organization permissions: Members (Read)

API Methods

Repository Operations

// Get repository metadata
const repo = await provider.getRepoMetadata("owner/repository");
console.log(repo.fullName, repo.defaultBranch, repo.isPrivate);

// List user repositories
const repos = await provider.getUserRepos({
  perPage: 50,
  maxItems: 200
});

// Get repository branches
const branches = await provider.getRepoBranches("owner/repository");

// Get repository tags
const tags = await provider.getRepoTags("owner/repository");

Organization Operations

// List user's organizations
const organizations = await provider.getOrganizations();

// List organization repositories
const orgRepos = await provider.getOrganizationRepos("github");

// Search organization repositories
const searchResults = await provider.getOrganizationRepos(
  "github", 
  "typescript",
  { maxItems: 10 }
);

Advanced Configuration

const provider = new GitHubProvider({
  auth: { kind: "token", token: process.env.GITHUB_TOKEN },
  baseUrl: "https://api.github.com", // Custom API URL
  userAgent: "MyApp/1.0.0", // Custom user agent
  requestTimeoutMs: 10000 // Request timeout
});

Error Handling

import { AuthError, NotFoundError, RateLimitError } from '@uni-git/core';

try {
  const repos = await provider.getUserRepos();
} catch (error) {
  if (error instanceof AuthError) {
    console.error('Authentication failed - check your token and scopes');
  } else if (error instanceof NotFoundError) {
    console.error('Repository or organization not found');
  } else if (error instanceof RateLimitError) {
    console.error(`Rate limited. Reset at: ${error.resetTime}`);
  }
}

Features

Organization Support

  • Automatic organization discovery
  • Role-based access (member, admin, owner)
  • Enhanced search with repository descriptions
  • Membership visibility handling

Repository Access

  • Public and private repository support
  • Comprehensive metadata extraction
  • Branch and tag enumeration
  • Clone URL generation (HTTPS/SSH)

Authentication Flexibility

  • Multiple authentication methods
  • Automatic token validation
  • GitHub Enterprise Server support
  • GitHub App installation handling

Performance Optimizations

  • Intelligent pagination
  • Request retry logic
  • Rate limit awareness
  • Concurrent request batching

GitHub Enterprise Server

For GitHub Enterprise Server instances:

const provider = new GitHubProvider({
  auth: { kind: "token", token: process.env.GHE_TOKEN },
  baseUrl: "https://github.company.com/api/v3"
});

Additional Considerations:

  • Verify SSL certificates are properly configured
  • Some API features may differ between GitHub.com and Enterprise Server versions
  • Rate limits may be configured differently

Troubleshooting

Common Issues

403 Forbidden Errors:

  • Check token scopes/permissions
  • Verify organization membership visibility
  • Ensure repository access permissions

404 Not Found Errors:

  • Repository may be private without access
  • Organization name may be incorrect
  • Resource may have been deleted or renamed

Rate Limiting:

  • Use pagination options to reduce API calls
  • Implement proper retry logic
  • Consider GitHub App for higher rate limits

Testing

Run integration tests with your GitHub credentials:

export GITHUB_TOKEN=your_token_here
npm test

For GitHub App testing:

export GITHUB_APP_ID=your_app_id
export GITHUB_APP_PRIVATE_KEY=your_private_key
export GITHUB_APP_INSTALLATION_ID=installation_id
npm test

Related Packages

License

MIT