DEX API
The DEX endpoints cover the constant-product AMM behind Superhero's swap UI: listed tokens and prices, liquidity pairs and reserves, swap routes, and every swap and liquidity event. The bonding-curve counterpart is Tokens.
All paths are relative to https://api.superhero.com. Reads need no authentication.
Endpoints
Tokens
| Method & path | Query | Returns |
|---|---|---|
GET /api/dex/tokens | order_by, order_direction, listed, search, limit, page | Paginated DexTokenDto |
GET /api/dex/tokens/{address} | None | One DexTokenDto |
GET /api/dex/tokens/{address}/price | None | Token plus current price |
GET /api/dex/tokens/{address}/price/analysis | base_token, debug | Liquidity-weighted price with confidence metrics |
GET /api/dex/tokens/{address}/summary | None | DexTokenSummaryDto |
GET /api/dex/tokens/{address}/history | interval, convertTo, limit, page | OHLCV candles |
PATCH /api/dex/tokens/{address}/listed | None | Set the listed flag. Requires an API key |
Pairs
| Method & path | Query | Returns |
|---|---|---|
GET /api/dex/pairs | order_by, order_direction, token_address, search, limit, page | Paginated PairDto |
GET /api/dex/pairs/{address} | None | One PairDto |
GET /api/dex/pairs/from/{from_token}/to/{to_token} | None | The direct pair for two tokens |
GET /api/dex/pairs/from/{from_token}/to/{to_token}/providers | None | All swap paths, direct and multi-hop |
GET /api/dex/pairs/{address}/history | interval, from_token, convertTo, limit, page | Pair price history |
GET /api/dex/pairs/{address}/summary | token | PairSummaryDto |
GET /api/dex/pairs/{address}/preview | interval | Compact preview payload |
Transactions and routing
| Method & path | Query | Returns |
|---|---|---|
GET /api/dex/transactions | order_by, order_direction, pair_address, token_address, tx_type, account_address, from_date, to_date, limit, page | Paginated PairTransactionDto |
GET /api/dex/transactions/{txHash} | None | One PairTransactionDto |
GET /api/dex/transactions/pair/{pairAddress} | order_by, order_direction, limit, page | Transactions for one pair |
GET /api/dex/swap-routes/{from_token}/{to_token} | None | All quotable routes |
DexTokenDto
| Field | Type | Meaning |
|---|---|---|
address | string | ct_... of the token contract |
name | string | Token name |
symbol | string | Ticker |
decimals | number | Decimal places. A number here, unlike the string on TokenDto |
pairs_count | number | How many pairs include this token |
created_at | string | ISO 8601 |
is_ae | boolean | Whether this token is AE itself |
listed | boolean | Officially listed or featured by the DEX |
price | PriceDto | Current price, all nine currencies. An object, not a string |
summary | DexTokenSummaryDto or null | Aggregated volume and change across all pools. Null when not computed |
decimals is a number here and a string on the bonding-curve TokenDto; price is a
PriceDto object here and a decimal string there. Do not share a parser between the two.
order_by accepts pairs_count, name, symbol, created_at, price, tvl, 24hchange,
24hvolume, 7dchange, 7dvolume, 30dchange, 30dvolume. Pass listed=true to restrict to
curated tokens, listed=false for the rest, and omit it for everything.
curl -s "https://api.superhero.com/api/dex/tokens?listed=true&order_by=tvl&order_direction=DESC&limit=20"DexTokenSummaryDto carries address, total_volume (a PriceDto) and change, a map keyed
by period, or null.
PairDto
| Field | Type | Meaning |
|---|---|---|
address | string | ct_... of the pair contract |
token0 | DexTokenDto | First token, fully inlined |
token1 | DexTokenDto | Second token, fully inlined |
reserve0 | string | Reserve of token0, in that token's base units |
reserve1 | string | Reserve of token1, in that token's base units |
total_supply | string | LP token supply, in base units |
transactions_count | number | Lifetime transactions on the pair |
created_at | string | ISO 8601 |
Reserves and LP supply are big-integer strings in base units. Divide each by 10 raised to its
own token's decimals, which may differ between the two sides.
curl -s "https://api.superhero.com/api/dex/pairs?order_by=transactions_count&order_direction=DESC&limit=20"PairSummaryDto adds volume and price change over 24h, 7d and 30d:
| Field | Type | Meaning |
|---|---|---|
address | string | The pair |
volume_token | string | Which token volume is denominated in |
token_position | string | Whether that token is position 0 or 1 |
total_volume | PriceDto | Lifetime volume |
change | object or null | 24h, 7d and 30d, each with volume (a PriceDto) and price_change (percentage and value, both strings) |
Pass ?token=ct_... to choose the denominating side; without it the endpoint defaults to WAE
when one side of the pair is WAE.
PairTransactionDto
One row per swap or liquidity event.
| Field | Type | Meaning |
|---|---|---|
tx_hash | string | th_... |
account_address | string or null | Who submitted it |
block_height | number | Inclusion height |
pair | PairDto | The pair, inlined |
tx_type | string | The router entrypoint that was called (see below) |
reserve0 / reserve1 | string | Reserves after the transaction, in base units |
ratio0 | string | Price of token0 quoted in token1: reserve0 / reserve1 |
ratio1 | string | Price of token1 quoted in token0 |
total_supply | string | LP supply after the transaction |
volume0 / volume1 | string | Traded volume per side for swaps; 0 for liquidity operations |
market_cap0 / market_cap1 | string | Market cap denominated in each token |
market_cap | string | Pool market cap |
swap_info | SwapInfoDto or null | Present for swaps |
pair_mint_info | LiquidityInfoDto or null | Present for liquidity operations |
created_at | string | ISO 8601 |
LiquidityInfoDto is type (PairMint or PairBurn) plus amount0 and amount1.
tx_type
tx_type is the name of the router entrypoint that was called. The complete set:
swap_exact_tokens_for_tokens add_liquidity
swap_tokens_for_exact_tokens add_liquidity_ae
swap_exact_tokens_for_ae remove_liquidity
swap_tokens_for_exact_ae remove_liquidity_ae
swap_exact_ae_for_tokens
swap_ae_for_exact_tokensThe tx_type filter is exact-match, so ?tx_type=swap matches nothing; to select all swaps,
make six requests or filter client-side on the swap_ prefix. PairMint and PairBurn are the
pair contract's event names and appear only inside pair_mint_info.type: add_liquidity*
carries a PairMint, remove_liquidity* a PairBurn.
Date filters on this endpoint are from_date and to_date, both ISO 8601, both bounds
inclusive. order_by accepts created_at (the default) or tx_type; anything else is a 400.
# Every "exact tokens in" swap, newest first
curl -s "https://api.superhero.com/api/dex/transactions?tx_type=swap_exact_tokens_for_tokens&limit=20&order_direction=DESC"Fetch a single transaction by hash as a path segment (GET /api/dex/transactions/{txHash}),
unlike the bonding-curve equivalent, which takes a tx_hash query parameter.
GET /api/dex/swap-routes/{from_token}/{to_token}
Returns an array of routes, each an ordered array of pairs, covering direct and single-hop paths. An empty array means no route exists.
| Field | Type | Meaning |
|---|---|---|
address | string | The pair contract |
synchronized | boolean | Whether the pair has usable non-zero reserves on both sides |
token0 / token1 | string | The two token addresses |
liquidityInfo | object | Reserve information for quoting |
A route containing an unsynchronized pair is not quotable, so check synchronized on every hop.
curl -s "https://api.superhero.com/api/dex/swap-routes/ct_FROM_TOKEN/ct_TO_TOKEN"GET /api/dex/pairs/from/{from_token}/to/{to_token}/providers is the broader form, returning
all possible paths including multi-hop.
GET /api/dex/tokens/{address}/history
OHLCV for a single token. The series is derived from the deepest pool pairing that token against WAE, so the price is expressed in AE; if no WAE pool exists, the deepest available pool is used.
| Parameter | Notes |
|---|---|
interval | Candle width in seconds. Default 3600, minimum 60, maximum 86400. Outside that range is a 400 |
convertTo | Default ae. Fiat conversion uses the AE-to-currency rate as of each candle's own timestamp |
limit, page | Standard pagination |
Requesting a fiat convertTo for a token without a WAE-quoted pool returns 400.
GET /api/dex/pairs/{address}/history is the pair-level equivalent and adds from_token, which
takes token0 or token1 to choose the quoting direction.
GET /api/dex/tokens/{address}/price
{ "price": "0.0431", "token": {} }token is the full DexTokenDto; price is the best price found, quoted in WAE, as a
decimal string. It is null when the token has no liquid path to WAE. The value comes from the
deepest-liquidity path, not the median. A 404 means the token is unknown to the DEX index.
GET /api/dex/tokens/{address}/price/analysis
The same computation with its working shown:
| Field | Type | Meaning |
|---|---|---|
price | string or null | The best price, the same value the /price route returns |
confidence | number | 0 to 1 |
bestPath | array of pairs | The route the price came from |
allPaths | array | Every path considered, each with path, price, liquidity and confidence |
liquidityWeightedPrice | string or null | Weighted across all paths |
medianPrice | string or null | Median across all paths, for comparison |
base_token defaults to WAE; debug=true widens the per-path breakdown. Asking for the base
token's price against itself returns "1". A token with no path at all is a 404
(No price paths found for token ...).
A wide spread between price, medianPrice and liquidityWeightedPrice means the quote rests
on one shallow pool.
PATCH /api/dex/tokens/{address}/listed
Sets the listed flag. Body is { "listed": true } or { "listed": false }; returns the
updated DexTokenDto, or 404 for an unknown token.
Requires the API key, sent as x-api-key: YOUR_KEY or Authorization: Bearer YOUR_KEY. A
missing or wrong key is a 401. Every other write in the API uses a wallet signature. See
Conventions.
Pagination on /api/dex/*
limit defaults to 100 and is capped at 100. Unlike the rest of the API, exceeding the cap does
not error: limit=500 is silently clamped to 100, page=0 to 1, and a non-numeric limit falls
back to 100. Read meta.itemsPerPage rather than assuming your limit was honoured, and never
infer "no more results" from getting fewer rows than you asked for.
Related
- API Conventions: pagination, the
limitcap and the date-parameter spellings - Tokens API: the bonding-curve tokens and their
TokenDto - Transactions API: bonding-curve trades
- Swap: the feature these endpoints back
- Pools: what a pair is and what providing liquidity means
- Wrapped AE: why WAE is the pricing base for every history series