Skip to Content

GET /trades

Returns recent trade history with pagination. Ordered from present to past.

Request

Query Parameters:

NameTypeRequiredDescription
marketIdnumberNoFilter by market ID
makerIdnumberNoFilter by maker account ID
takerIdnumberNoFilter by taker account ID
takerSidestringNoFilter by taker side: ask or bid
sincestringNoStart timestamp (RFC3339); defaults to UNIX epoch
untilstringNoEnd timestamp (RFC3339); defaults to current time
startInclusivenumberNoPagination cursor for fetching next page
pageSizenumberNoMaximum trades to return (default: 50, max: 50)
# Recent trades for a market curl "https://zo-mainnet.n1.xyz/trades?marketId=0&pageSize=10" # Trades for a specific maker with time range curl "https://zo-mainnet.n1.xyz/trades?makerId=12345&since=2024-01-01T00:00:00Z&until=2024-01-02T00:00:00Z" # Filter by taker side curl "https://zo-mainnet.n1.xyz/trades?marketId=0&takerSide=bid&pageSize=50"

Response

{ "items": [ { "time": "…", "actionId": 1, "tradeId": 1, "takerId": 1, "takerSide": "ask", "makerId": 1, "marketId": 1, "orderId": 1, "price": 1, "baseSize": 1 } ], "nextStartInclusive": null }

Response Fields

PageResult Object

FieldTypeDescription
itemsTrade[]Array of trade objects
nextStartInclusivenumber | nullPagination cursor for next page. If null, no more data.

Trade Object

FieldTypeDescription
timestringTrade timestamp (RFC3339/ISO 8601)
actionIdnumberAction ID that caused this trade
tradeIdnumberUnique trade identifier
takerIdnumberTaker account ID
takerSidestringTaker side: bid (buy) or ask (sell)
makerIdnumberMaker account ID
marketIdnumberMarket where trade occurred
orderIdnumberOrder ID of the maker order
pricenumberTrade execution price
baseSizenumberTrade size in base asset

Pagination

To fetch all trades, use the nextStartInclusive cursor:

import requests def fetch_all_trades(market_id: int, since: str, until: str): all_trades = [] cursor = None while True: params = { "marketId": market_id, "since": since, "until": until, "pageSize": 50 } if cursor is not None: params["startInclusive"] = cursor response = requests.get("https://zo-mainnet.n1.xyz/trades", params=params) data = response.json() all_trades.extend(data["items"]) cursor = data.get("nextStartInclusive") if cursor is None: break return all_trades trades = fetch_all_trades(0, "2024-01-01T00:00:00Z", "2024-01-02T00:00:00Z") print(f"Total trades: {len(trades)}")

Example: Python

import requests from datetime import datetime response = requests.get( "https://zo-mainnet.n1.xyz/trades", params={"marketId": 0, "pageSize": 20} ) data = response.json() print("Recent Trades:") for trade in data["items"]: time = datetime.fromisoformat(trade["time"].replace("Z", "+00:00")) side = "BUY" if trade["takerSide"] == "bid" else "SELL" print(f" {time:%H:%M:%S} | {side:4} | ${trade['price']:,.1f} x {trade['baseSize']:.4f}")

Fetching Trade History for Your Account

import requests # Replace with your account ID my_account_id = 12345 # Trades where you were the maker maker_trades = requests.get( "https://zo-mainnet.n1.xyz/trades", params={"makerId": my_account_id, "pageSize": 50} ).json() # Trades where you were the taker taker_trades = requests.get( "https://zo-mainnet.n1.xyz/trades", params={"takerId": my_account_id, "pageSize": 50} ).json() print(f"Maker trades: {len(maker_trades['items'])}") print(f"Taker trades: {len(taker_trades['items'])}")
Last updated on