Skip to main content
POST
Returns past trades that match a spot.trades filter, newest first or ranked by a value. The same filter object reads the history and streams new trades.

Filter

filter takes every key of a spot.trades subscription filter, such as chains, tokens, wallets, pools, side, flags, platforms, volumeUsd, token and exclude. See spot.trades for each key and Filtering streams for the rules they share. Omit filter to match every trade. A filter can list at most 10 tokens, 10 pools and 100 wallets, and each list must contain at least one value. The filter keeps the same trades as the subscription, with two differences:
  • token tests the token’s state when the request is read, not when the trade was made.
  • A trade that was corrected after it was first recorded matches when any recorded version matches. A ranking can return such a trade once per version.

Order

  • Newest first. With no sortBy, or sortBy set to timestamp, trades are returned newest first. order must stay desc.
  • Ranked. Any other sortBy ranks the trades in the window by that value, such as volumeUsd or marketCapUsd. order is desc by default, or asc. A trade without a value for the key is not ranked.

Time window

fromAt is inclusive and toAt is exclusive, both in Unix milliseconds.
  • A newest-first read that lists tokens pages back through the whole history of those tokens. A read that lists no token returns the last 30 days.
  • A ranked read requires fromAt. The listed tokens share a window of 30 days, with at least one day each, so one token ranks up to 30 days and ten tokens rank up to 3 days. A read that lists no token ranks at most one day, inside the last 30 days.
  • Without toAt, a ranking ends at fromAt plus the widest allowed window, or at the current time if that is earlier. Every page of the ranking keeps that end.
  • A ranking that pages past the 30-day limit returns 400 VALIDATION_ERROR on fromAt. Start again with a later fromAt.

Response

A page contains trades, nextCursor and hasMore, in the same shape as Trades. limit sets the page size. The default is 20, and out-of-range values are clamped to 1–100. Each token and each wallet in filter costs one credit, and a request that lists neither costs one. Pools are free.

Pagination

Send nextCursor back as cursor, with the rest of the body unchanged. A cursor continues only the request that made it, and a cursor from another request returns 400 VALIDATION_ERROR on cursor. A page can hold fewer than limit trades, or none, while hasMore is true. Page until hasMore is false.

Backfill a stream

To fill a list with past trades and keep it live without a gap:
  1. Subscribe to spot.trades with the filter, and buffer the trades you receive.
  2. Read POST /v1/trades with the same filter, newest first.
  3. Drop each buffered trade whose id the read returned, then apply the rest.
A trade’s id is the same on both.

Errors

Authorizations

Authorization
string
header
required

Send an API key, or a session token a key minted, as Authorization: Bearer <credential>. A browser opening /v1/stream offers its session token in Sec-WebSocket-Protocol instead.

Body

application/json

The body of POST /v1/trades: trade history under any spot.trades filter.

filter takes every key a spot.trades subscription takes. A timestamp order reads newest first and pages back through history. Any other order ranks one window of trades by that value, and needs fromAt.

cursor
string | null

Opaque cursor from the previous page.

filter
object

The trades to keep, as a spot.trades subscription names them.

fromAt
null | integer<int64>

Window start, inclusive. A ranking needs it.

limit
integer<int32> | null

Trades per page, 20 when absent. A value outside 1–100 is clamped into it.

Required range: x >= 0
order
null | enum<string>

desc when absent. A timestamp order is always desc.

Available options:
asc,
desc
sortBy
null | enum<string>

The value that orders the trades; timestamp when absent.

Available options:
timestamp,
volumeUsd,
volumeNative,
amount,
priceUsd,
priceNative,
marketCapUsd,
marketCapNative,
liquidityUsd,
liquidityNative,
feesValidatorUsd,
feesValidatorNative,
feesPlatformUsd,
feesPlatformNative
toAt
null | integer<int64>

Window end, exclusive. When absent, a feed ends at now. A ranking ends at its widest window past fromAt, or at now when that is earlier.

Response

The trades the filter keeps, in the requested order.

A page of trades, newest first.

hasMore
boolean
required

Whether a next page exists.

trades
object[]
required

Trades on the requested page, newest first.

nextCursor
string | null

Cursor for the next page; null on the last page.