curl -X POST "https://api.metastreams.io/v1/trades" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filter": { "chains": ["solana"], "side": "buy", "flags": ["whale"], "volumeUsd": { "min": "1000" } },
"limit": 30
}'
curl -X POST "https://api.metastreams.io/v1/trades" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filter": { "tokens": ["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"] },
"sortBy": "volumeUsd",
"fromAt": 1789545600000,
"limit": 20
}'
const response = await fetch("https://api.metastreams.io/v1/trades", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
filter: { chains: ["solana"], side: "buy", flags: ["whale"], volumeUsd: { min: "1000" } },
limit: 30,
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const { trades, nextCursor, hasMore } = await response.json();
use serde_json::{Value, json};
let page: Value = reqwest::Client::new()
.post("https://api.metastreams.io/v1/trades")
.bearer_auth(std::env::var("API_KEY")?)
.json(&json!({
"filter": { "chains": ["solana"], "side": "buy", "flags": ["whale"], "volumeUsd": { "min": "1000" } },
"limit": 30,
}))
.send()
.await?
.error_for_status()?
.json()
.await?;
let trades = &page["trades"];
{
"trades": [
{
"id": "4xQmVb8e2kT1nR7pZcW3sLdHfA9jEuY6gVnX1oB5iC0wQ2rT8yU3iO7pA1sD4fG6h:2",
"chain": "solana",
"token": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"name": "Bonk",
"symbol": "Bonk",
"trader": "7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5",
"transactionHash": "4xQmVb8e2kT1nR7pZcW3sLdHfA9jEuY6gVnX1oB5iC0wQ2rT8yU3iO7pA1sD4fG6h",
"side": "buy",
"amount": "62500000",
"price": { "native": "0.000000121", "usd": "0.0000216" },
"volume": { "native": "7.55", "usd": "1350.60" },
"marketCap": { "native": "10741962.1", "usd": "1917440000" },
"flags": ["whale"],
"timestamp": 1789632015120
}
],
"nextCursor": "eyJ0cyI6MTc4OTYzMjAxNTEyMCwiaWQiOiI0eFFtVmI4ZTJrVDFuUjdwWmNXM3NMZEhmQTlq",
"hasMore": true
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "One or more parameters are invalid.",
"details": [{ "field": "fromAt", "message": "A ranking needs the start of its window." }]
}
}
REST
Trade history
Returns past trades that match a spot.trades filter, newest first or ranked by a value.
POST
/
v1
/
trades
curl -X POST "https://api.metastreams.io/v1/trades" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filter": { "chains": ["solana"], "side": "buy", "flags": ["whale"], "volumeUsd": { "min": "1000" } },
"limit": 30
}'
curl -X POST "https://api.metastreams.io/v1/trades" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filter": { "tokens": ["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"] },
"sortBy": "volumeUsd",
"fromAt": 1789545600000,
"limit": 20
}'
const response = await fetch("https://api.metastreams.io/v1/trades", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
filter: { chains: ["solana"], side: "buy", flags: ["whale"], volumeUsd: { min: "1000" } },
limit: 30,
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const { trades, nextCursor, hasMore } = await response.json();
use serde_json::{Value, json};
let page: Value = reqwest::Client::new()
.post("https://api.metastreams.io/v1/trades")
.bearer_auth(std::env::var("API_KEY")?)
.json(&json!({
"filter": { "chains": ["solana"], "side": "buy", "flags": ["whale"], "volumeUsd": { "min": "1000" } },
"limit": 30,
}))
.send()
.await?
.error_for_status()?
.json()
.await?;
let trades = &page["trades"];
{
"trades": [
{
"id": "4xQmVb8e2kT1nR7pZcW3sLdHfA9jEuY6gVnX1oB5iC0wQ2rT8yU3iO7pA1sD4fG6h:2",
"chain": "solana",
"token": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"name": "Bonk",
"symbol": "Bonk",
"trader": "7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5",
"transactionHash": "4xQmVb8e2kT1nR7pZcW3sLdHfA9jEuY6gVnX1oB5iC0wQ2rT8yU3iO7pA1sD4fG6h",
"side": "buy",
"amount": "62500000",
"price": { "native": "0.000000121", "usd": "0.0000216" },
"volume": { "native": "7.55", "usd": "1350.60" },
"marketCap": { "native": "10741962.1", "usd": "1917440000" },
"flags": ["whale"],
"timestamp": 1789632015120
}
],
"nextCursor": "eyJ0cyI6MTc4OTYzMjAxNTEyMCwiaWQiOiI0eFFtVmI4ZTJrVDFuUjdwWmNXM3NMZEhmQTlq",
"hasMore": true
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "One or more parameters are invalid.",
"details": [{ "field": "fromAt", "message": "A ranking needs the start of its window." }]
}
}
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:
tokentests 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, orsortByset totimestamp, trades are returned newest first.ordermust staydesc. - Ranked. Any other
sortByranks the trades in the window by that value, such asvolumeUsdormarketCapUsd.orderisdescby default, orasc. 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
tokenspages 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 atfromAtplus 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_ERRORonfromAt. Start again with a laterfromAt.
Response
A page containstrades, 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
SendnextCursor 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:- Subscribe to
spot.tradeswith the filter, and buffer the trades you receive. - Read
POST /v1/tradeswith the same filter, newest first. - Drop each buffered trade whose
idthe read returned, then apply the rest.
id is the same on both.
Errors
| Code | When |
|---|---|
UNSUPPORTED_CHAIN | A slug in filter.chains is not supported |
VALIDATION_ERROR | More than 10 tokens or pools, more than 100 wallets, or an empty list; a ranking without fromAt, or with a window that is too wide or too old; a ranking whose fromAt is in the future; a toAt at or before fromAt; order set to asc on a newest-first read; a range with min above max; an unknown filter key, flag or value; a cursor from another request; or a malformed body |
curl -X POST "https://api.metastreams.io/v1/trades" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filter": { "chains": ["solana"], "side": "buy", "flags": ["whale"], "volumeUsd": { "min": "1000" } },
"limit": 30
}'
curl -X POST "https://api.metastreams.io/v1/trades" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filter": { "tokens": ["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"] },
"sortBy": "volumeUsd",
"fromAt": 1789545600000,
"limit": 20
}'
const response = await fetch("https://api.metastreams.io/v1/trades", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
filter: { chains: ["solana"], side: "buy", flags: ["whale"], volumeUsd: { min: "1000" } },
limit: 30,
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const { trades, nextCursor, hasMore } = await response.json();
use serde_json::{Value, json};
let page: Value = reqwest::Client::new()
.post("https://api.metastreams.io/v1/trades")
.bearer_auth(std::env::var("API_KEY")?)
.json(&json!({
"filter": { "chains": ["solana"], "side": "buy", "flags": ["whale"], "volumeUsd": { "min": "1000" } },
"limit": 30,
}))
.send()
.await?
.error_for_status()?
.json()
.await?;
let trades = &page["trades"];
{
"trades": [
{
"id": "4xQmVb8e2kT1nR7pZcW3sLdHfA9jEuY6gVnX1oB5iC0wQ2rT8yU3iO7pA1sD4fG6h:2",
"chain": "solana",
"token": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"name": "Bonk",
"symbol": "Bonk",
"trader": "7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5",
"transactionHash": "4xQmVb8e2kT1nR7pZcW3sLdHfA9jEuY6gVnX1oB5iC0wQ2rT8yU3iO7pA1sD4fG6h",
"side": "buy",
"amount": "62500000",
"price": { "native": "0.000000121", "usd": "0.0000216" },
"volume": { "native": "7.55", "usd": "1350.60" },
"marketCap": { "native": "10741962.1", "usd": "1917440000" },
"flags": ["whale"],
"timestamp": 1789632015120
}
],
"nextCursor": "eyJ0cyI6MTc4OTYzMjAxNTEyMCwiaWQiOiI0eFFtVmI4ZTJrVDFuUjdwWmNXM3NMZEhmQTlq",
"hasMore": true
}
{
"error": {
"code": "VALIDATION_ERROR",
"message": "One or more parameters are invalid.",
"details": [{ "field": "fromAt", "message": "A ranking needs the start of its window." }]
}
}
Authorizations
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.
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