LN Markets Stream API
Realtime market data and private events over JSON-RPC 2.0 WebSocket
Realtime market data and private events over JSON-RPC 2.0 WebSocket
Version 1.0.0 — JSON-RPC 2.0 over a single persistent WebSocket. Use it to push trades, fund deposits, OHLC candles, and ticker updates to your client without polling.
Why Stream
- Push-based — receive market and account events the moment they happen.
- Single connection — multiplex public market data and private account events on one socket.
- JSON-RPC 2.0 — request/response, notifications, and errors follow a well-known spec.
- Permission-scoped — private topics honor the same scopes (
account:*,futures:*) as the REST API.
At a glance
- Endpoint
wss://stream.lnmarkets.com/v1 - Protocol WebSocket, JSON-RPC 2.0 messages
- Methods 8 (
subscribe,unsubscribe,authenticate, …) - Topics 12 (public market data + private account events)
- Auth API key + HMAC-SHA256 signature, identical to REST v3
Sections
- Connection — endpoint, limits, message envelope, heartbeat
- Authentication — sign your requests with an API key, secret, and passphrase
- Methods — full request/response reference for every JSON-RPC method
- Subscriptions — payload reference for every topic
Quick start
const ws = new WebSocket('wss://stream.lnmarkets.com/v1')
ws.addEventListener('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'subscribe',
params: { topics: ['futures/inverse/btc_usd/ticker'] },
}))
})
ws.addEventListener('message', (event) => {
const message = JSON.parse(event.data)
if (message.method === 'subscription') {
console.log(message.params.topic, message.params.data)
}
})Authenticated topics need an extra step — call authenticate before subscribe. See Authentication for the signing recipe.
Client libraries
- TypeScript / JavaScript —
@ln-markets/sdk(npm) - Python —
lnmarkets_sdk