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 🙏

© 2024 – Pkg Stats / Ryan Hefner

gist-client

v1.1.1

Published

A client to consume Gist API with JS

Downloads

119

Readme

NPM

Gist Client

Build Status Coverage Status Known Vulnerabilities

A client to consume Gist API with JS. Provides some features like filtering or abstraction of resource pagination. You don't know Gist? See official Github's help.

Installation

Get a Github token

Certain operations on Gist require authorization. Read more about how to get a granted token in 'About scopes for OAuth Apps'.

Basic use

To use Gist Client you need to require it and create an instance:

If you want to get your private Gist or perform some securized operation, you need to use setToken method to bind your token:

Getting a Gist

Gist Client works with promises. For example, if you want to get a single Gist you do the following:

You don't need a token to get a public Gist, but if you are trying to get a private one, you need to set the token. You can do:

Or:

Get a Gist list

You can use getAll method to get a Gist list:

Iterating the list

Results can be iterated without worrying about pagination:

Filtering the list

Gist Client allows you to filter results. You can append filters, it will be applied with 'AND' criteria.

This call will be return all user's public gists in PHP that have been updated since given date.

There is a limited list of filters that can be applied to a result:

| Filter | Tier | Type | Notes | |-----------|----------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | since | global | string | A timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Only gists updated at or after this time are returned. | | userName | resource | string | Name of the user whose documents you want to list. | | starred | resource | bool | Starred gists. | | public | resource | bool | Public gists. | | filename | file | string | Complete file name, f.ex: doc.json, index.sh... It doesn`t filter files inside a gist. It just filter all gists that contains a file with given name.| | size | file | int | File size in Kb. | | raw_url | file | string | Url to file's raw content. | | type | file | string | text/plain, application/json... | | language | file | string | PHP, Javascript, Erlang, Java... | | truncated | file | bool | The Gist API provides up to one megabyte of content for each file in the gist. Each file returned for a gist through the API has a key called truncated. If truncated is true, the file is too large and only a portion of the contents were returned in content. | | content | file | string | File content. IMPORTANT: You must to activate option rawContent to use this filter. |

  • resource tier: filters at API resource level. You can't combine these filters types between them; for example if you are using 'userName' you can't use 'starred' too.
  • file: filters at the level of documents linked to gists. It will search for any gist that contains a file with the given criteria.
  • global tier: Can be used in combination with any other.

Bind raw content

Gist API hides the content of the files in lists to decrease payload. Gist Client provides an option to bind the content in list; rawContent (true|false). You can use it as follow:

IMPORTANT: Be careful with the preceding call. Using this option in combination with 'filterBy' is highly recommended to limit the total amount of requests to Gist API. Keep in mind that there were an aditional API call for each retrieved file. It can rebase your remaining rate limit on Github API.

Get a gist revision

Get gist commits

Get gist forks

Check if gist is starred

Star / unstar gists

Create / update gists

To create a new gist you can use 'create' method as follow:

To edit a gist you can use 'update' metod:

Delete a gist

If you need information about Gist API, you can see official documentation.