WebSocket Streaming

Subscribe to real-time quote updates via a persistent WebSocket connection.

Connection

wss://api.waretto.com/v1/stream?apiKey=wde_YOUR_KEY&symbols=BTC/USD,ETH/USD
ParamRequiredDescription
apiKeyYesYour API key
symbolsYesComma-separated (e.g. BTC/USD,ETH/USD)

Server Messages

snapshot

Sent immediately after connection for each subscribed symbol.

{
  "type": "snapshot",
  "symbol": "BTC/USD",
  "data": { "price": 67432.80, "bid": 67432.10, "ask": 67433.50, ... }
}
subscribed

Confirmation after initial connect or subscribe action.

{ "type": "subscribed", "symbols": ["BTC/USD", "ETH/USD"] }
quote

Real-time quote update.

{
  "type": "quote",
  "symbol": "BTC/USD",
  "data": { "price": 67435.20, "bid": 67434.90, "ask": 67435.50, ... }
}
pong

Response to a client ping.

{ "type": "pong" }

Client Messages

subscribe

Add more symbols.

{ "action": "subscribe", "symbols": ["SOL/USD", "AVAX/USD"] }
unsubscribe

Remove symbols.

{ "action": "unsubscribe", "symbols": ["SOL/USD"] }
ping

Keep alive. Server responds with pong.

{ "action": "ping" }

Full Example

PYTHON
import asyncio
import websockets
import json

async def stream():
    uri = "wss://api.waretto.com/v1/stream?apiKey=wde_YOUR_KEY&symbols=BTC/USD,ETH/USD"
    async with websockets.connect(uri) as ws:
        async for message in ws:
            data = json.loads(message)
            if data["type"] == "quote":
                print(f"{data['symbol']}: {data['data']['price']}")

asyncio.run(stream())
CONNECTION LIMITS: Free: 1 connection. Starter: 3. Pro: 10. Enterprise: 50. Excess connections rejected with code 4003.