glitch-api
v3.1.0
Published
Library for using Glitch API ⚙️
Downloads
40
Readme
glitch-api
A Node.js module that allows you to easily interact with the Glitch API
| 📖 Documentation | ✨ Examples | | ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
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
andalgoliasearch
- 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 aProject
instance. Consider getting project data with token viaapi.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 ♥️
- VK: @tarnatovski
- git: @jarvis394