---
title: "Get user trade history"
method: GET
path: "/api/v1/trade_history"
tags: ["Account"]
---

# Get user trade history

`GET /api/v1/trade_history`

Retrieve trade history for a specific user with optional filtering by market, order ID, side,
and timestamp range. Returns executed trades with price, size, PnL, and fee details.
Supports sorting by timestamp (default: descending) and pagination. Page size is capped at 200.

## Query parameters

- `account` string, required
- `order_id` string
- `market` string
- `side` 'buy' | 'sell' — Order side filter: buy (long) or sell (short). For orders, maps to `is_buy` column. For trades/funding, maps to `action IN ('OpenLong','CloseShort')` (buy) or `action IN ('CloseLong','OpenShort')` (sell).
- `limit` integer
- `offset` integer
- `start_timestamp` integer
- `end_timestamp` integer
- `sort_key` 'timestamp' — Sort key for history endpoints
- `sort_dir` 'ASC' | 'DESC'

## Response `200`

Trade history retrieved successfully

- PaginatedResponseTradeDto
  - `items` object[], required — The items in the current page
    - `account` string, required — User's account address
    - `action` string, required — Trade action type (e.g., "buy", "sell", "liquidation")
    - `client_order_id` string, required — Client-specified order ID
    - `counter_party_account` string, required — Counter party account on the other leg of the fill. For liquidation / ADL / delisting fills this is the backstop liquidator. Empty string for pre-V2 historical trades that did not carry counter party on-chain.
    - `fee_amount` number, double, required — Fee amount in raw units
    - `is_profit` boolean, required — Whether trade was profitable
    - `is_rebate` boolean, required — Whether trade received rebate
    - `market` string, required — Market identifier address
    - `order_id` string, required — Order ID associated with trade
    - `price` number, double, required — Trade price
    - `realized_funding_amount` number, double, required — Realized funding amount in USDC - Negative value: trader PAID funding (e.g., long position with positive funding rate) - Positive value: trader RECEIVED funding (e.g., short position with positive funding rate) - Zero: no funding accrued
    - `realized_pnl_amount` number, double, required — Realized PnL amount
    - `size` number, double, required — Trade size
    - `source` string, required — Trade source (e.g., "OrderFill", "MarginCall", "BackStopLiquidation", "ADL", "MarketDelisted")
    - `trade_id` string, required — Trade ID
    - `transaction_unix_ms` integer, required — Transaction timestamp in milliseconds
    - `transaction_version` integer, required — Transaction version
  - `total_count` integer, nullable — The total number of items across all pages. Optional: history endpoints omit this field to avoid expensive COUNT(*) queries.

## Other responses

- `400` — Invalid parameters (order_id requires market)
- `500` — Database error

---

[API](https://skmtc.net/decibel/apis/decibel-trading-api.md) · [All operations](https://skmtc.net/decibel/apis/decibel-trading-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/decibel/decibel-trading-api/versions/37a02083ff59/schema)
