Skip to main content

Overview

The Limitless WebSocket API provides real-time market prices, orderbook updates, and position notifications. This guide covers connecting with Python using python-socketio with asyncio.

Prerequisites

1

Install dependencies

Install the required packages:
Use a virtual environment to isolate dependencies. Run python -m venv venv then source venv/bin/activate (Unix) or venv\Scripts\activate (Windows) before installing.

Authentication Modes

Connect without authentication to receive public market data only:
  • newPriceData (AMM market prices)
  • orderbookUpdate (CLOB orderbook)
  • system (system notifications)
No API key required. Use this for read-only market monitoring.
Never commit your API token id or secret to version control or expose them in client-side code. Use environment variables (e.g. LMTS_TOKEN_ID / LMTS_TOKEN_SECRET) and load them at runtime.
Cookie-based session authentication is deprecated. Authenticate the handshake with HMAC-signed headers (lmts-api-key, lmts-timestamp, lmts-signature) — see Authentication.

Connection Details

Authenticated connections sign the socket.io handshake with HMAC. The signed canonical message uses a fixed path and empty body, and the HMAC key is the base64-decoded secret:
ws_auth.py
See Authentication for how to generate the token id and secret.

Subscribing to Market Prices

Emit subscribe_market_prices with market identifiers. Subscriptions replace previous ones, so include all markets you want in a single call.
Subscriptions replace previous ones. If you want both AMM prices and CLOB orderbook, send both marketAddresses and marketSlugs together in a single subscribe_market_prices call.

Subscribing to Positions

Position updates require authentication. Emit subscribe_positions after connecting:

Handling Events

Register handlers for each event type. All handlers use namespace="/markets".

Event Payloads

newPriceData — AMM market price update:
positions — Position balance update (auth required):
system — System notification:

Complete Async Python Client

Usage Examples

Environment Variables

Auto-Reconnection

The client uses reconnection=True by default. On reconnect, call _resubscribe() in the connect handler to restore market and position subscriptions, since the server does not persist them across disconnects.
Store your API token id and secret securely. Rotate the token if exposure is suspected. Do not log or print the secret.