XP-shell devices and plugins¶
XP-shell is XPARO’s app for a robot’s screen (kiosks, reception robots, displays). It signs in to an XPARO account as a device, keeps its settings in sync, and installs plugins from the XPARO Plugin Store. This page is for developers who build plugins or their own app on the same API.
The Plugin Store¶
Plugins are written, published and reviewed on the Plugin Store’s own pages:
Build a plugin (
/store/docs): the three kinds of plugin, the folder layout, everymanifest.jsonfield, how review works, and the Store API that XP-shell uses to list and download plugins.Templates (
/store/templates): a ready folder for each kind of plugin to start from.Publish (
/store/publish) and My plugins (/store/mine): upload a version and follow its review.
The store is also linked from the Account box on your profile page.
Signing a device in¶
Every call below goes to https://xparo.in/api/xpshell/v1/ and takes and
returns JSON. A device gets a device token in one of two ways, and sends
it on every later call:
Authorization: Bearer xpd_...
device_id is your own stable ID for the device (letters, digits and
. _ : -, up to 128 characters). device_name, platform and
app_version are optional and shown on the account’s devices page.
device_name can be up to 100 characters (spaces at the start and end
don’t count). A longer name is not cut short: pair/start, auth/login
and auth/signup answer 400, for example:
{"error": "device_name can be at most 100 characters (this one has 120)."}
Nothing is made then: no pairing code, no account and no sign-in. The call
still counts toward the Limits at the end of this page. Shorten the name
and send the call again. A device_id that breaks its rules also gets a
400. platform and app_version keep only their first 40
characters.
With a pairing code (recommended for screens)¶
Nobody has to type a password on the robot’s screen.
The device asks for a code:
POST pair/start {"device_id": "kiosk-01", "device_name": "Reception kiosk"}{"code": "3EUC-QWM9", "poll_token": "...", "expires_in": 600, "interval": 3, "verification_url": "https://xparo.in/profile/devices?code=3EUC-QWM9"}
The device shows the code (or
verification_urlas a QR code). The account owner opens/profile/devices, signed in, types the code and presses Link device.Meanwhile the device polls every
intervalseconds with the secretpoll_token(never show it):POST pair/poll {"poll_token": "..."}Status
Answer
202
{"status": "pending", "expires_in": ...}: not linked yet, keep polling.200
{"status": "approved", "token": "xpd_...", "user": {...}, "device": {...}}. The token is given only once: save it.410
status"used"(the token was already collected),"expired"(10 minutes passed) or"cancelled"(the owner pressed Sign out for the device before it collected the token). Start again withpair/start.404
Unknown
poll_token.
With a password¶
POST auth/login {"login": "<username or email>", "password": "...", "device_id": "kiosk-01"}
It answers {"token": "xpd_...", "user": {...}, "device": {...}}, or
401 {"error": "Invalid username/email or password."}.
auth/signup (username, email, password, device_id) makes a
new account and signs the device in; auth/password-reset (email)
sends a reset link.
Using the token¶
Call |
What it does |
|---|---|
|
The account and this device. |
|
Signs this device out (its token stops working). Other devices stay signed in. |
|
The keys this account has synced ( |
|
One synced value (404 if there is none). |
|
Stores |
|
Deletes it: |
A token does not expire. It stops working when the device signs out, when
the owner presses Sign out for it on /profile/devices, when the
account’s password is changed or reset (that signs out every device of the
account), or when the account is deactivated; calls then answer 401
{"detail": "Invalid or revoked device token."}. A signed-out device
leaves the account’s devices page until it signs in again. The owner gets one
email whenever a device is connected or signed out; a new password’s email
says how many devices it signed out instead.
Synced data¶
Synced data belongs to the account: every device signed in to it sees the
same keys, and for each key the write with the latest ts wins.
A key is 1 to 128 letters, digits and
. _ : -(else 400,"error_code": "bad_key"). Keys starting withxparo.are written by XPARO only; writing or deleting one answers 403 with"error_code": "read_only".A value is any JSON, up to 256 KB once written as JSON. An account keeps up to 1000 keys and 20 MB in all. Over a limit: 413 with
"error_code""too_large"("Values are limited to 256 KB.") or"quota".tsis the writer’s clock as Unix time in seconds (milliseconds are recognised). It is optional (the server’s time is used), and atsmore than 5 minutes ahead of the server’s clock counts as the server’s time.
Live sync over /ws/sync¶
Open a WebSocket to wss://xparo.in/ws/sync with the token in a
header of the opening request, the same header as the REST calls:
Authorization: Bearer xpd_...
X-Device-Id: kiosk-01
X-Device-Id is optional; if you send it, it must be this token’s
device_id. The token is read only from that header, never from the URL
(?token=) or Sec-WebSocket-Protocol. Without a valid token the
server accepts the connection, sends one error message and closes it with
code 4401:
{"op": "error", "error": "unauthorized", "message": "Sign in again: this device token is missing, invalid or revoked."}
An open connection gets the same message and close when its device is signed out.
Frames¶
Every message is a binary frame:
Bytes |
What they hold |
|---|---|
1 |
The frame type, one ASCII letter: |
4 |
The header’s length, a big-endian unsigned integer. |
header length |
The header, JSON in UTF-8. Send |
the rest |
The body. In a |
So every D message from the server starts with the 7 bytes D, 00 00 00
02, {}, followed by the JSON, for example
b'D\x00\x00\x00\x02{}{"op":"update",...}'. In Python:
import json, struct
def pack(message, frame_type=b"D"):
header = b"{}"
body = json.dumps(message).encode() if message is not None else b""
return frame_type + struct.pack(">I", len(header)) + header + body
def unpack(frame):
(header_len,) = struct.unpack(">I", frame[1:5])
body = frame[5 + header_len:]
return frame[:1], (json.loads(body) if body else None)
Send pack(None, b"K") about once a minute: the server sends it back, and
it keeps the device Online on the devices page (a device counts as
online for 2 minutes after its last call, connection or keepalive).
Messages¶
You send |
The server answers |
|---|---|
|
Nothing. Add |
|
|
|
|
|
Nothing. Add |
When another device of the account (or XPARO, for an xparo. key) writes
or deletes a key, you receive an update. A connection never gets its own
writes back (a PUT sync/<key> does reach the same device’s connection).
device is the writer’s device.id from GET me:
{"op": "update", "key": "xp.notes", "value": "hi", "ts": 1762140000.5, "updated_at": "...", "device": "..."}
{"op": "update", "key": "xp.notes", "value": null, "ts": 1762140100.0, "deleted": true}
A refused message answers {"op": "error", "error": ..., "key": k,
"message": "..."}, where error is bad_key, read_only,
too_large or quota (the limits above), bad_op, bad_json or
bad_frame. Answers carry no request ID, and an update can arrive
between a pull and its answer, so match answers by op and key.
A text frame holding just the JSON message is also accepted and answered as
text, which is handy for trying things in a WebSocket console. Updates and
the sign-in error always come as binary D frames.
From a web page¶
The device API is for apps (XP-shell, a native app, your own server), not
for JavaScript running in a browser. It sends no CORS headers, so a web
page on another site can’t read its answers, and a browser’s WebSocket
can’t send the Authorization header that /ws/sync needs. A device
token never expires, so it shouldn’t sit in a web page either. For a
browser kiosk, run a small backend beside it that keeps the token and
makes these calls, or build the screen as an XP-shell window plugin (see
Build a plugin).
Limits¶
Call |
Limit (then 429) |
|---|---|
|
20 codes per hour from one network: |
|
600 polls per 10 minutes from one network. |
|
10 attempts per 15 minutes for one login from one network, even with
the right password: |
|
5 sign-ups per hour from one network: |
Errors are {"error": "..."} with status 400 for a missing or invalid
field (for example device_id, or a device_name over 100 characters).