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, every manifest.json field, 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 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

GET me

The account and this device.

POST auth/logout

Signs this device out (its token stops working). Other devices stay signed in.

GET sync

The keys this account has synced (key, ts, size, updated_at), without values.

GET sync/<key>

One synced value (404 if there is none).

PUT sync/<key>

Stores {"value": ..., "ts": ...}. If the server already has a newer ts, it answers 409 {"status": "stale", ...} with the newer value. Too big or over quota: 413.

DELETE sync/<key>

Deletes it: {"deleted": true} (false if there was no such key).

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 with xparo. 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".

  • ts is the writer’s clock as Unix time in seconds (milliseconds are recognised). It is optional (the server’s time is used), and a ts more 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: D (data) or K (keepalive).

4

The header’s length, a big-endian unsigned integer.

header length

The header, JSON in UTF-8. Send {}; the server always sends {}.

the rest

The body. In a D frame it is one JSON message in UTF-8.

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

{"op": "push", "key": k, "value": v, "ts": t}

Nothing. Add "ack": true to get {"op": "ack", "key": k, "ts": t}. If the server already has a newer ts: {"op": "stale", ...} with the newer value.

{"op": "pull", "key": k}

{"op": "value", "key": k, "value": v, "ts": t, "updated_at": ..., "device": ...}, or "value": null, "missing": true.

{"op": "list"}

{"op": "list", "keys": [{"key": ..., "ts": ..., "size": ...}]}

{"op": "delete", "key": k}

Nothing. Add "ack": true to get {"op": "ack", "key": k, "deleted": true}.

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)

pair/start

20 codes per hour from one network: "Too many pairing requests. Please try again later."

pair/poll

600 polls per 10 minutes from one network.

auth/login

10 attempts per 15 minutes for one login from one network, even with the right password: "Too many sign-in attempts. Please wait a few minutes."

auth/signup

5 sign-ups per hour from one network: "Too many sign-ups from this network. Please try again later."

Errors are {"error": "..."} with status 400 for a missing or invalid field (for example device_id, or a device_name over 100 characters).