Skip to content

Trades

Both methods take these, all optional:

Param Description
fields Required. Trade fields to return. id always comes first
token Trades with this token on either side, or a list of tokens. Each trade appears once, seen from this token
parent Instead of token: the tokens directly under an account or a list of them, as they are when the request is made, up to 2,000 tokens
counterparty The other token. Needs token
trader Trades by this account
side sell, buy, add_liquidity or remove_liquidity. With token, only trades where it went in or came out, or only that kind of liquidity change. Without it, sell and buy pick which token each trade is seen from (buy means token_out)
include_liquidity Default false. Liquidity changes alongside swaps, when side isn’t given
min_usd One of 10, 50, 100, 500, 1000, 5000, 10000

A page of trades, newest first. HTTP: /trades.

Param Description
limit 1 to 200, default 50
cursor next_cursor from the page before
after_millis Inclusive
before_millis Exclusive

Result:

{ "height": 219969289, "timestamp_millis": 1792003517185, "columns": ["id", ...], "rows": [...], "next_cursor": "1792003517185090582:6860365", "latest_id": 6860368 }
  • next_cursor: pass as cursor for the next page. null on the last page.
  • latest_id: the newest trade the result accounts for, of all trades, not just matching ones.

History, then live trades. See History, then live. Takes one of:

Param Description
history 1 to 200: the newest trades, newest first, in the result, with next_cursor if there are more
after_id Every trade after this one, oldest first, in the result. More than 10,000 is too_far_behind
neither Only trades from now on

The result is { "height", "timestamp_millis", "columns", "rows", "next_cursor", "latest_id" }. Each push is { "sub", "height", "timestamp_millis", "rows" } with a block’s matching trades, oldest first, in the result’s columns.

To pick up after a reconnect, subscribe again with after_id set to the newest id you have, or the result’s latest_id if that’s newer.

Field Type Description
id number Identifies this view of the trade. The same trade seen from its other token has another id
height, timestamp_millis number The block it’s in
trader string The account that swapped, or the liquidity provider
pool_id string Like REF-6063
pool_url string The pool’s page on its DEX
transaction_id, receipt_id string
token_in, amount_in string or null What was sold. null for liquidity changes
token_out, amount_out string or null What was bought. null for liquidity changes
token, amount string The trade seen from one of its tokens: the filtered one when there’s a token filter, otherwise token_in
counterparty, counterparty_amount string The other token
side string sell if token went in, buy if it came out, or add_liquidity or remove_liquidity
usd_value string or null At the prices from before its block. null when neither token had a price yet. For a liquidity change, both tokens together
referrer string or null The app or aggregator the swap came through, as the DEX reports it. Always null for liquidity changes
  • Amounts are in each token’s smallest units.
  • Native NEAR is always wrap.near, so its trades are found with token: "wrap.near". Wrapping and unwrapping aren’t trades.
  • For liquidity changes, token and counterparty are the pool’s two tokens.