HTTP API
Every board has a small JSON API. Requests send form-encoded bodies
(application/x-www-form-urlencoded) and get JSON back.
Authentication
Once an admin password is set, every
endpoint needs it (HTTP Basic, user admin) except /stream.sdp,
/usbip.sh and /usbip.ps1:
curl -u admin:PASSWORD http://etherjax-XXXX.local/api/status
Scripts and curl work from anywhere. Browsers can call a board's API from
pages served by that board or by another board it has found on the network.
A browser POST from any other site is refused.
Endpoints
| Endpoint | Description |
|---|---|
GET /api/status | live state |
GET /api/config | saved settings |
POST /api/config | save settings and reboot (see below) |
POST /api/reboot | reboot |
POST /api/ota | body: a raw build/etherjax.bin. Installs it and reboots (see firmware updates) |
POST /api/password | password=… sets the admin password; password= removes it |
GET /api/auth | the credentials the calling page signed in with (same-origin only; the matrix uses it) |
GET /api/peers | this board and every other board found over mDNS: hostname, IP, role, name, stream |
GET /matrix | the routing matrix page |
Encoder
| Endpoint | Description |
|---|---|
GET /stream.sdp | the stream's SDP, for media players. No password. |
GET /api/trim | {trim_db, device_db, device_min_db, device_max_db, digital_db}: the input trim, how much of it the adapter's own gain takes (and its range; null without an adapter that has one), and the rest, applied digitally |
POST /api/trim | trim_db=-40…20. Applied at once, saved after 2 s. |
Decoder
| Endpoint | Description |
|---|---|
GET /api/streams | streams heard over SAP |
GET /api/route | the current group, port, source, link offset, media clock offset and detected stream channels |
POST /api/route | mcast=…&port=…, optionally source=, link_ms=, mclk_offset= and encoding=L16 or L24. Switches at once and saves. mcast= (empty) stops. source is the IP address of the sender to play; without it, the decoder takes the announced sender if only one announces that address, else the first sender it hears. mclk_offset and encoding default to the stream's announcement, else 0 and L24. |
GET /api/volume | {volume, volume_db, mute} |
POST /api/volume | volume=0…100 and/or mute=…. Applied at once, saved after 2 s. |
POST /api/volume_db | volume_db=-80…12 and/or mute=… |
POST /api/mute | mute=1, 0 or toggle |
Serial server
| Endpoint | Description |
|---|---|
GET /api/serial | the adapter, and each port's settings, clients and counters |
POST /api/serial | port=1…4 plus any of enabled, mode (raw or rfc2217), tcp_port, baud, data_bits, parity (none, odd, even, mark, space), stop_bits (1, 1.5, 2), label, allow. Applied at once and saved. |
USB/IP server
| Endpoint | Description |
|---|---|
GET /api/usbip | the device, the attached host, traffic and settings |
POST /api/usbip | enabled, allow. Applied at once and saved. detach=1 drops the attached host. |
GET /usbip.sh | the Linux host setup script. No password. |
GET /usbip.ps1 | the Windows host setup script. No password. |
See USB/IP server for using the scripts.
IR blaster
| Endpoint | Description |
|---|---|
GET /api/ir | the dongle, the clients, counters and settings, and last: the last code learned, as a sendir line (null if none) |
POST /api/ir | enabled, allow: applied at once and saved. send= queues a code: a whole sendir line, or GEM's form without sendir,1:1,. learn=1 learns codes for a minute, learn=0 stops. |
Both answer 409 in other roles. In the IR role, /api/status has the same
state under ir. The iTach API itself is on TCP port 4998: see
IR blaster.
Bluetooth remote
| Endpoint | Description |
|---|---|
GET /api/remote | Bluetooth's state, the paired remotes, the remotes found while pairing (program: a Sofabaton U3 that can be programmed), program (state: idle, running, done or failed, with percent, step, name and error), the controller connection, counters, the last button pressed, voice (listening, utterances, voice_lost), settings and the renamed buttons (map), and keys: the standard key names |
POST /api/remote | enabled, mode (tcp or rest), host, port, url, method (post or get), repeat, repeat_ms (50 to 1000), voice: applied at once and saved. pairing=1 lists remotes in pairing mode for two minutes, pairing=0 stops. pair=<address> pairs a listed remote, forget=<address> removes a paired one. program=<address>&name=<name> programs a listed Sofabaton U3 (one whose entry in found has program true) and pairs with it; name is 1 to 30 characters. map=<usage>&key=<name> names a button (map=0c:0223&key=activity_1); an empty key gives it its standard name back. test=<key> sends a key to the controller. |
Both answer 409 in other roles. In the Bluetooth remote role, /api/status
has the same state under remote. See
Bluetooth remote.
Wi-Fi
| Endpoint | Description |
|---|---|
GET /api/wifi | present (the board has Wi-Fi), the saved network ssid, connected, ip, rssi, the last error joining, and setup: whether the setup network is open, its name and address, and how many devices are on it, and the Wi-Fi chip's firmware: the version it runs (empty if it didn't say), the bundled version this firmware installs, and update (due, updating, failed, or empty) |
POST /api/wifi | ssid=…&password=… saves the network and joins it at once. ssid= (empty) forgets it. The password is never sent back. |
GET /api/wifi/scan | the networks in range, strongest first: ssid, rssi, open. Takes a few seconds. |
GET /setup | the Wi-Fi setup page |
/api/status has the same state under wifi. On a board without Wi-Fi,
present is false and the scan answers 409.
Saving settings
POST /api/config takes the same fields as the Settings form: role
(encoder, decoder, serial, usbip, ir or remote), hostname, name, mcast,
port, channels, link_ms, ext_link_ms, ptp_priority1, sap, static_ip, ip,
mask, gw and audio (usb, or builtin for the
built-in speaker or microphone). The board
checks them, saves them and reboots. GET /api/config also has
builtin_audio: whether the board has built-in audio at all, and
bluetooth: whether it can take the Bluetooth remote role.
In /api/status, usb describes the encoder's or decoder's audio device,
whichever it is: builtin is true for the built-in speaker or microphone,
and clock_ppm is then the correction its clock runs at to follow PTP.
sap and static_ip are checkboxes: present means on, absent means off. To
change one setting, read GET /api/config and send it back whole.
Examples
# Switch a decoder to another stream
curl -u admin:PASSWORD -d 'mcast=239.200.171.18&port=5004&source=192.0.2.10' http://etherjax-ab12.local/api/route
# Set a decoder's volume to -6 dB
curl -u admin:PASSWORD -d 'volume_db=-6' http://etherjax-ab12.local/api/volume_db
# Send an IR code from an IR blaster
curl -u admin:PASSWORD --data-urlencode 'send=sendir,1:1,1,38000,1,1,172,172,21,64,21,1673' http://etherjax-ab12.local/api/ir
# Update firmware
curl -u admin:PASSWORD --data-binary @build/etherjax.bin http://etherjax-ab12.local/api/ota