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
// 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:
I think you might be able to get it from ‘Network’ panel in your browser’s dev panel. In Chrome, you can access it by pressing F12 and selecting ‘Network’. There you can see all requests and responses, so go to your profile page and see, what ID it is requesting.
Yes, I was searching for the exact parameters in the editor’s obfuscated code, but I’m still working on it. Surely, it would be the greatest feature of this package! I wonder how many things are possible to do with it.
Actually, all you have to do is connect by WebSockets to your application editor. Sounds pretty easy, but reengineering the code is pretty hard (for me).
If you have any thoughts about the Editor API, share it here
I’m actually might get to start WebSockets stuff going, so I hope in next release I would add:
Support for collections
Support for team pins
Class for remixed project and an interface to it
And, most important, Glitch’s editor abilities, like application.files() or application.logsData()
Hey @charliea21,
The library is build with power of TypeScript, so there would be some handy descriptions for every method (in a proper editor, like VSCode).
In addition to that, I’ve build a great documentation using TypeDoc (glapi.ml) and so you can always check what should something do.
Thanks. The code I posted was to mainly clarify some issues in this thread about getting a users ID. Also I may be creating a pull request at some point as I’m thinking of adding some features related to the Glitch Support Forum! (i doubt many people would use it but it would be a nice addition)
No, user IDs are public because you can get them by API without a token. And, of course, any token should be kept in private place because, for example, someone could retrieve list of private projects of a user