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 = ;const app = ; const githubAPI = ;const gistOAuth = ; // YOUR EXPRESS APPLICATION ;
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 // returns all public and secret gists of that user. ;
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 ;
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 ;
Get a single gist
Parameters
- gistId - Particular ID of the gist obtained in above APIs.
gistAPI ;
Get a specific revision of a gist
Parameters
- gistId - Particular ID of the gist obtained in above APIs.
- sha - Particular file's SHA
gistAPI ;
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 andfalse
to create a secret gist.
gistAPI ;
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 ;
List gist commits
Parameters
- gistId (string) - Gist Id of the particular gist.
gistAPI ;
Star a gist
Parameters
- gistId (string) - Gist Id of the particular gist.
gistAPI ;
Response - If done - Just resolves, else rejects the promise.
Unstar a gist
Parameters
- gistId (string) - Gist Id of the particular gist.
gistAPI ;
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 ;
Response - true
if starred. false
if unstarred.
Fork a gist
Parameters
- gistId (string) - Gist Id of the particular gist.
gistAPI ;
List gist forks
Parameters
- gistId (string) - Gist Id of the particular gist.
gistAPI ;
Delete a gist
Parameters
- gistId (string) - Gist Id of the particular gist.
gistAPI ;
Response - If done - Just resolves, else rejects the promise.
For all API Responses refer Gist Github API reference.