3.1.0 • Published 4 years ago

glitch-api v3.1.0

Weekly downloads
23
License
MIT
Repository
github
Last release
4 years ago

glitch-api

GitHub package.json dynamic CircleCI npm bundle size

A Node.js module that allows you to easily interact with the Glitch API

📖 DocumentationExamples

Features

  • 99% coverage of the known Glitch API
  • Uses TypeScript that provides hints in editor, type checking, etc.
  • Supports WebSocket connection to the Glitch editor
  • Support for authorization
  • Only two dependencies: node-fetch and algoliasearch
  • Class abstraction
  • Works with both API versions
Warning: this module uses unstable API that hasn't been officially released yet. Described only world-open methods from this unofficial site and my researches

Installation

Node.js 8.0.0 or newer is required

NPM
npm i glitch-api -s

Example usage

// Require using ES6 syntax
import { Glitch } from 'glitch-api'

// Or using old fancy style
const { Glitch } = require('glitch-api')

// Init main class
const glitch = new Glitch({ token: 'xxx' })  // Put here your Glitch token or use glitch.setAnonToken()
const { api } = glitch

// Get a user profile
api.users.get({ id: 1 }).then(user => console.log) // → User

❗ Migration from 2.x to 3.x

  • Any search method now follows the same syntax:
    .search(s: string) → Algolia result
  • Remixing a project doesn't return joinLink. Now it is a Project instance. Consider getting project data with token via api.projects.get()
  • Token is absolutely required. If you don't have a token, consider using Glitch.setAnonToken(). For more info, see examples/anonymous.js

Q&A

How do I get Glitch token?

Paste the following code to the browser's console on the Glitch editor page:

(JSON.parse(localStorage.getItem('cachedUser'))).persistentToken

Also you can use Glitch.setAnonToken() → Promise<string> method to login as an anonymous user and use its token.


Why **api-method** is not implemented?

Because I'm also human and I might not have seen the recent changes in Glitch's API. Anyway, PRs are open for anyone :)


The **api-method** is not working.

It could be that Glitch devs removed the support for that method. Or it's just a my fault. Open a new issue and describe what's happend.

Contribution

Feel free to open new Pull request or an issue!

Credits

Made by jarvis394 with ♥️

3.1.0

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

3.0.0-alpha3

4 years ago

3.0.0-alpha2

4 years ago

3.0.0-alpha1

4 years ago

2.4.0

4 years ago

2.3.4

4 years ago

2.3.3

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

1.2.1

5 years ago

1.3.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago