The REST + WebSocket surface for LiberX L1.
Auth is SIWE-based; trading endpoints additionally require an Ed25519 signature from your scoped session key. Streams are MessagePack over WebSocket so a 3k-level orderbook fits in ~8 KB of wire.
Base URL
https://api.liberx.xyz/v1
Regional CNAME, anycast at mainnet.
Latency target
1–5 ms
Preconfirm ack from nearest gateway.
Auth
SIWE bearer + session-key signature
Read-only endpoints need only bearer.
Quickstart
# 1. Get a bearer token
curl -X POST https://api.liberx.xyz/v1/auth/siwe \
-H "Content-Type: application/json" \
-d @siwe.json
# → { "token": "eyJh…", "expiresAt": 1766... }
# 2. Place an order
curl -X POST https://api.liberx.xyz/v1/orders \
-H "Authorization: Bearer $TOKEN" \
-H "X-Liberx-Sig: $(liberx-sign payload.json)" \
-d @payload.json
# → { "ackNonce": "...", "filledSize": 0.0149, "avgFillPrice": 67345.2, ... }Subscribe to a stream
const ws = new WebSocket('wss://api.liberx.xyz/ws/v1');
ws.binaryType = 'arraybuffer';
ws.onopen = () => ws.send(JSON.stringify({
op: 'subscribe',
streams: ['book.BTCUSD', 'trades.BTCUSD', 'preconfirms'],
}));
ws.onmessage = (ev) => {
// Frames are MessagePack-encoded:
// import { decode } from '@msgpack/msgpack';
// const frame = decode(new Uint8Array(ev.data));
};Popular endpoints
POST/v1/auth/siwe
Exchange a SIWE signature for a bearer token.
POST/v1/auth/rotate
Rotate the active session key.
GET/v1/markets
List active perpetual markets.
GET/v1/markets/{symbol}/book
Orderbook snapshot (top N levels).
GET/v1/markets/{symbol}/trades
Recent trades tape.
GET/v1/markets/{symbol}/candles
OHLCV history.
POST/v1/orders
Place a perpetual order.
POST/v1/orders/{id}/cancel
Cancel a resting order.