> ## Documentation Index
> Fetch the complete documentation index at: https://docs.altnautica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API

> HTTP API on port 8080, served by the native Rust front with a residual FastAPI behind it.

# REST API

Port 8080 is owned by the native Rust front (`ados-control`, an axum server). It serves migrated routes directly and reverse-proxies the rest to a residual FastAPI on an internal Unix socket (`/run/ados/api-internal.sock`). From a client's point of view it is one HTTP API for status, telemetry, commands, configuration, video, pairing, and everything else the agent can do.

The API is the backbone that the CLI, TUI, and Mission Control all talk to.

The split between native and proxied routes moves over time as more routes migrate into the Rust front. Callers do not need to know which process answers a given route. A route that has not yet migrated is forwarded transparently to the FastAPI upstream; on a zero-Python build with no upstream present, an un-migrated route returns `501` rather than `404`.

## Base URL

```
http://<drone-ip>:8080
```

On the drone itself: `http://localhost:8080`

## Authentication

Most endpoints require the `X-ADOS-Key` header. The key is generated during pairing and stored at `/etc/ados/pairing.json`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl http://localhost:8080/api/status \
  -H "X-ADOS-Key: sk_live_your_key_here"
```

A few endpoints are exempt from auth (like `/api/pairing/info`) so that unpaired agents can still be discovered and paired.

## Route domains

The API is organized by domain. The "Served by" column shows where a domain currently lives: the Rust front, the residual FastAPI (proxied through the front), or a mix while migration is in progress.

| Domain          | Prefix                               | Served by         | Purpose                                                                     |
| --------------- | ------------------------------------ | ----------------- | --------------------------------------------------------------------------- |
| Status          | `/api/status`, `/api/status/full`    | Rust front        | Agent status, board, FC, health                                             |
| Configuration   | `/api/config`                        | FastAPI (proxied) | Read/write configuration                                                    |
| Commands        | `/api/command`, `/api/commands`      | Rust front        | Send MAVLink commands and list supported commands                           |
| Telemetry       | `/api/telemetry`                     | Rust front        | Cached telemetry snapshot                                                   |
| Parameters      | `/api/params`, `/api/params/{name}`  | Rust front        | FC parameter reads and writes through the cache                             |
| Video           | `/api/video`                         | Mixed             | Pipeline config, snapshot, recording (live device enumeration stays Python) |
| WFB-ng          | `/api/wfb`                           | Rust front        | Link stats, channel, pairing                                                |
| MAVLink signing | `/api/mavlink/signing`               | Rust front        | MAVLink2 signing capability and FC enrollment                               |
| Pairing         | `/api/pairing`                       | Mixed             | Pair, unpair, info, code                                                    |
| Plugins         | `/api/plugins`                       | FastAPI (proxied) | Plugin lifecycle, install, list, perms                                      |
| Services        | `/api/services`                      | Rust front        | Systemd service control                                                     |
| System          | `/api/system`, `/api/v1/diagnostics` | Rust front        | Reboot, shutdown, diagnostics, resource reads                               |
| Fleet           | `/api/fleet`                         | Rust front        | Fleet enrollment and peers                                                  |
| Peripherals     | `/api/peripherals`                   | FastAPI (proxied) | USB devices, sensors                                                        |
| Vision          | `/api/vision`, `/api/vision/models`  | FastAPI (proxied) | Vision state, detections, model registry                                    |
| Logs            | `/api/logs`, `/api/observability`    | FastAPI (proxied) | Log retrieval (see also the `ados-logd` query API)                          |
| Network         | `/api/v1/network`                    | Rust front        | MAC pinning, WiFi client                                                    |
| Ground station  | `/api/v1/ground-station`             | Rust front        | Ground-station status, network, PIC, mesh, UI, recording                    |
| WHEP            | `/whep`                              | FastAPI (proxied) | WebRTC video playback signaling                                             |
| Setup           | `/api/setup`, `/setup`               | FastAPI (proxied) | First-boot setup wizard webapp                                              |

## Common endpoints

### Status

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Full agent status
curl http://localhost:8080/api/status \
  -H "X-ADOS-Key: $KEY"
```

Response:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "version": "0.89.2",
  "uptime_seconds": 3847,
  "board": {
    "name": "Radxa ROCK 5C Lite (RK3582)",
    "tier": 4,
    "soc": "RK3582"
  },
  "fc_connected": true,
  "fc_port": "/dev/ttyS0",
  "fc_baud": 921600,
  "health": {
    "cpu_percent": 12.3,
    "memory_percent": 34.2,
    "disk_percent": 41.8,
    "temperature": 52.3
  }
}
```

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Consolidated full status (single request, replaces 4 separate calls)
curl http://localhost:8080/api/status/full \
  -H "X-ADOS-Key: $KEY"
```

### Configuration

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Read full config
curl http://localhost:8080/api/config \
  -H "X-ADOS-Key: $KEY"

# Set a value
curl -X PUT http://localhost:8080/api/config \
  -H "X-ADOS-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{"key": "mavlink.baud_rate", "value": "115200"}'
```

### Video

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Video pipeline status
curl http://localhost:8080/api/video \
  -H "X-ADOS-Key: $KEY"

# Capture snapshot
curl -X POST http://localhost:8080/api/video/snapshot \
  -H "X-ADOS-Key: $KEY"
```

### WFB-ng link

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl http://localhost:8080/api/wfb \
  -H "X-ADOS-Key: $KEY"
```

Response:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "state": "active",
  "rssi_dbm": -42,
  "snr_db": 28.5,
  "channel": 149,
  "packets_received": 184523,
  "packets_lost": 12,
  "fec_recovered": 8,
  "fec_failed": 0,
  "bitrate_kbps": 4200
}
```

### Parameters

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Read cached FC parameters
curl http://localhost:8080/api/params \
  -H "X-ADOS-Key: $KEY"

# Read a single parameter
curl http://localhost:8080/api/params/RC1_MIN \
  -H "X-ADOS-Key: $KEY"
```

### Pairing

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Check pairing status (no auth required)
curl http://localhost:8080/api/pairing/info

# Unpair
curl -X POST http://localhost:8080/api/pairing/unpair \
  -H "X-ADOS-Key: $KEY"
```

### Services

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# List all systemd services and their states
curl http://localhost:8080/api/services \
  -H "X-ADOS-Key: $KEY"
```

### Ground station

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Ground station status (only in ground-station profile)
curl http://localhost:8080/api/v1/ground-station/status \
  -H "X-ADOS-Key: $KEY"

# Network info
curl http://localhost:8080/api/v1/ground-station/network \
  -H "X-ADOS-Key: $KEY"

# PIC heartbeat
curl -X POST http://localhost:8080/api/v1/ground-station/pic/heartbeat \
  -H "X-ADOS-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{"client_id": "gcs-session-1"}'
```

## CORS

CORS is enabled by default with an allowlist, not a wildcard. The defaults cover the local Mission Control development origins (`localhost:4000`, `localhost:4001`). Add your own origins in config without dropping the defaults:

```yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
security:
  api:
    cors_enabled: true
    cors_origins_extra: ["https://command.altnautica.com"]
```

The effective allowlist is the union of the built-in defaults, `cors_origins`, and `cors_origins_extra`.

## OpenAPI docs

The residual FastAPI generates interactive API documentation, served through the front. When the agent is running with the Python API present, open:

* **Swagger UI:** `http://localhost:8080/docs`
* **ReDoc:** `http://localhost:8080/redoc`

These pages list the FastAPI endpoints with request/response schemas and a "Try it out" button. On a zero-Python build (where the residual API is not present), these paths are not available.

<Tip>
  The Swagger UI is a fast way to explore the proxied endpoints. It shows the available endpoints, required parameters, and response shapes, and you can send test requests directly from the browser.
</Tip>
