Skip to content
First Access Exchange

Queries

The node answers every module's queries over REST (https://api.testnet.firstaccess.exchange) and gRPC (grpc.testnet.firstaccess.exchange:443). The REST paths below are the gRPC methods' HTTP bindings; the gRPC service is the module's Query (for example dydxprotocol.binary.Query/CompanyIndex). Lists are paginated: pass pagination.limit (and pagination.key from the previous page's pagination.next_key).

These are the chain's own state. For history (trades, candles, fills, funding payments) and short-term orders, use the indexer.

A company, its index and its markets

const REST = 'https://api.testnet.firstaccess.exchange';
const get = async (path: string) => (await fetch(REST + path)).json();
 
async function main() {
  const { companies } = await get('/dydxprotocol/binary/company');
  const company = companies.find((c: any) => c.ticker_base === 'TESTCO');
  const { company_index } = await get(`/dydxprotocol/binary/company_index/${company.id}`);
  console.log('I =', Number(company_index.value) / 1e6, 'B', company_index.mode, company_index.stale);
 
  for (const eventId of company.expiry_event_ids) {
    const { event } = await get(`/dydxprotocol/binary/event/${eventId}`);
    const { implied_price } = await get(`/dydxprotocol/binary/implied_price/${eventId}`);
    console.log(event.ticker_base, event.status, 'S =', Number(implied_price.value) / 1e6, 'p =', Number(implied_price.binary_price) / 1e6);
  }
}
 
main();

x/binary

RESTgRPCReturns
GET /dydxprotocol/binary/companyAllCompaniesEvery company (paginated)
GET /dydxprotocol/binary/company/{company_id}CompanyOne company: status, template, perpetual, expiries, settlement
GET /dydxprotocol/binary/company_index/{company_id}CompanyIndexThe index I with its mode, weights and premium, and the perpetual's insurance fund address and balance
GET /dydxprotocol/binary/eventAllEventsEvery IPO event (paginated)
GET /dydxprotocol/binary/event/{event_id}EventOne event: deadline, admin, status, outcome, final market cap, its markets
GET /dydxprotocol/binary/implied_price/{event_id}ImpliedPriceThe event's S, p, depth used and parameters
GET /dydxprotocol/binary/marketAllMarketsEvery chain market's record (paginated)
GET /dydxprotocol/binary/market/{perpetual_id}MarketOne market's record: status, question, admin, resolution, settlement totals

Every field is described in the x/binary reference.

Markets and prices

RESTReturns
GET /dydxprotocol/perpetuals/perpetualEvery perpetual: params (ticker, market id, liquidity tier, chain_market), funding index, open interest
GET /dydxprotocol/perpetuals/perpetual/{id}One perpetual
GET /dydxprotocol/perpetuals/liquidity_tiersMargin tiers, the reserved chain-market tiers 1,000,000 to 1,000,003 included
GET /dydxprotocol/perpetuals/paramsFunding parameters
GET /dydxprotocol/perpetuals/premium_votes, /premium_samplesThis funding sample's votes and this hour's samples
GET /dydxprotocol/clob/clob_pairEvery order book: id, perpetual, step, tick, status
GET /dydxprotocol/clob/clob_pair/{id}One book
GET /dydxprotocol/prices/marketEvery oracle price (exponent −6 on chain markets)
GET /dydxprotocol/prices/market/{id}One oracle price
GET /dydxprotocol/prices/params/marketOracle market parameters

A perpetual's chain_market record:

{
  "kind": "CHAIN_MARKET_KIND_PERP",
  "strike": "0",
  "underlying_market_id": 0,
  "oi_cap": "100000",
  "price_cap": "500000000",
  "event_id": 0,
  "call_margin_ppm": 0,
  "call_min_margin_ppm": 0,
  "company_id": 1,
  "max_abs_funding_rate_ppm": 0,
  "price_band_ppm": 100000
}
FieldKindsMeaning
kindallCHAIN_MARKET_KIND_BINARY, _CALL, _PUT or _PERP
strikecall, putK in micro-dollars a contract (micro-$B)
underlying_market_idcall, putThe oracle market holding the event's S
oi_capcall, perpMost open interest, contracts; 0 none (a perpetual's is never 0)
price_capallHighest order price and mark: $1 for a binary, K for a put
event_idbinary, call, putThe IPO event; 0 for a standalone binary
call_margin_ppm, call_min_margin_ppmcallThe call margin rates; 0 reads as 200% and 100%
company_idperpThe company
max_abs_funding_rate_ppmperpMost 8-hour funding rate either way; 0 reads as 10,000 (1%)
price_band_ppmperpThe current band around I; 0 reads as 20,000 (2%)

Accounts

RESTReturns
GET /cosmos/auth/v1beta1/accounts/{address}Account number and sequence
GET /cosmos/bank/v1beta1/balances/{address}Wallet balances
GET /dydxprotocol/subaccounts/subaccount/{owner}/{number}A subaccount's USDC and positions
GET /dydxprotocol/subaccounts/subaccountEvery subaccount (paginated)
GET /dydxprotocol/subaccounts/withdrawals_and_transfers_blocked_info/{perpetual_id}Whether the withdrawal gate is on for a market's collateral pool
GET /dydxprotocol/subaccounts/call_short_entryFirst Access: each open short call's average sale price (the premium lock)
GET /dydxprotocol/v4/feetiers/user_fee_tier?user={address}The address's fee tier
GET /dydxprotocol/v4/stats/user_stats?user={address}Its trading volume

A long-term order in state:

# dydxprotocold q clob stateful-order OWNER SUBACCOUNT CLIENT_ID CLOB_PAIR_ID ORDER_FLAGS
dydxprotocold q clob stateful-order dydx1... 1 42 0 64 --node https://rpc.testnet.firstaccess.exchange:443

Parameters

RESTReturns
GET /dydxprotocol/v4/feetiers/perpetual_fee_paramsThe fee schedule
GET /dydxprotocol/clob/liquidations_configLiquidation fee and limits
GET /dydxprotocol/clob/block_rateOrder rate limits
GET /dydxprotocol/clob/equity_tierOpen-order limits by equity
GET /dydxprotocol/v4/epochs/epoch_infoFunding epochs
GET /dydxprotocol/assets/asset/0USDC: its denom and resolution
GET /cosmos/gov/v1/params/votingGovernance voting periods

The order book

The node has no order-book query. Long-term orders on chain markets are in x/clob's store under a price index (PxIdx: + clob pair id + side + price + order id → size and placement height), less filled amounts (Fill:), which abci_query on /store/clob/subspace can read; the trading app does so. Short-term orders live only in validators' memory: for the full book use the indexer's /v4/orderbooks/perpetualMarket/{ticker} or its v4_orderbook channel.