Giter VIP home page Giter VIP logo

github-gist-api-encapsulation's Introduction

GitHub Gist API Encapsulation

API Doc

How to use

  1. Get your GitHub access token

https://github.com/settings/tokens

  1. Modify GIST_TOKEN in gist.js
  2. import class gist to your project
import Gist from "./gist.js";

Functions Ref

Get a gist

let gist_id1 = "335b41c561e25a372b913a8698bdcdca";
Gist.get({ type: Gist.type.getGist, gist_id: gist_id1 })

Get all gists

Gist.get({ type: Gist.type.getGists })

Get all starred gists

Gist.get({ type: Gist.type.getStarredGists })

Get a gist revision

let gist_id1 = "335b41c561e25a372b913a8698bdcdca";
let sha1 = "bb91943594f69dba3e48db2a47a51a137620f4d1";
Gist.get({ type: Gist.type.getGistHistory, gist_id: gist_id1, sha: sha1 })

Create a gist

content = {
    "description": "The description for this gist",
    "public": true,
    "files": {
        "test1.py": {
            "content": "print(\"Hello World\")"
        }
    }
}
Gist.post({ type: Gist.type.createGist, content: content })

Update a gist

content = {
    "description": "The description for this gist",
    "public": true,
    "files": {
        "test1.py": {
            "content": "print(\"Hi there\")"
        }
    }
}
id = "999a2b3b6f20e7645eaacc4efb80b091"
Gist.patch({ type: Gist.type.updateGist, content: content, gist_id: id })

Delete a gist

id = "999a2b3b6f20e7645eaacc4efb80b091"
Gist.delete({ type: Gist.type.deleteGist, gist_id: id })

Star a gist

id = "999a2b3b6f20e7645eaacc4efb80b091";
Gist.put({ type: Gist.type.starGist, gist_id: id })

Unstart a gist

id = "999a2b3b6f20e7645eaacc4efb80b091";
Gist.delete({ type: Gist.type.unStarGist, gist_id: id })

github-gist-api-encapsulation's People

Contributors

yuenci avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.