Call views with NEAR JSON-RPC query / call_function (finality: "final" or "optimistic") on hexbook.near, args as base64 JSON. Amounts are decimal strings, prices raw decimal strings, hashes 64 hex characters, timestamps u64 nanoseconds (they exceed 2^53: parse them as big integers).

Order book

get_orderbook({ token_pair, depth?, with_extra? }) returns the live orders of both sides, best price first, time priority inside a level. Dead orders (expired or stale epoch) are hidden.
order_balance is base units for asks, quote units for bids. Group by price to get levels. depth_ask({ token_pair, limit?, with_extra? }) and depth_bid({ token_pair, limit?, with_owner? }) return one side the same way. Single orders:
These return every stored order, dead ones included. Use order liveness to tell them apart.

Active pairs

get_active_pairs() lists every book with its config.
  • volume: the total resting balance per side (sell in base units, buy in quote units), dead orders not yet closed included. Not traded volume.
  • fee is in pips (500 = 0.05%).
  • min_order_amount: raw units, base for asks, quote for bids. tick_size: raw price step, "0" = none.
For one book: get_book_config({ token_pair }) → { token_pair, fee_config, min_order_amount, tick_size }, get_protocol_fee({ token_pair }), get_volume({ token_pair }).

Quote

get_quote_pub({ ext, amount, token_id, order_placement_action, taker_id? }) simulates an order exactly as mt_on_transfer would execute it.
Whatever would make the execution panic (post-only that would take, min_amount_out not met, off-tick price, past expires_at) makes the view panic with the same error.

User balance

get_user_balance({ account_id }) → { "<token_id>": "<amount>" }: the account’s internal balance. get_user_balances({ skip?, limit? }) lists every account.

Payout mode

get_payout_mode({ account_id }) → "intents" (default) or "internal".

Epoch

get_epoch({ token_pair, account_id }) → the account’s current epoch in the book (0 until its first cancel_all or bump_epoch).

Order liveness

is_order_live({ token_pair, hash }) → true when the order rests, is not expired at this block and its epoch equals its maker’s current epoch; false otherwise (unknown, closed, expired or stale epoch). get_order_meta({ token_pair, hash }) → { epoch, expires_at, maker_epoch, live } for a resting order, or null (expires_at 0 = never).