LN Markets Stream API is live

Push, don't poll.

LN Markets Stream API is live

We just shipped a WebSocket API for LN Markets.

One connection, JSON-RPC 2.0, public market data and private account events on the same socket.

If you've been keeping a bot or dashboard fresh by polling the REST endpoints on a loop, you can stop now.

Push, don't poll.

What's in it

Twelve topics at launch: tickers, trades, OHLC candles, order book, deposits, withdrawals, position updates, and the rest. Eight methods covering subscribe / unsubscribe / authenticate and friends.

Same API key, secret and passphrase you already use for REST v3 - scopes carry over unchanged.

Endpoint: wss://stream.lnmarkets.com/v1

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)
  }
})

That subscribes you to the BTC/USD ticker.

Public topics work straight away.

For private ones (your positions, your fills, your deposits) call authenticate first. Signing recipe is in the docs.

SDKs

Don't feel like writing WebSocket plumbing yourself? Two SDKs already handle it:

Docs

Full reference (connection, auth, every method, every topic, every error code) lives at docs.lnmarkets.com/en/stream.

Please build something with it and tell us if something is missing!

Subscribe to LN Markets Blog

Get the latest posts delivered right to your inbox.

Subscribe