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();import httpx
REST = "https://api.testnet.firstaccess.exchange"
get = lambda path: httpx.get(REST + path).json()
company = next(c for c in get("/dydxprotocol/binary/company")["companies"] if c["ticker_base"] == "TESTCO")
index = get(f"/dydxprotocol/binary/company_index/{company['id']}")["company_index"]
print("I =", int(index["value"]) / 1e6, "B", index["mode"], index["stale"])
for event_id in company["expiry_event_ids"]:
event = get(f"/dydxprotocol/binary/event/{event_id}")["event"]
s = get(f"/dydxprotocol/binary/implied_price/{event_id}")["implied_price"]
print(event["ticker_base"], event["status"], "S =", int(s["value"]) / 1e6, "p =", int(s["binary_price"]) / 1e6)curl -s https://api.testnet.firstaccess.exchange/dydxprotocol/binary/company
curl -s https://api.testnet.firstaccess.exchange/dydxprotocol/binary/company/1
curl -s https://api.testnet.firstaccess.exchange/dydxprotocol/binary/company_index/1
curl -s https://api.testnet.firstaccess.exchange/dydxprotocol/binary/event/1
curl -s https://api.testnet.firstaccess.exchange/dydxprotocol/binary/implied_price/1x/binary
| REST | gRPC | Returns |
|---|---|---|
GET /dydxprotocol/binary/company | AllCompanies | Every company (paginated) |
GET /dydxprotocol/binary/company/{company_id} | Company | One company: status, template, perpetual, expiries, settlement |
GET /dydxprotocol/binary/company_index/{company_id} | CompanyIndex | The index I with its mode, weights and premium, and the perpetual's insurance fund address and balance |
GET /dydxprotocol/binary/event | AllEvents | Every IPO event (paginated) |
GET /dydxprotocol/binary/event/{event_id} | Event | One event: deadline, admin, status, outcome, final market cap, its markets |
GET /dydxprotocol/binary/implied_price/{event_id} | ImpliedPrice | The event's S, p, depth used and parameters |
GET /dydxprotocol/binary/market | AllMarkets | Every chain market's record (paginated) |
GET /dydxprotocol/binary/market/{perpetual_id} | Market | One market's record: status, question, admin, resolution, settlement totals |
Every field is described in the x/binary reference.
Markets and prices
| REST | Returns |
|---|---|
GET /dydxprotocol/perpetuals/perpetual | Every perpetual: params (ticker, market id, liquidity tier, chain_market), funding index, open interest |
GET /dydxprotocol/perpetuals/perpetual/{id} | One perpetual |
GET /dydxprotocol/perpetuals/liquidity_tiers | Margin tiers, the reserved chain-market tiers 1,000,000 to 1,000,003 included |
GET /dydxprotocol/perpetuals/params | Funding parameters |
GET /dydxprotocol/perpetuals/premium_votes, /premium_samples | This funding sample's votes and this hour's samples |
GET /dydxprotocol/clob/clob_pair | Every order book: id, perpetual, step, tick, status |
GET /dydxprotocol/clob/clob_pair/{id} | One book |
GET /dydxprotocol/prices/market | Every oracle price (exponent −6 on chain markets) |
GET /dydxprotocol/prices/market/{id} | One oracle price |
GET /dydxprotocol/prices/params/market | Oracle 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
}| Field | Kinds | Meaning |
|---|---|---|
kind | all | CHAIN_MARKET_KIND_BINARY, _CALL, _PUT or _PERP |
strike | call, put | K in micro-dollars a contract (micro-$B) |
underlying_market_id | call, put | The oracle market holding the event's S |
oi_cap | call, perp | Most open interest, contracts; 0 none (a perpetual's is never 0) |
price_cap | all | Highest order price and mark: $1 for a binary, K for a put |
event_id | binary, call, put | The IPO event; 0 for a standalone binary |
call_margin_ppm, call_min_margin_ppm | call | The call margin rates; 0 reads as 200% and 100% |
company_id | perp | The company |
max_abs_funding_rate_ppm | perp | Most 8-hour funding rate either way; 0 reads as 10,000 (1%) |
price_band_ppm | perp | The current band around I; 0 reads as 20,000 (2%) |
Accounts
| REST | Returns |
|---|---|
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/subaccount | Every 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_entry | First 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:443Parameters
| REST | Returns |
|---|---|
GET /dydxprotocol/v4/feetiers/perpetual_fee_params | The fee schedule |
GET /dydxprotocol/clob/liquidations_config | Liquidation fee and limits |
GET /dydxprotocol/clob/block_rate | Order rate limits |
GET /dydxprotocol/clob/equity_tier | Open-order limits by equity |
GET /dydxprotocol/v4/epochs/epoch_info | Funding epochs |
GET /dydxprotocol/assets/asset/0 | USDC: its denom and resolution |
GET /cosmos/gov/v1/params/voting | Governance 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.