For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

Add auth to the subscribe message for private channels:

Which channel to use:

You need
Channel

Positions, trades, funding across all markets

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.

  1. On load: REST snapshot (account) + subscribe to account_all/{account} and account_all_orders/{account}.

  2. After every sendTx: optimistically show the order as pending; reconcile when it appears in account_all_orders or a failure arrives on account_tx.

  3. 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?