WebSocket API

Real-time cryptocurrency price streaming via WebSocket.

Stream real-time cryptocurrency price updates via WebSocket using Socket.IO. Available to Pro users only.

#Connection

Connect to the /api-ws namespace using Socket.IO:

javascript
import { io } from "socket.io-client";

const socket = io("https://chartinspect.com/api-ws", {
  auth: { apiKey: "YOUR_API_KEY" },
  transports: ["websocket"],
});

#Python Example

python
import socketio

sio = socketio.Client()
sio.connect(
    "https://chartinspect.com",
    namespaces=["/api-ws"],
    auth={"apiKey": "YOUR_API_KEY"},
    transports=["websocket"]
)

@sio.on("price-update", namespace="/api-ws")
def on_price(data):
    print(f"{data['symbol']}: ${data['price']}")

#Authentication

Pass your API key in the auth object during connection. The key must:

  • Be a valid, active API key (format: ci_live_xxx or ci_test_xxx)
  • Belong to a user with an active Pro subscription

#Events

#Receiving

EventDescriptionPayload
initial-pricesSent on connect with latest prices for all symbolsMarketUpdate[]
price-updateReal-time price update for a single symbolMarketUpdate

#Sending

EventDescriptionPayload
subscribeSubscribe to specific symbols{ symbols: string[] }
unsubscribeUnsubscribe from symbols{ symbols: string[] }

#MarketUpdate Format

json
{
  "symbol": "BTC",
  "price": 87250.50,
  "volume": 12500000000,
  "timestamp": 1775001600,
  "change": 1250.30,
  "changePercent": 1.45
}

#Supported Symbols

20 cryptocurrencies are available for real-time streaming:

BTC, ETH, LTC, XRP, BCH, ADA, DOT, LINK, BNB, DOGE, UNI, SOL, MATIC, AVAX, ATOM, XLM, ALGO, VET, ICP, FIL

#Limits

  • Maximum 2 concurrent connections per user
  • Requires Pro subscription

#Connection Example (Full)

javascript
import { io } from "socket.io-client";

const socket = io("https://chartinspect.com/api-ws", {
  auth: { apiKey: "YOUR_API_KEY" },
  transports: ["websocket"],
  reconnection: true,
  reconnectionDelay: 1000,
});

// Receive all current prices on connect
socket.on("initial-prices", (prices) =>; {
  console.log(`Received ${prices.length} initial prices`);
  prices.forEach((p) =>; console.log(`${p.symbol}: $${p.price}`));
});

// Subscribe to specific symbols only
socket.emit("subscribe", { symbols: ["BTC", "ETH", "SOL"] });

// Receive real-time updates
socket.on("price-update", (update) =>; {
  console.log(`${update.symbol}: $${update.price} (${update.changePercent >; 0 ? "+" : ""}${update.changePercent}%)`);
});

socket.on("connect_error", (err) =>; {
  console.error("Connection failed:", err.message);
});

#Error Handling

ErrorCause
Authentication failedInvalid or missing API key
Pro subscription requiredAPI key belongs to a free-tier user
Connection limit exceededMore than 2 active connections for this user
Was this page helpful?