Skip to content

moo-w/geasty

Repository files navigation

geasty

npm version npm downloads jsDocs.io

Simple and easy to use TypeScript library for interacting with GitHub Gist API.

Features

  • Use ofetch, a better fetch API, works on node, browser and workers.
  • Full CRUD operations for gists
  • Support for forks, stars, and commits
  • Type-safe API with proper TypeScript definitions
  • Authentication via GitHub access tokens

Installation

npm install geasty

Usage

import Geasty from 'geasty'

// Initialize with your GitHub access token
const geasty = new Geasty({ access_token: 'your-github-token' })

// Example: Create a gist
const newGist = await geasty.createAGist({
  files: {
    'hello.txt': { content: 'Hello World!' }
  },
  public: true,
  description: 'My first gist'
})

// Example: Get all gists
const myGists = await geasty.getAllGists()

GitHub Authentication

You can use Geasty with or without authentication. However, to access private gists or perform write operations, you need to provide a GitHub access token. It is recommended to provide an access token, cause authenticated requests have a higher rate limit.

API Methods

Gist Retrieval

  • getAGist(gistId)
  • getAllGists(options)
  • getPublicGists(options)
  • getStarredGists(options)
  • getGistsForUser(options)

Create, Delete, Update

  • createAGist(options)
  • deleteAGist(gistId)
  • updateAGist(options)

Forks

  • getGistForks(options)
  • forkAGist(gistId)

Commits

  • getGistCommits(options)
  • getAGistRevision(options)

Stars

  • isGistStarred(gistId)
  • starAGist(gistId)
  • unstarAGist(gistId)

Utils

  • getRawGistFileContent(options)
  • hasAccessToken()

Important

Check the Type Doc for detailed information.

References

GitHub REST API endpoints for gists

License

MIT License © 2025-PRESENT Moozon Wei

About

Simple and easy to use TypeScript library for interacting with GitHub Gist API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published