pixelplanet/API.md

56 lines
2.0 KiB
Markdown
Raw Normal View History

2020-01-02 16:58:06 +00:00
# API Websocket
This websocket provides unlimited access to many functions of the site, it is used for Discord Chat Bridge and Minecraft Bridge.
Websocket url:
`https://[old.]pixelplanet.fun/mcws`
Connection just possible with header:
```
Authorization: "Bearer APISOCKETKEY"
```
All requests are made as JSON encoded array.
### Subscribe to chat messages
```["sub", "chat"]```
All chat messages, except the once you send with `chat` or `mcchat`, will be sent to you in the form:
```["msg", name, message, id, country, channelId]```
channelId is an integer, channel 0 is `en` channel 1 is `int` and maybe more to come.
id is the user id
country is the [two-letter country code](https://www.nationsonline.org/oneworld/country_code_list.htm) in lowercase
2022-01-05 15:40:25 +00:00
### Online user counter
2020-01-02 16:58:06 +00:00
2022-01-05 15:40:25 +00:00
Online counter will be sent to you as typical binary package (see `src/socket/packets/OnlineCounter.js`)
2020-01-02 16:58:06 +00:00
### Subscribe to pixel packages
```["sub", "pxl"]```
All pixels (including your own) will be sent to you as typical binary packages
### Set Pixel
```[ "setpxl", minecraftid, ip, x, y, clr ]```
(x, y, clr are integers, rest strings)
Sets a pixel with the according cooldown to minecraftid, ip. Minecraftid is optional, but ip is required if it is given. If both minecraftid and ip are null/None, the pixel will get set without cooldown check. No race condition checks are performed.
You will get a reply with:
```["retpxl", id, error, success, waitSeconds, coolDownSeconds]```
(id and error as strings, success as boolean, waitSeconds and coolDownSeconds as float)
ID is minecraftid, if given, else ip.
error is a message on error, else null.
success... self explanatory
waitSeconds is the current cooldown.
coolDownSeconds is the added cooldown (negative if pixel couldn't be set because max cooldown got reached)
### Send Chat Message
```["chat", name, message, country, channelId]```
2020-01-02 16:58:06 +00:00
channelId is an integer, channel 0 is `en` channel 1 is `int` and maybe more to come.
2020-01-02 16:58:06 +00:00
(messages with the name "info" will be displayed as red notifications in the chat window)