Glitch Editor API

GlitchEditingAPI

The Glitch Editing API allows one to edit Glitch documents without being in the Glitch editor.

Disclaimer:

This is nowhere near being done. I haven’t documented everything. Please note this is unofficial and is the product of attempting to reverse engineer Glitch’s API, something that isn’t public now.

I am in no way trying to harm Glitch or any Glitch service. This is simply for educational purposes.

URL

Type: Websocket

wss://api.glitch.com/YOUR_PROJECT_ID/ot?authorization=YOUR_AUTH_TOKEN

Send/Payload

Sample payload

{
  "type": "broadcast",
  "payload": {
    "user": {
      "avatarUrl": null,
      "avatarThumbnailUrl": null,
      "awaitingInvite": false,
      "id": 12345,
      "name": null,
      "login": null,
      "color": "#94f0e4",
      "lastCursor": {
        "cursor": {
          "line": 0,
          "ch": 0,
          "sticky": null
        },
        "documentId": "hs943sduer",
        "clientId": "nMso39kHwo"
      },
      "readOnly": null,
      "thanksReceived": false,
      "tabId": "92830",
      "teams": [],
      "projectPermission": {
        "userId": 12345,
        "projectId": "933nse-23jwhef-msbdfo-3jiked",
        "accessLevel": 30
      },
      "invited": false,
      "left": false,
      "stopAsking": false
    }
  }
}

Values:

type:

Type of event the client is sending/reciving to or from the server. Can be broadcast or master-state.

payload:

Details of the event. (JSON format)

user:

Details of the user. (JSON format)

avatarUrl:

Url to avatar photo. Leave as null for anonymous accounts. (string)

avatarThumbnailUrl:

Thumbnail of the avatar. Leave as null for anonymous accounts. (string)

awaitingInvite:

Shows if the authorized user is waiting to join the project. (Unknown) (bool)

id:

ID of the authorized user. Do not leave null. (int)

name:

Nickname of the authorized user. Leave as null for anonymous accounts. (string)

login:

Username of the authorized user. Leave as null for anonymous accounts. (string)

color:

Color of the authorized users cursor. Must be a hex color value.

lastCursor:

Details about the last location of the authorized user’s cursor. (JSON format)

cursor:

Details about the last location of the authorized user’s cursor. (JSON format)

line:

Number of the line the cursor is on. (int)

ch:

What charactor the cursor is on. (int)

sticky:

unknown

documentId:

unknown

clientId:

unknown

readOnly:

Can the client edit the project? Left null if true.

thanksReceived:

unknown

tabId:

unknown, likley has something do with the file ID

teams:

Teams that have access to this project (JSON format)

projectPermission:

Permissions for the user. (JSON format)

userId:

ID of the authorized user. (int)

projectId:

ID of the project (int)

accessLevel:

What the user can do in the project: (int)

  • 30: Full read and write
  • 0: Read only

invited:

Was the user invited by an owner or member? (bool)

left:

Did the user leave the project?

stopAsking:

(LIKLEY DEPRECATED) Has the user stopped asking for help? (bool)

Recive Payload

Sample:

{
  "type": "broadcast",
  "payload": {
    "type": "project-stats",
    "timeNs": 1607455201265000000,
    "cpuUsage": 13594074430,
    "diskSize": 209175552,
    "diskUsage": 88976384,
    "memoryLimit": 536870912,
    "memoryUsage": 198082560,
    "quotaPercent": 0.25,
    "cpuUsagePercent": 0.003623644049827723,
    "quotaUsagePercent": 0.014494576199310893
  }
}

payload:

Details of the sent event (JSON)

type:

Type of payload

timeNs:

Epoch time

cpuUsage:

% of CPU used (3535966264 would be about 3.5%)

diskSize:

Total size of the disk in bytes

diskUsage:

Used disk space in bytes

memoryLimit:

Memory limit in bytes

memoryUsage:

Used memory in bytes

quotaPercent:

Unknown

cpuUsagePercent:

Percent of CPU used

quotaUsagePercent:

Unknown

4 Likes

quota might be the 4000 free requests thing

2 Likes

Just had a read, that would make sense.

OP do you have a POC of this?

1 Like

Well, this would be hard for me (Because i’m mobile user). Also, i will create my Own Glitch Editor because editing codes on Mobile seems like Suck.