API v1 · operational rev 2026.06.11 API keys →
Getting Started

Quickstart

Go from an API key to a live, AI-supervised strategy in under five minutes. This guide walks through authenticating against the StochLab API, deploying a strategy to the colocated execution engine, and streaming real-time Sonar AI signals over WebSocket. Every request is signed, idempotent, and routed through our colocated matching gateway at a median 38 µs round trip.

BASE https://api.stochlab.io/v1 REST · WSS SDK 4.3.1

00 Before you begin

You'll need a StochLab account on the Quant tier or above, plus an active API key. Keys are scoped per-environment — never ship a live-trading key to the browser. Generate and rotate keys from the dashboard.

  • A secret key, formatted sk_live_… (or sk_test_… for the paper-trading sandbox).
  • The Python (pip install stochlab) or Node (npm i @stochlab/sdk) SDK, or any HTTP client.
  • A funded sub-account — the sandbox seeds $1,000,000 in paper capital automatically.

01 Authenticate

Authentication uses a bearer token passed in the Authorization header. Pair it with an X-SL-Account header to target a specific sub-account, and an idempotency key on every write so retried requests never double-fill. Pick your language below — all three snippets hit the same signed endpoint.

authenticate.sh bash
# Verify your key and fetch the authenticated account
curl https://api.stochlab.io/v1/account \
  -H "Authorization: Bearer sk_live_3aF9k2Qx7Lp0wRtZ8nVbY" \
  -H "X-SL-Account: acct_8Hq2Rd" \
  -H "Accept: application/json"
!Keep secret keys server-side

Live keys can move capital. Store them in a secrets manager, scope them to the minimum permissions (read, trade, stream), and rotate on a 90-day cadence from the dashboard.

02 Deploy a strategy

Strategies are immutable, versioned bundles of entry/exit logic, risk limits, and the venues they're allowed to trade. Deploying compiles your config, runs a 12-month walk-forward smoke-backtest, and — if it clears your guardrails — arms the strategy on the live engine. Compose the logic visually in the Strategy Builder or POST it directly.

Request

POST  /v1/strategies/deploy json
{
  "name": "momentum-breakout-eth",
  "pattern": "bull_flag",
  "universe": ["ETH-PERP", "SOL-PERP"],
  "timeframe": "5m",
  "capital_usd": 250000,
  "sonar": {
    "min_confidence": 0.72,
    "veto_on_regime_flip": true
  },
  "risk": {
    "max_drawdown_pct": 8.0,
    "max_leverage": 3,
    "per_trade_bps": 35
  },
  "execution": {
    "venue": "colo-ny4",
    "order_type": "post_only",
    "slippage_bps_cap": 2
  }
}

Response — 201 Created

201 · application/json json
{
  "id": "strat_Qf7m2Kd9Lx",
  "name": "momentum-breakout-eth",
  "status": "armed",
  "version": 1,
  "smoke_backtest": {
    "sharpe": 2.41,
    "max_drawdown_pct": 6.3,
    "win_rate": 0.586,
    "trades": 1284
  },
  "sonar_attached": true,
  "created_at": "2026-06-14T08:31:07Z",
  "dashboard_url": "https://app.stochlab.io/s/strat_Qf7m2Kd9Lx"
}

Body parameters

FieldTypeDescription
name req string Unique, URL-safe label for the strategy within your account. 3–48 chars.
pattern req enum Setup template — bull_flag, v_recovery, cup_handle, inv_hns and 10 more.
universe req string[] Instruments the strategy may trade. Perps, spot, or dated futures.
capital_usd req number Notional capital allocated. Must not exceed sub-account buying power.
sonar.min_confidence float Suppress entries below this Sonar AI confidence (0–1). Default 0.65.
risk.max_drawdown_pct float Hard kill-switch. Strategy disarms automatically when breached.
execution.venue enum Colocated gateway — colo-ny4, colo-ld4, colo-tk3.

03 Stream Sonar AI signals

Sonar AI publishes a continuous feed of predicted price paths, regime classifications, and order-flow imbalance over a single multiplexed WebSocket. Each signal carries a confidence score and a forward horizon — the same strand that rides above the realized price in your equity curves. Authenticate the socket with the same bearer token, then subscribe to the channels you care about.

Connect & subscribe

WSS  stream.stochlab.io javascript
const ws = new WebSocket("wss://stream.stochlab.io/v1/sonar");

ws.onopen = () => {
  ws.send(JSON.stringify({
    op: "auth",
    token: "sk_live_3aF9k2Qx7Lp0wRtZ8nVbY",
  }));
  ws.send(JSON.stringify({
    op: "subscribe",
    channels: ["sonar.signal", "sonar.orderflow"],
    symbols: ["ETH-PERP"],
  }));
};

ws.onmessage = (e) => {
  const msg = JSON.parse(e.data);
  if (msg.channel === "sonar.signal") route(msg);
};

Sample signal frame

← sonar.signal json
{
  "channel": "sonar.signal",
  "symbol": "ETH-PERP",
  "ts": "2026-06-14T08:42:19.118Z",
  "signal": "long",
  "confidence": 0.814,
  "horizon_ms": 90000,
  "predicted_move_bps": 47,
  "regime": "trending_up",
  "orderflow_imbalance": 0.63,
  "model": "sonar-v4.3-perp",
  "latency_us": 38
}

Pipe the frame straight into a deployed strategy by matching on confidence and regime, or react in your own process. Frames are delivered at-least-once and stamped with a monotonic ts; de-duplicate on ts + symbol if you fan out across workers.

04 Core endpoints

The most-used routes against https://api.stochlab.io/v1. Every endpoint returns JSON, supports cursor pagination, and is rate-limited per the table in the next section. Full reference, including error codes and webhook payloads, lives in the API section.

MethodEndpointDescription
GET /account Equity, buying power, margin and open-position summary for the account.
POST /strategies/deploy Compile, smoke-backtest and arm a strategy on the live execution engine.
GET /strategies/{id} Fetch live status, P&L, Sharpe and current positions for one strategy.
POST /orders Submit a manual order with idempotency key, TIF and slippage cap.
POST /backtests Run a walk-forward backtest over a date range; returns a job you can poll.
DEL /strategies/{id}/disarm Immediately flatten positions and disarm the strategy. Irreversible.

05 Rate limits & latency

Limits are applied per API key on a sliding window. WebSocket frames are exempt from the REST budget. Exceeding a limit returns 429 with a Retry-After header; the SDKs back off and retry automatically.

iDefault limits — Quant tier

Need more headroom or a dedicated colocated rack? The Institutional plan lifts every ceiling below and adds burst capacity, priority order routing and a 99.99% uptime SLA.

0
REST requests / min
0 µs
Median colocated routing
0%
Engine uptime, 90-day
0
WSS subscriptions / socket
0
Concurrent sockets / key
0 bps
Max routed slippage