Skip to content

Get Orders History

Retrieve orders history for the authenticated subaccount with comprehensive filtering, sorting, and pagination capabilities, providing access to orders in any status with flexible query options.

Endpoint

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

Request

Request Format

{
  "params": {
    "action": "getOrderHistory",
    "subAccountId": "1867542890123456789",
    "status": ["placed", "filled"],
    "fromTime": 1730160000000,
    "toTime": 1730764800000,
    "limit": 100
  },
  "nonce": 1704067200000,
  "signature": {
    "v": 28,
    "r": "0x19480589384695193600abcdef19480589384695193600abcdef19480589384695193600abcdef19480589384695193600abcdef",
    "s": "0xabcdef19480589384695193600abcdef19480589384695193600abcdef19480589384695193600abcdef19480589384695193600"
  }
}

Request Parameters

ParameterTypeRequiredDescription
paramsobjectYesRequest parameters wrapper
params.actionstringYesMust be "getOrderHistory"
params.subAccountIdstringYesSubAccount ID to retrieve orders for
params.statusstring[]NoFilter by order status: ["started", "placed", "partially filled", "filled", "cancelling", "cancelled", "rejected", "modifying", "modified", "unknown"]
params.fromTimeintegerNoStart timestamp in milliseconds (inclusive). Max 7-day range
params.toTimeintegerNoEnd timestamp in milliseconds (inclusive). Max 7-day range
params.limitintegerNoMaximum number of orders to return (default: 50, max: 1000)
ParameterTypeRequiredDescription
nonceuint64YesUnix milliseconds timestamp (must be monotonically increasing)
signatureobjectYesEIP-712 signature object
expiresAfteruint64NoUnix milliseconds expiration timestamp (5x rate limit on stale cancels)

Filter Combinations

The endpoint supports powerful filter combinations:

  • All Orders: Omit status to get orders in any status
  • Historical Orders: "status": ["filled", "cancelled"] with time range
  • Recent Activity: Use fromTime without toTime for orders since a specific time
  • Symbol-Specific: Combine symbol with any other filters

Response

Response Structure

FieldTypeDescription
statusstringAlways "ok" for successful requests or "error" for failures
responsearrayArray of order objects matching filter criteria (omitted when status is "error")
errorobjectError details (only present when status is "error")
requestIdstringRequest tracking identifier
timestampintegerUnix milliseconds timestamp

Success Response Examples

Multiple Orders with Various Statuses

{
  "status": "ok",
  "response": [
    {
      "orderId": "1958787130134106112",
      "symbol": "BTC-USDT",
      "side": "buy",
      "type": "LIMIT",
      "status": "FILLED",
      "quantity": "0.1",
      "price": "45000.00",
      "timeInForce": "GTC",
      "createdTime": 1755846234000,
      "filledQuantity": "0.1",
      "filledPrice": "44998.50",
      "triggeredByLiquidation": false
    },
    {
      "orderId": "1958787130134106113",
      "symbol": "ETH-USDT",
      "side": "sell",
      "type": "LIMIT",
      "status": "PARTIALLY_FILLED",
      "quantity": "2.0",
      "price": "2800.00",
      "triggerPrice": "",
      "triggerPriceType": "",
      "timeInForce": "GTC",
      "reduceOnly": false,
      "postOnly": false,
      "closePosition": false,
      "createdTime": 1755846235000,
      "filledQuantity": "0.5",
      "filledPrice": "2801.25",
      "triggeredByLiquidation": false
    },
    {
      "orderId": "1958787130134106114",
      "symbol": "BTC-USDT",
      "side": "buy",
      "type": "LIMIT",
      "status": "NEW",
      "timeInForce": "GTC",
      "quantity": "0.05",
      "price": "44000.00",
      "triggerPrice": "",
      "triggerPriceType": "",
      "reduceOnly": false,
      "postOnly": false,
      "closePosition": false,
      "createdTime": 1755846236000,
      "filledQuantity": "0.0",
      "filledPrice": "0.0",
      "triggeredByLiquidation": false
    }
  ],
  "request_id": "5ccf215d37e3ae6d",
  "timestamp": "2025-01-01T00:00:00Z"
}

Empty Result Set

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

Order Object

FieldTypeDescription
orderIdstringUnique order identifier (64-bit unsigned integer as string)
clientOrderIdstringClient-provided order identifier (128-bit hex string with 0x prefix)
symbolstringTrading pair symbol (e.g., "BTC-USDT")
sidestringOrder side: "buy" or "sell"
typestringOrder type: "LIMIT", "MARKET", "STOP_LOSS", "TAKE_PROFIT"
quantitystringOriginal order quantity
pricestringOrder price (empty for market orders)
triggerPricestringTrigger price for conditional orders
triggerPriceTypestringTrigger price type: "mark", "last", or "index"
timeInForcestringTime in force: "GTC", "IOC", or "FOK"
reduceOnlybooleanWhether order only reduces existing position
postOnlybooleanWhether order must be maker (no immediate match)
createdTimeintegerOrder creation timestamp (Unix seconds)
updatedTimeintegerLast update timestamp (Unix seconds)
filledQuantitystringQuantity that has been filled
takeProfitOrderIdstringID of linked take-profit order (if exists)
stopLossOrderIdstringID of linked stop-loss order (if exists)
closePositionbooleanWhether order closes entire position

Error Response

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

Advanced Filtering

Time-based Queries

// Orders from last 24 hours
"fromTime": Date.now() - 86400000
 
// Orders in specific date range
"fromTime": 1704067200000,
"toTime": 1704153600000
 
// Orders since specific time (no end)
"fromTime": 1704067200000

Implementation Notes

  • Authentication requires signature by account owner or authorized delegate
  • Time range cannot exceed 30 days (2,592,000,000 milliseconds)
  • Time range filtering supports inclusive bounds with fromTime ≤ toTime validation
  • Pagination: Use limit parameter (default: 50, max: 1000)
  • Status filtering accepts multiple values

Signing

All trading methods are signed using EIP-712. Each successful trading request will contain:

  • A piece of structured data that includes the sender address
  • A signature of the hash of that structured data, signed by the sender

For detailed information on EIP-712 signing, see EIP-712 Signing.

Nonce Management

The nonce system prevents replay attacks and ensures order uniqueness:

  • Use current timestamp in milliseconds as nonce
  • Each nonce must be greater than the previous one
  • Recommended: Use Date.now() or equivalent
  • If nonce conflicts occur, increment by 1 and retry

Error Handling

Common error scenarios:

ErrorDescription
Invalid signatureEIP-712 signature validation failed
Invalid market symbolMarket symbol not recognized
Nonce already usedNonce must be greater than previous value
Rate limit exceededToo many requests in time window
Request expiredexpiresAfter timestamp has passed
ErrorDescription
Invalid request formatRequest payload could not be parsed
Internal errorFailed to retrieve orders
Invalid time rangefromTime is greater than toTime, or time range exceeds 30 days
Invalid statusSpecified status is not recognized
Invalid symbolSpecified symbol is not recognized
Invalid sort fieldSpecified sortBy field is invalid
Invalid paginationLimit or offset out of valid range
Subaccount not foundSpecified subaccount does not exist