The server consists of HTTP API and a WebSocket server.
All endpoints are under /api and are POST only. Body must have a JSON object and be no more than 64 kB.
Errors are in this format: {"ok": false, "error": "bio is like... way too freaky.", "field": "bio"}. Basically if ok is false, you done f'd up.
| Endpoint | Payload | Notes |
|---|---|---|
/api/auth/register |
Required: login and passwordOptional: email, nickname, color and bio |
Returns ok as true on success along with an object with the User with heaps of info I am too lazy to list, just check it. Note that register doesn't log user in. |
/api/auth/login |
Required: login and passwordOptional: duration |
Returns ok, along with token, user & expiration. |
/api/auth/logout |
Required: token |
Returns ok. That's it. |
/api/account/edit |
Required: tokenOptional: email, nickname, color and bio |
Returns ok plus a new user. |
In order to connect, setup a socket connection with wss://srv.quary.cz/socket. You can check whether the server is running or not at https://srv.quary.cz/socket/status.
All payloads are JSON objects as strings, the root object always contains a type (string).
Many of these return a timestamp, but I can't be bothered to check which.
| Type | Sent by | Payload | Notes |
|---|---|---|---|
system.init |
Server | clientId (string) |
Sent instantly after connecting, note that clientId is a stringified number. |
auth.login |
Client | token (string) |
Should be sent after system.init. |
auth.loggedin |
Server | expiresAt (number), user (User) |
Sent after successful login. Mostly informational |
auth.logout |
Client | token (string) |
Logs you out, duh. |
auth.loggedout |
Server | reason (string) |
Basically a "Yep, you're out". Triggered both manually and automatically (note that there may be a up to 30 second limbo zone where your token expired but you won't get this message, honestly, consult your expireAt timestamp and end a bit early if you don't want to deal with it.). Reason can be either logout or invalidtoken. |
chat.user.status |
Client | status (string) |
Should only be sent after chat.user.join, changes user's status. |
chat.user.list |
Server | users (array of User) |
Sent after chat.user.join or at any user list change. Check object format below. |
chat.message.send |
Client | message (string) |
Sends message into chat. |
chat.message.single |
Server | message (Message) |
Sent to all users when a message is recieved by server. Check object format below. |
chat.message.history |
Server | messages (array of Message) |
Sent to user after chat.user.join. Contains up to 20 last messages. |
system.ping |
Client | empty | Used to keep socket alive (send every 15~20 seconds to keep TTL high), can be used for debugging. |
system.pong |
Server | timestamp (number) |
Server response to system.ping. Contains timestamp for profiling & convenience. |
Example {"type": "chat.user.profile", "nick": "Alice", "color": "#ff0000"}.
Example {"type": "chat.user.list", "users": [{"id": "1", "nick": "Alice", "color": "#ff0000", "status": "active"}, {"id": "2", "nick": "Amy", "color": "#0000ff", "status": "inactive"}]}.
User has attributes id (string), nick (string), color (string) & status (string). Example {"id": "1", "nick": "Alice", "color": "#ff0000", "status": "active"}.
Message has attributes timestamp (number, integer; unix milliseconds), nick (string), color (string) & message (string). Example {"timestamp": 1710000000000, "nick": "Alice", "color": "#ff0000", "message": "Hello!"}.
login is 2 to 32 characters login, alphanumeric lowercase only (uppercase gets converted anyway), you can use dot and underscore tho. Must be unique.
password has to be at least 1 character long (limit it on your client however you want), oh and 256 characters max.
nickname is up to 32 characters long. Not really limited in any other way, it's optional.
color must be one of "default", "red", "blue", "green", "yellow", "orange", "purple", "pink", "gray", "brown" or "cyan", defaults to "default".
status is either "active" or "inactive". Anything other than "active" is "inactive".
message is up to 512 (up from measly 500) characters long.
bio is up to 512 characters long.
duration is "4h", "8h", "12h", "24h", "1d", "72h", "3d", "168h", "7d", "720h" or "30d". If you forget it, you'll be punished by a 60 minute session only.