WatchCrypto API Docs

REST and WebSocket APIs for market data and alerts. Backend is built on Axum (Rust).

Base URL/api/v1
WebSocket/ws
AuthAlerts and notifications endpoints require Authorization: Bearer <supabase_jwt>.

REST API

GET /api/v1/exchanges

List supported exchanges and their current connection status.

GET /api/v1/exchange-status

Per-stream connection status for each exchange.

{
  "exchange": "binance",
  "status": "Connected",
  "streams": [
    {
      "stream": "trades",
      "status": "Connected",
      "last_connected": 1700000000000,
      "last_disconnected": 1699990000000,
      "reconnects": 2
    }
  ]
}
GET /api/v1/klines

Fetch historical candlesticks.

Query params:
- exchange (default: binance)
- symbol (default: BTC/USDT)
- interval (default: 1m)
- limit (default: 1000, max: 2000)
- endTime (optional, ms since epoch)
GET /api/v1/depth

Order book snapshot (top levels).

Query params:
- exchange (default: binance)
- symbol (default: BTC/USDT)
GET /api/v1/trades

Recent trades for a symbol.

Query params:
- exchange (default: binance)
- symbol (default: BTC/USDT)
- limit (default: 1000, max: 2000)
GET /api/v1/tickers

Watchlist tickers (price, 24h change, high/low, volume).

WebSocket API

Send JSON messages with op and channel to subscribe or unsubscribe.

{
  "op": "subscribe",
  "channel": "klines",
  "exchange": "binance",
  "symbol": "BTC/USDT",
  "interval": "1m"
}
{
  "op": "subscribe",
  "channel": "ticker",
  "exchange": "*",
  "symbol": "*"
}

Supported channels: klines, depth, trades, ticker. Ticker supports wildcard subscription with *.

If the server drops messages, it can send {"type":"resync","missed":N}.

Alerts API

GET /api/alerts

List alerts for the authenticated user.

POST /api/alerts

Create a new alert.

{
  "symbol": "BTC/USDT",
  "exchange": "binance",
  "condition": "above",
  "target_price": 50000
}
PATCH /api/alerts/:id

Update an alert (partial).

{
  "enabled": true,
  "condition": "below",
  "target_price": 42000
}
DELETE /api/alerts/:id

Delete an alert. Returns 204 No Content on success.

Notifications API

GET /api/notifications/preferences

Get notification preferences for the authenticated user.

PUT /api/notifications/preferences

Upsert notification preferences.

{
  "telegram_chat_id": "123456789",
  "telegram_enabled": true,
  "email_enabled": false
}
POST /api/notifications/test

Send a test notification (Telegram must be configured).

POST /api/notifications/telegram/link

Generate a Telegram linking code.