Transactions API
Every buy and sell against a token sale contract is indexed here. Filter by token to watch a market, by account to watch a trader, or by both.
All paths are relative to https://api.superhero.com. Reads need no authentication.
Endpoints
| Method & path | Query | Returns |
|---|---|---|
GET /api/transactions | token_address, account_address, includes, limit, page | Paginated trade rows |
GET /api/transactions/by-hash | tx_hash | One trade row |
GET /api/tokens/{address}/transactions | interval, start_date, end_date, convertTo, mode | Aggregated series for one token |
GET /api/debug/failed-transactions | None | The 500 most recent indexer failures |
These are Superhero trade records, not raw chain transactions. For arbitrary chain history (transfers, contract calls, name transactions), use the middleware; see Node & Middleware.
GET /api/transactions
| Parameter | Notes |
|---|---|
token_address | A token sale address, AEX-9 address or name, resolved through the same lookup as /api/tokens/{address} |
account_address | Filter to trades made by this ak_.... A malformed address is a 400 |
includes | Only token. Inlines the full token object on each row |
limit, page | limit defaults to 100 and is capped at 100 |
Both filters compose:
# All recent trades, with the token inlined
curl -s "https://api.superhero.com/api/transactions?includes=token&limit=20&page=1"
# One account's trades on one token
curl -s "https://api.superhero.com/api/transactions?token_address=ct_YOUR_SALE_ADDRESS&account_address=ak_YOUR_ADDRESS&includes=token&limit=20"Response is the standard items plus meta envelope.
Results are ordered by created_at descending, and that is the only order: there is no
order_by, order_direction, from_date or to_date (unrecognised keys are ignored). To bound
a date range, page from the top and stop when created_at passes your cutoff, or use
GET /api/tokens/{address}/transactions, which takes start_date and end_date.
Without token_address the list is restricted to tokens from the current community factory.
An unresolvable token_address returns an empty page, not a 404. account_address also adds
token.name, token.symbol, token.address, token.sale_address and token.collection to
each row even without includes=token.
Trade row
| Field | Type | Meaning |
|---|---|---|
tx_hash | string | th_..., the primary key |
sale_address | string | ct_... of the token sale contract this trade hit |
tx_type | string | buy, sell or create_community (see below) |
block_height | number | Height of the including block |
address | string | The trader's ak_... |
verified | boolean | The indexer settled this row: no revalidation pending and the transaction is at least 5 hours old |
volume | string | Token quantity traded, in whole tokens |
protocol_reward | string | Protocol-fee mint attached to the trade, in whole tokens |
amount | PriceDto | Total spent (buy) or received (sell), in AE |
unit_price | PriceDto | amount / volume, the realised price per token, in AE |
previous_buy_price | PriceDto or null | Curve buy price before this trade, in AE |
buy_price | PriceDto | Curve buy price after this trade, in AE |
sell_price | PriceDto or null | Legacy field |
total_supply | string | Token supply after the trade, in whole tokens |
market_cap | PriceDto or null | buy_price * total_supply, in AE, not aettos |
created_at | string | ISO 8601, the micro-block time |
With includes=token, a token object carrying the full token row is added.
Units
Nothing on a trade row needs dividing by 1e18, even though the field names repeat those on
TokenDto, which are scaled:
volume,protocol_rewardandtotal_supplyare in whole tokens, not base units.amount,unit_price,buy_priceandprevious_buy_priceare in AE.market_capis in AE, whereasTokenDto.market_capis in aettos. The two differ by 1e18.
tx_type
tx_type is the name of the contract entrypoint that was called. The complete set:
| Value | What it is |
|---|---|
buy | A purchase from the bonding curve |
sell | A sale back into the curve |
create_community | Token creation. Carries the creator's initial purchase, so it has a non-zero volume and amount and counts as a buy |
Nothing else (a DEX swap, an AE transfer, a governance vote) is indexed here, and reverted transactions are skipped, so every row is a trade that succeeded.
Treat create_community as a buy. PnL, volume and trending all use
tx_type IN ('buy', 'create_community') on the acquisition side and tx_type = 'sell' on the
disposal side; counting only buy understates every creator's position by their founding
purchase.
For the DEX's separate tx_type vocabulary, see DEX API.
GET /api/transactions/by-hash
Takes the hash as a query parameter, not a path segment:
curl -s "https://api.superhero.com/api/transactions/by-hash?tx_hash=th_YOUR_TX_HASH"Returns a single row; a malformed hash is a 400. On a miss, the handler fetches the transaction
from the middleware and indexes it on the spot, so a trade the indexer has not caught up to can
be pulled in by asking for it; only if that also fails is it a 404. The DEX equivalent takes the
hash as a path segment: GET /api/dex/transactions/{txHash}.
GET /api/tokens/{address}/transactions
These are aggregated rather than row-level, and charts are built from them.
| Parameter | Notes |
|---|---|
interval | Bucket width in seconds |
start_date, end_date | ISO 8601. Snake_case here, against camelCase on the account endpoints |
convertTo | One of the nine currency codes, default ae |
mode | normal or aggregated |
curl -s "https://api.superhero.com/api/tokens/SUPERHERO/transactions?interval=3600&mode=aggregated&convertTo=usd"For OHLC candles, GET /api/tokens/{address}/history is the better endpoint. See
Tokens.
Live trades
The API pushes every live-indexed trade over Socket.IO on the token-history channel,
carrying the row that was just written plus the token it belongs to. Seed your list from this
endpoint once, then update from the socket. See WebSocket.
Relating a record to the chain
tx_hash is the on-chain transaction hash:
| Where | URL |
|---|---|
| æScan (mainnet) | https://aescan.io/transactions/{tx_hash} |
| æScan (testnet) | https://testnet.aescan.io/transactions/{tx_hash} |
| Middleware | GET https://mainnet.aeternity.io/mdw/v3/transactions/{tx_hash} |
While a trade is confirming, poll the middleware form and treat a 404 as "still pending".
GET /api/debug/failed-transactions
A diagnostics endpoint: the 500 most recent rows of the failed-transactions table, newest first, with no parameters and no pagination.
| Field | Type | Meaning |
|---|---|---|
hash | string | th_... of the transaction the indexer could not process |
retries | number | How many times it has been re-attempted |
error | string | The error message |
error_trace | string | The stack trace |
created_at | string | ISO 8601 |
Use it when a trade of yours is missing from /api/transactions and you want to know whether
the indexer failed on it.
Related
- API Conventions: the units table and the shared pagination envelope
- Tokens API: the
TokenDtothatincludes=tokeninlines - Accounts API: the aggregated PnL these trades roll up into
- WebSocket API: push instead of poll for the same records
- Node & Middleware: chain history beyond Superhero trades
- æScan (opens in a new tab): the block explorer for resolving a
tx_hash