Skip to main content

Get Trade Data of an Instrument

API Description

This endpoint allows querying the trade data for a specified instrument, including contract size, direction, ID, timestamp, and price. By default, it will return data for the 20 most recent trades.

Note: Trade data is available via both Resful and Websocket APIs. This page describes the RESTful API. For information on the Websocket API, please click here

Precautions

  1. This interface does not allow users to specify the number of trades to return. By default, it will return the 20 most recent trades.
  2. This interface does not support specifying a time range for querying trade data in specified time interval.

Authentication

This is a public interface and does not require authentication. For details on using the RESTful API, please refer to Introduction > Authentication & Code Snippet > Futures > RESTful Public Interface.

Request Method

GET

Endpoint

/v1/perpumPublic/trades

Frequency Limit

The frequency limit for this interface is 10 requests/2s per user ID and IP. In addition to this per-interface limit, a global rate limit is also enforced.

For detailed information on Global rate limits and API Rate Limiting Policy, please refer to the "Frequency Limit" section at click here

Request Parameters

ParameterMandatoryTypeDescription
basetrueStringThe base currency of the instrument. (e.g., BTC or btc). This parameter is case-insensitive.
Note: For instruments that start with numbers (e.g., 1000PEPE), both uppercase and lowercase formats are valid.

Response Parameters

ParameterTypeDescription
createdDateLongThe timestamp when the trade occurred
pieceStringNumber of contracts
directionStringTrade direction: long, short.
priceStringThe executed transaction price
quantityStringTransaction volume (number of coins)
idLongPrimary key ID

Request Example

The following Python code shows how to get the trade data for BTC.

Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Futures > RESTful Public Interface.

api_url = "/v1/perpumPublic/trades"

params = {"base": "BTC", }
FuturesRestfulPublic(api_url, params) # function FuturesRestfulPublic() is defined in section (Introduction > Authentication & Code Snippet > Futures > RESTful Public Interface)

Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Futures > RESTful Public Interface.

Response Example

The following is an example response returned by the above Python request. The actual response includes data of the 20 most recent trades. For brevity, only 3 trades are shown below:

{
{'code': 0,
'data': [{'createdDate': 1744799567321,
'direction': 'long',
'id': 21320586404543493,
'piece': '21',
'price': '83902.9',
'quantity': '0.021'},
{'createdDate': 1744799566969,
'direction': 'short',
'id': 21320586350672903,
'piece': '562',
'price': '83906.7',
'quantity': '0.562'},
{'createdDate': 1744799566600,
'direction': 'long',
'id': 21320586307943429,
'piece': '30',
'price': '83908.5',
'quantity': '0.03'}......],
'msg': ''}
}