Skip to content

REST API

HTTP API for monitoring and controlling Shadowquic.

The restful-api feature is enabled by default. Build with cargo build --release --features restful-api to include it explicitly. Configuring this section without the feature produces a configuration error. Omit restful-api to leave the HTTP listener disabled.

restful-api:
  tag: restful-api
  bind-addr: 127.0.0.1:9090
  secret: choose-a-secret
  ui-path: ./ui

ui-path enables local dashboard serving at /. If index.html is missing, startup downloads Squirrelboard v0.1.2's standalone index.html. Existing files are reused. Downloads follow normal routing with tag as the inbound tag. Omit ui-path to disable dashboard serving and downloading. Dashboard files are public; API endpoints still require the configured bearer token.

A nonempty secret requires Authorization: Bearer <secret> on API requests. Omit secret or set it to an empty string to disable authentication.

curl -H 'Authorization: Bearer choose-a-secret' http://127.0.0.1:9090/api/v1/traffic

CORS allows all origins, with unauthenticated browser preflights for GET, POST, and PUT using Authorization and Content-Type request headers.

API responses use JSON with snake_case fields, except heap profile downloads. Timestamps use UTC RFC 3339; durations use milliseconds and byte counters use bytes. Unavailable optional fields are null. Collections are sorted by tag or session ID.

Method Path Response
GET /api/v1/outbounds {"outbounds": [...]}: tags and cached connection/probe quality
GET /api/v1/connections {"connections": [...]}: active TCP sessions and UDP associations
GET /api/v1/traffic {"inbounds": [...]}: summed user traffic and active session counts per inbound
GET /api/v1/tokio_metric Tokio runtime worker count, alive task count, and global queue depth
GET /api/v1/memory jemalloc allocator statistics; requires jemalloc
POST /api/v1/memory/profile Download a jemalloc heap profile; requires mem-profile
POST /api/v1/outbounds/{tag}/probe Probe the selected outbound with an HTTP GET
GET /api/v1/outbounds/{tag}/selection Selector's current member and allowed outbound tags
PUT /api/v1/outbounds/{tag}/selection Set a selector's member with {"selected":"outbound-tag"}

Fields

tag

  • Type: string
  • Required: no
  • Default: restful-api

Inbound tag for dashboard downloads, available to routing scripts.

bind-addr

  • Type: SocketAddr
  • Required: yes

HTTP listener address. Wildcard addresses such as 0.0.0.0:9090 and [::]:9090 are allowed. A bind failure prevents manager startup.

secret

  • Type: string (optional)
  • Required: no

Require Authorization: Bearer <secret> on API requests when nonempty, except on CORS preflights. Dashboard files remain public. Omit this field or set it to an empty string to disable authentication.

ui-path

  • Type: path (optional)
  • Required: no

Serve the dashboard from this directory. If index.html is missing, download ui-download-url as index.html on startup. Omit to disable the UI.

ui-download-url

  • Type: string
  • Required: no
  • Default: https://github.com/spongebob888/squirrelboard/releases/download/v0.1.5/index.html

Standalone dashboard HTML URL. Used only when ui-path is configured and index.html is missing. Downloads follow redirects through normal routing.