Account data & positions
Balances, positions, orders, fills and transaction status for an account.
REST
# Public account snapshot: collateral, positions, sub-accounts
curl "https://mainnet.zklighter.elliot.ai/api/v1/account?by=index&value=123"Private endpoints such as accountActiveOrders, accountInactiveOrders, pnl and the history endpoints require an auth token:
const { authToken } = check(lighter.CreateAuthToken(Math.floor(Date.now() / 1000) + 3600, API_KEY_INDEX, ACCOUNT_INDEX));
const orders = await fetch(
`${BASE_URL}/api/v1/accountActiveOrders?account_index=${ACCOUNT_INDEX}&market_id=0`,
{ headers: { Authorization: authToken } },
).then(r => r.json());Check a submitted transaction with tx (status values are in Data Structures, Constants and Errors):
curl "https://mainnet.zklighter.elliot.ai/api/v1/tx?by=hash&value=<tx_hash>"Binary options
account returns binary options positions in bo_positions, separately from perps positions. The account_all and account_all_positions WebSocket channels also expose bo_positions; account_market uses bo_position. Realized PnL is available through portfolio_boPnl and is gross of fees. See Positions and settlement for position fields and payout records.
WebSocket (recommended)
Add auth to the subscribe message for private channels:
Which channel to use:
Positions, trades, funding across all markets
Open orders
Whether a transaction executed or was rejected
Collateral, leverage, margin usage
Liquidations, deleverages, announcements
Every account channel, with its auth requirement and payload, is in the WebSocket reference.
Recommended pattern for apps
On load: REST snapshot (
account) + subscribe toaccount_all/{account}andaccount_all_orders/{account}.After every
sendTx: optimistically show the order as pending; reconcile when it appears inaccount_all_ordersor a failure arrives onaccount_tx.On reconnect: resubscribe and replace local state with the new snapshot.
Read-only access for third parties
For portfolio trackers, accountants, or AI agents, ask the user for a read-only token (ro:…). It works anywhere an auth token is accepted for reading and can never trade. See Read-only Authentication.
Last updated
Was this helpful?