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

gist-oauth

v1.0.3

Published

A package that provides easy way to call Gist Github's API.

Readme

gist-oauth

  • A small library (< 4kb when minimized and gzipped) through which we can call all Gist APIs provided by github.
  • If it is an express application, It is recommended to use with github-oauth-express for OAuth. A small < 6kb package. (A five min simple implementation for getting github Auth token)
  • Or else you can use your own way of getting OAuth Token from github. As authToken is essential for accessing user specific datas.
npm install --save github-oauth-express gist-oauth

Contents

Initial Setup

const express = require('express');
const app = express();

const githubAPI = require('github-oauth-express');
const gistOAuth = require('gist-oauth');

// YOUR EXPRESS APPLICATION

githubAPI(
  app, // Send your app instance to get OAuth Access
  {
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
    redirectURL: '/oauth-call'
  }
)
  .then(authToken => {
    console.log('Obtained Auth token');
    const gistAPI = gistOauth(authToken);

    // gistAPI provides all Gist's API
    // For Eg:
    gistAPI
      .getGists() // returns all public and secret gists of that user.
      .then(res => console.log('res:', res))
      .catch(err => console.log('err:', err));
  })
  .catch(err => console.log(err));

APIs

  • Every API returns a promise. Results are obtained in resolved object. So if any error occured during the process then it will be rejected.

List a user's gists

Parameters

  • since - optional This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Only gists updated at or after this time are returned.
gistAPI
  .getGists(since) // returns all public and secret gists of that user.
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

List all public gists

Parameters

  • since - optional This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Only gists updated at or after this time are returned.
gistAPI
  .getPublic(since)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

List starred gists

Parameters

  • since - optional This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Only gists updated at or after this time are returned.
gistAPI
  .getStarred(since)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

Get a single gist

Parameters

  • gistId - Particular ID of the gist obtained in above APIs.
gistAPI
  .getGist(gistId)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

Get a specific revision of a gist

Parameters

  • gistId - Particular ID of the gist obtained in above APIs.
  • sha - Particular file's SHA
gistAPI
  .getSpecificRevision(gistId, sha)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

Create a gist

Parameters

  • files (object) - List of files. They must be of format like

    const files = {
      'file1.txt': {
        content: 'Entire file contents'
      },
      'file2.py': {
        content: "print('Hello world')"
      }
    };
  • description (string) - A small description about the gist.

  • isPublic (boolean) - true if public and false to create a secret gist.

gistAPI
  .create(files, description, isPublic)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

Edit a gist

Parameters

  • gistId (string) - Gist Id of the particular gist.

  • files (object) - Files of format

    const files = {
      'file1.txt': {
        content: 'Entire file contents'
      },
      'file2.py': {
        content: "print('Hello world')"
      }
    };

    with edited contents.

  • description (string) - Updated description

gistAPI
  .edit(gistId, files, description)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

List gist commits

Parameters

  • gistId (string) - Gist Id of the particular gist.
gistAPI
  .getCommitsList(gistId)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

Star a gist

Parameters

  • gistId (string) - Gist Id of the particular gist.
gistAPI
  .starGist(gistId)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response - If done - Just resolves, else rejects the promise.

Unstar a gist

Parameters

  • gistId (string) - Gist Id of the particular gist.
gistAPI
  .unStarGist(gistId)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response - If done - Just resolves, else rejects the promise.

Check if a gist is starred

Parameters

  • gistId (string) - Gist Id of the particular gist.
gistAPI
  .isGistStarred(gistId)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response - true if starred. false if unstarred.

Fork a gist

Parameters

  • gistId (string) - Gist Id of the particular gist.
gistAPI
  .forkGist(gistId)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

List gist forks

Parameters

  • gistId (string) - Gist Id of the particular gist.
gistAPI
  .getForksList(gistId)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response

Delete a gist

Parameters

  • gistId (string) - Gist Id of the particular gist.
gistAPI
  .deleteGist(gistId)
  .then(res => console.log('res:', res))
  .catch(err => console.log('err:', err));

Response - If done - Just resolves, else rejects the promise.

For all API Responses refer Gist Github API reference.