Skip to content

Get Trades

Retrieve trade execution history (fills) from Synthetix's orderbook. Each trade represents a filled order or partial fill that has been executed. Returns trades for the specified subaccount.

Endpoint

POST https://papi.synthetix.io/v1/trade

Request

Request Format

{
  "params": {
    "action": "getTrades",
    "subAccountId": "1867542890123456789",
    "symbol": "BTC-USDT",
    "limit": 100,
    "offset": 0,
    "startTime": 1730678400000,
    "endTime": 1730764800000
  },
  "nonce": 1704067200000,
  "expiresAfter": 1704067300000,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

Request Parameters

Action Parameters

ParameterTypeRequiredDescription
paramsobjectYesRequest parameters wrapper
params.actionstringYesMust be "getTrades"
params.subAccountIdstringYesSubAccount ID to retrieve trades for
params.symbolstringNoFilter trades by market symbol (e.g., "BTC-USDT")
params.limitintegerNoMaximum number of trades to return (default: 100, max: 1000)
params.offsetintegerNoNumber of trades to skip for pagination (default: 0)
params.startTimeintegerNoStart timestamp in milliseconds (inclusive)
params.endTimeintegerNoEnd timestamp in milliseconds (inclusive)

Common Request Parameters

ParameterTypeRequiredDescription
nonceuint64YesUnix milliseconds timestamp (must be monotonically increasing)
signatureobjectYesEIP-712 signature object
expiresAfteruint64NoUnix milliseconds expiration timestamp (5x rate limit on stale cancels)
ParameterTypeRequiredDescription
expiresAfterintegerNoOptional expiration timestamp in milliseconds

Response

Response Structure

FieldTypeDescription
statusstringAlways "ok" for successful requests or "error" for failures
responseobjectResponse object containing trades array and pagination info (omitted when status is "error")
response.tradesarrayArray of trade objects matching filter criteria
response.hasMorebooleanWhether more trades exist beyond current result
response.totalintegerTotal number of trades matching the query
errorobjectError details (only present when status is "error")
request_idstringRequest tracking identifier
timestampstringRFC3339 timestamp

Success Response Examples

Multiple Trades with Various Details

{
  "status": "ok",
  "response": {
    "trades": [
      {
        "tradeId": "123456789",
        "orderId": "1948058938469519360",
        "clientOrderId": "0x1234567890abcdef1234567890abcdef",
        "symbol": "BTC-USDT",
        "side": "buy",
        "direction": "LONG",
        "price": "50000.50",
        "quantity": "0.1",
        "realizedPnl": "125.50",
        "fee": "5.00",
        "feeRate": "0.001",
        "markPrice": "50025.00",
        "entryPrice": "49500.00",
        "timestamp": 1704067200500,
        "maker": false,
        "reduceOnly": false,
        "triggeredByLiquidation": false
      },
      {
        "tradeId": "123456790",
        "orderId": "1948058938469519361",
        "clientOrderId": "0x9876543210fedcba9876543210fedcba",
        "symbol": "ETH-USDT",
        "side": "sell",
        "direction": "SHORT",
        "price": "2999.25",
        "quantity": "1.5",
        "realizedPnl": "-75.25",
        "fee": "4.50",
        "feeRate": "0.001",
        "markPrice": "3000.00",
        "entryPrice": "2950.00",
        "timestamp": 1704067201000,
        "maker": true,
        "reduceOnly": true,
        "triggeredByLiquidation": false
      },
      {
        "tradeId": "123456791",
        "orderId": "1948058938469519362",
        "clientOrderId": "",
        "symbol": "BTC-USDT",
        "side": "sell",
        "direction": "SHORT",
        "price": "49500.00",
        "quantity": "0.05",
        "realizedPnl": "0.00",
        "fee": "2.48",
        "feeRate": "0.001",
        "markPrice": "49450.00",
        "entryPrice": "50000.00",
        "timestamp": 1704067201500,
        "maker": false,
        "reduceOnly": false,
        "triggeredByLiquidation": true
      }
    ],
    "hasMore": false,
    "total": 3
  },
  "request_id": "5ccf215d37e3ae6d",
  "timestamp": "2025-01-01T00:00:00Z"
}

Single Symbol Filter

{
  "status": "ok",
  "response": {
    "trades": [
      {
        "tradeId": "123456792",
        "orderId": "1948058938469519363",
        "clientOrderId": "",
        "symbol": "BTC-USDT",
        "side": "buy",
        "direction": "LONG",
        "price": "50250.00",
        "quantity": "0.2",
        "realizedPnl": "50.00",
        "fee": "10.05",
        "feeRate": "0.001",
        "markPrice": "50275.00",
        "entryPrice": "50100.00",
        "timestamp": 1704067202000,
        "maker": false,
        "reduceOnly": false,
        "triggeredByLiquidation": false
      }
    ],
    "hasMore": true,
    "total": 150
  },
  "request_id": "5ccf215d37e3ae6e",
  "timestamp": "2025-01-01T00:00:00Z"
}

Empty Result Set

{
  "status": "ok",
  "response": {
    "trades": [],
    "hasMore": false,
    "total": 0
  },
  "request_id": "5ccf215d37e3ae6f",
  "timestamp": "2025-01-01T00:00:00Z"
}

Trade Object

FieldTypeDescription
tradeIdstringUnique trade execution identifier
orderIdstringAssociated order ID
clientOrderIdstringClient-provided order ID (if exists)
symbolstringMarket symbol (e.g., "BTC-USDT")
sidestringTrade side: "buy" or "sell"
pricestringActual filled price of this trade
quantitystringActual filled quantity of this trade
realizedPnlstringRealized P&L from position closure
feestringTrading fee amount
feeRatestringFee rate applied
timestampintegerTrade timestamp (Unix milliseconds)
makerbooleantrue if maker order, false if taker
reduceOnlybooleantrue if trade reduced existing position
postOnlybooleantrue if order was post-only (maker-only)
markPricestringMark price at time of trade
entryPricestringPosition average entry price at time of trade
triggeredByLiquidationbooleantrue if triggered by liquidation
directionstringPosition direction after trade

Trade Field Explanations

FieldDescription
tradeIdUnique identifier for this specific trade execution
orderIdOrder that generated this trade
clientOrderIdOptional client-specified order identifier
priceActual execution price at which this trade was filled (not the mark price or entry price)
quantityActual filled quantity for this trade execution
realizedPnlProfit/loss realized from this trade
feeTrading fee charged for this execution
feeRateFee rate applied (maker/taker rate)
markPriceMark price at time of trade execution (used for unrealized P&L and liquidations)
entryPricePosition's average entry price at time of trade (weighted average of all entries)
isMakerWhether this trade provided liquidity (maker) or took liquidity (taker)
reduceOnlyWhether this trade reduced an existing position
liquidationWhether this trade was part of a liquidation

Error Response

{
  "status": "error",
  "error": {
    "message": "Invalid time range: startTime must be less than or equal to endTime",
    "code": "VALIDATION_ERROR"
  },
  "request_id": "5ccf215d37e3ae6d",
  "timestamp": "2025-01-01T00:00:00Z"
}

Examples

Get Recent Trades (Own Account)

{
  "params": {
    "action": "getTrades",
    "subAccountId": "1867542890123456789",
    "limit": 50
  },
  "nonce": 1704067200000,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

Filter by Symbol

{
  "params": {
    "action": "getTrades",
    "subAccountId": "1867542890123456789",
    "symbol": "ETH-USDT",
    "limit": 100
  },
  "nonce": 1704067200000,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

Sorting

Trades are returned in descending order by timestamp (newest first).

Implementation Notes

  • Subaccount parameter required for trade retrieval scope
  • Time range cannot exceed 30 days (2,592,000,000 milliseconds)
  • Pagination supports up to 1000 trades per request (default: 100)
  • Time filtering uses inclusive millisecond timestamp bounds
  • Symbol filtering reduces response size for multi-market accounts
  • Trade identification uses unique tradeId with order linking via orderId
  • Position tracking available through startPosition and endPosition fields

Trade Types

Regular Trades

Standard trades from limit or market orders:

  • Contains standard execution information
  • May be partial fills (group by orderId to see all fills for the same order)

Liquidation Trades

Forced trades due to insufficient margin:

  • Contains liquidation object with additional details
  • liquidatedUser identifies the account that was liquidated
  • method indicates how the liquidation was executed

Maker vs Taker

  • Maker: Order added liquidity to the orderbook (maker: true)
    • Typically receives fee rebate or reduced fees
  • Taker: Order removed liquidity from the orderbook (maker: false)
    • Typically pays higher fees

Error Handling

Common Errors

ErrorDescriptionSolution
Invalid time rangeStart time is after end time, or time range exceeds 30 daysEnsure startTime < endTime and range ≤ 30 days
Invalid limitLimit exceeds maximumUse limit ≤ 1000
Invalid offsetNegative offset valueUse offset ≥ 0
Invalid symbolMarket symbol not recognizedCheck available markets
Authentication failedInvalid signatureVerify signature generation
Unauthorized accessNo permission for specified subAccountIdEnsure you have access to the specified subaccount

Rate Limiting

  • Each request counts as 1 against rate limits
  • Large queries (high limits) may have higher weight
  • Consider caching trade history for frequently accessed data
  • See Rate Limits for details

Next Steps