stellarlinkd serves a REST API and a set of WebSocket streams on port 8080. Everything the CLI
and the web console do goes through it, so anything they can do, a script can do.
Base URL and versioning#
http://<unit>:8080/api/v1/... REST
ws://<unit>:8080/ws/... WebSocket streamsEvery response carries an x-api-version: v1 header. The OpenAPI 3 document is served at
GET /api/v1/openapi.json, with an interactive Swagger UI at /docs. The
API Reference section of this site is generated from the same document.
curl -s http://<unit>:8080/api/v1/health
curl -s http://<unit>:8080/api/v1/version
curl -s http://<unit>:8080/api/v1/system/capabilities | jq '.symbol_rates'Errors#
Errors are JSON with a machine-readable code and a human message:
{"code": "conflict", "message": "a scenario is already running: ..."}| HTTP | code | Typical cause |
|---|---|---|
| 400 | bad_request | Unparseable YAML, a bad duration, a framing that cannot hold alignment |
| 404 | not_found | Unknown profile, scenario or run; no datapath available |
| 409 | conflict | A scenario is already running; the chain cannot be conditioned; the datapath is held by someone else; a scenario exists and overwrite was not given |
| 422 | validation_failed | Semantic validation failed |
| 501 | not_implemented | The resource is not configured on this unit (for example no scenarios_dir) |
| 500 | internal | Anything else; the message says what |
| 504 | — | A capture or loopback did not sustain the requested blocks in time |
Refusals are written to be actionable: a 409 from a transmit or a scenario launch names the first unmet prerequisite and the command that clears it.
Authentication and CORS#
Authentication is off by default. To turn it on:
-
Generate a secret and keep it in a private file, for example
openssl rand -hex 32 > secret.txt. -
Put the same value in the unit's configuration:
[api] auth_required = trueand[api] auth_secret = "<the secret>". The unit refuses to start if the secret is empty, shorter than 32 characters, or an example value such aschange-me. -
Create a token on your machine (nothing is sent to the unit):
Shell stellarlinkctl auth token --secret-file secret.txt --role operator --hours 12The role is
operator,adminormaintenance. -
Pass it with
--tokenorSTELLARLINK_TOKEN(stellarlinkctl), or asAuthorization: Bearer <token>(any HTTP client).
What is protected: every request that changes something (POST, PUT, DELETE), and the
/ws/tx transmit stream, which also accepts the token as ?token=<token> since a browser cannot
set headers on a WebSocket. Reads (GET) and the other WebSocket streams stay open, so monitoring
needs no token. Without a token a protected request gets 401; with a token whose role is not
recognised, 403.
Web console. When the unit requires a token, the sidebar shows API token: paste a token there and the console sends it with every change. It is kept in your browser only. Without one, the console can read but changes are refused with a message saying so.
ZeroMQ link. The link service has no authentication of its own. With authentication on, its
transmit socket (port 5555) therefore listens on the unit itself only (127.0.0.1), so no
other host can transmit through it; the received-frames and telemetry streams (5556, 5557) are
read-only and stay reachable. To accept frames from the network anyway, set
[link] tx_unauthenticated = true — only on a network you control. The unit says which applies
in its log at startup.
CORS origins are set by [api] cors_origins. The shipped configuration allows every origin
(["*"]), so the web console can run from any host.
Request bodies are limited to [api] max_body_bytes (20 MiB by default). Payloads sent as hex
double in size; for large transfers use the /ws/tx stream.
See Daemon Configuration for the configuration file.
Long-running work#
Some requests start work that outlives them:
| Request | Returns | Follow with |
|---|---|---|
POST /api/v1/scenarios/{name}/run | 202, the run id | GET /api/v1/scenario-runs/{run_id}, ws://…/ws/scenario-runs/{run_id}, then GET /api/v1/reports/{run_id} |
POST /api/v1/campaigns/{name}/run | the execution id | GET /api/v1/campaign-runs/{id}, ws://…/ws/campaign-runs/{id} |
| Any of the above | — | GET /api/v1/jobs, GET /api/v1/jobs/{job_id} |
Only one scenario runs at a time. A second launch is refused with 409 naming the run in progress; it is never queued.
WebSocket streams#
| Stream | Content |
|---|---|
/ws/metrics | Telemetry snapshots (metrics_bulk messages) at the telemetry cadence |
/ws/events | Runtime events (profile_applied, lock lost, …) |
/ws/monitor/fft?channel=rx&interval_ms=200 | The spectrum, pushed |
/ws/scenario-runs/{run_id} | A scenario run in flight: events, samples and assertion verdicts as they happen |
/ws/campaign-runs/{id} | A campaign execution as it advances |
/ws/tx | A persistent feed for pushing packets into the modem (see Datapath and Transmission) |
/ws/frames?framing=slot&slot_len=256&payload=true | The receive stream in real time (see Datapath and Transmission) |
WebSocket streams are not described in the OpenAPI document.
Routes not listed in the OpenAPI document#
The following routes are served and used by the CLI and the web console, but do not appear in the API Reference:
| Route | Purpose | Documented in |
|---|---|---|
GET /api/v1/radio/rf | The radio's sample rate, signal path and readiness | Chain Conditioning |
POST /api/v1/radio/rf/tune | Set the radio's sample rate and align its digital interface at that rate ({"rate_sps": 8000000}) | Chain Conditioning |
POST /api/v1/radio/rf/mode/rf | Route through the AD9361's internal digital loopback | Chain Conditioning |
POST /api/v1/radio/rf/mode/pl | Route through the internal digital loopback | Chain Conditioning |
POST /api/v1/radio/nco-offset | Set the RX/TX NCO offsets ({"rx_hz": …, "tx_hz": …}) | RF Fundamentals |
PUT /api/v1/monitor/fft/{channel} | Switch spectrum analysis on or off for rx or tx | Telemetry and Metrics |
POST /api/v1/scenarios | Create or replace a scenario from YAML | Scenarios |
POST /api/v1/radio/rf/mode/air, /radio/rf/calibrate and /radio/rf/kill are in the document.
Talking to the API from a script#
import requests
UNIT = "http://<unit>:8080/api/v1"
print(requests.get(f"{UNIT}/version").json())
r = requests.post(f"{UNIT}/chain/condition",
json={"target": "pl", "profile": "pl_loopback"})
r.raise_for_status()
run = requests.post(f"{UNIT}/scenarios/hc_qpsk/run").json()
print(run)The Python example client wraps the REST API and the ZeroMQ link service; see Example Clients.