API Description - salierri/qpa-matrix GitHub Wiki
Routes
GET /pixels/reserve
Tries to reserve a new pixel
Parameters: none
Returns:
- status: "error" - if an error occured
- status: "reserved" - if a pixel was reserved
- pixel: {x: ,y: , color: {r: g: b: }}
- session: ""
- suggested: {r:, g:, b:} (can be undefined)
- status: "queue" - if there was no free pixels
- nextRealloc: time in milliseconds
- session: ""
POST /pixels
Your current pixel
Parameters: session: ""
Returns:
- status: "error" - if the session is invalid or an error occured
- status: "haspixel" - if you have a valid pixel
- pixel: {x: ,y: ,color: {r: g: b: }}
- suggested: {r:, g:, b:} (can be undefined)
- status: "queue" - if you are still in queue
- nextRealloc: time in milliseconds
POST /pixels/update
Update your pixel
Parameters: session: "", color: {r: 0..255, g: 0..255, b: 0..255 }
Returns:
- status: "error" - if the session is invalid or an error occured
- status: "nopixel - you don't have a pixel
- nextRealloc: time in milliseconds
- status: "success" - successful update
- nextRealloc: time in milliseconds
- suggested: {r:, g:, b:} (can be undefined)
POST /connection/keepalive
Keeping the connection (the user is still at the phone)
Parameters: session: ""
Returns:
- status: "error" - if the session is invalid or an error occured
- status: "success" - successful keeping alive
- hasPixel: true/false you have a pixel or not
- nextRealloc: time in milliseconds
POST /connection/drop
Dropping the connection (the user has left the phone)
Parameters: session: ""
Returns:
- status: "error" - if the session is invalid or an error occured
- status: "success" - successful keeping alive
GET /pixels/viewall
Get all pixel colors
Parameters: none
Returns:
- [{x: , y: , color: {r: , g: , b: }, ..... ] - list of pixels
Admin page
Requires Bfb-Admin-Key
header for each path, the admin key for development is: FHkHAD7BfeIdxQ2j55tldANzO
POST /bfbadmin
Check if your key is valid
Parameters: none
Returns:
- status: "error" - the password is invalid
- status: "success" - the password is valid
GET /bfbadmin/stats
Get basic stats from the game
Parameters: none
Returns:
- status: "error" - the admin key is invalid
- status: "success" - successful get
- userCount: sum users,
- usersWithPixels: users who currently has pixel,
- usersInQueue: users who currently doesn't have pixel
- emptyPixels: empty pixels (mainly for debug purposes, as this can be calculated)
- nextRealloc: time in milliseconds, or false if not initiated
POST /bfbadmin/image
Set the suggested image by id
Parameters:
- image: the id of the image or 0 if no image should be suggested
Returns:
- status: "error" - the admin key is invalid
- status: "success" - everything went as expected
POST /bfbadmin/reset
Resets the current table by shuffling the currently active users' pixels
Parameters: none
Returns:
- status: "error" - the admin key is invalid
- status: "success" - everything went as expected
POST /bfbadmin/log
Frontend logging for debug - No admin key required
Parameters:
- log: the log as a string
Returns:
- status: "success" - everything went as expected