nils-api-websocket-0.4.2 is not a library.
api-websocket
Overview
api-websocket executes deterministic WebSocket request files, writes optional call history, and generates Markdown reports.
It follows the same CLI conventions as api-rest, api-gql, and api-grpc.
Transport decision
- Selected backend: native Rust transport via
tungsteniteinapi-testing-core::websocket::runner. - Rejected backend: external adapter (
websocat-style shell-out) for MVP. - Revisit when:
- streaming/session orchestration needs async multiplexing beyond scripted send/receive steps;
- platform/runtime behavior diverges in CI and a swap behind the transport boundary is justified.
Runtime dependency policy
- Runtime dependency policy: no extra external binary is required for WebSocket execution.
api-websocketuses the embedded Rust transport path only.
Setup and naming conventions
Canonical setup directory: setup/websocket.
Endpoint variables
WS_URL_<PROFILE>insetup/websocket/endpoints.env(optional local override:endpoints.local.env).WS_ENV_DEFAULTcan set a default endpoint profile.WS_URLcan force an explicit URL.
Token variables
WS_TOKEN_<PROFILE>insetup/websocket/tokens.env(optional local override:tokens.local.env).WS_TOKEN_NAMEchooses a token profile.- If no profile is selected, fallback envs are
ACCESS_TOKENthenSERVICE_TOKEN.
URL/token precedence
URL precedence (call):
--url--env(profile lookup viaWS_URL_<PROFILE>, or literalws:///wss://)WS_URLWS_ENV_DEFAULTprofile- default
ws://127.0.0.1:9001/ws
Token precedence (call):
--tokenWS_TOKEN_NAME- profile lookup via
WS_TOKEN_<PROFILE> - env fallback
ACCESS_TOKENthenSERVICE_TOKEN
History
- Default history file:
<setup_dir>/.ws_history - Override:
WS_HISTORY_FILE - Controls:
WS_HISTORY_ENABLED,WS_HISTORY_MAX_MB,WS_HISTORY_ROTATE_COUNT,WS_HISTORY_LOG_URL_ENABLED
Request schema (v1)
See docs/specs/websocket-request-schema-v1.md.
Quick example:
Commands
call(default): execute request and print the last received message.history: print last entry or tail entries.report: generate Markdown report from--runor--response.report-from-cmd: reconstructreportargs from a savedcallsnippet.
JSON contract (--format json)
Supported for call and history.
Success envelope:
Failure envelope:
Full CLI/JSON contract: docs/specs/websocket-cli-contract-v1.md
Quickstart
|