Trading
Private

Retrieves the latest user trades that have occurred for a specific instrument within a specified time range. Returns trade details including price, amount, direction, timestamp, trade ID, and order ID.

Use the count parameter to limit the number of trades returned, and sorting to control the order (ascending or descending by trade ID). Use historical to retrieve historical trade data. This method is useful for analyzing trading activity over specific time periods.

Main accounts may use the subaccount_id parameter to retrieve trade data for a specific subaccount (requires mainaccount scope).

📖 Related Article: Accessing Historical Trades and Orders Using API

Scope: trade:read

Try in API console

get/private/get_user_trades_by_instrument_and_time

Request

  • Base URL
    https://test.deribit.com/api/v2
  • URL
    https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time
  • Auth
    none declared

Query parameters

instrument_namestring required

Unique instrument identifier

Example:BTC-PERPETUAL

Instrument name

start_timestampinteger

The timestamp (milliseconds since the Unix epoch)

Example:1536569522277

Inclusive earliest timestamp (milliseconds since the Unix epoch). Time-based methods require at least one of start_timestamp or end_timestamp.

end_timestampinteger

The timestamp (milliseconds since the Unix epoch)

Example:1536569522277

Inclusive latest timestamp (milliseconds since the Unix epoch). Time-based methods require at least one of start_timestamp or end_timestamp.

countinteger

Number of requested items, default - 10, maximum - 1000

sorting'asc' | 'desc' | 'default'

Result ordering: asc, desc, or the method-specific default.

historicalboolean

Determines whether historical trade and order records should be retrieved.

  • false (default): Returns recent records: orders for 30 min, trades for 24h.
  • true: Fetches historical records, available after a short delay due to indexing. Recent data is not included.

📖 Related Article: Accessing Historical Trades and Orders Using API

subaccount_idinteger
Example:9

Id of a subaccount

Response

Success response

jsonrpc'2.0' required

The JSON-RPC version (2.0)

idinteger

The id that was sent in the request

Example response

{
  "result": {
    "trades": [
      {
        "instrument_name": "BTC-PERPETUAL",
        "timestamp": 1517329113791,
        "starbase_timestamp": 1536569522277000000,
        "starbase_order_id": 103148386170,
        "block_trade_id": "154",
        "block_trade_leg_count": 3
      }
    ]
  }
}

Changes

    • breaking

      the response property /// became nullable for the status

    • breaking

      the response property /// became nullable for the status

    • breaking

      the response property /// became nullable for the status

    • breaking

      the /// response's property type changed from string to boolean for status

    • breaking

      the /// response's property type changed from string to boolean for status

    • info

      the query request parameter end_timestamp became optional

    • info

      the query request parameter start_timestamp became optional

    • info

      added the optional property /// to the response with the status