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>"WebSocket (recommended)
Add auth to the subscribe message for private channels:
{ "type": "subscribe", "channel": "account_all_orders/123", "auth": "<AUTH_TOKEN>" }Which channel to use:
| You need | Channel |
|---|---|
| Positions, trades, funding across all markets | Account All |
| Open orders | Account All Orders |
| Whether a transaction executed or was rejected | Account Tx |
| Collateral, leverage, margin usage | Account Stats |
| Liquidations, deleverages, announcements | Notification |
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.
Updated 2 days ago
Did this page help you?
