curl --request GET \
--url https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 276,
"method": "private/get_user_trades_by_instrument_and_time",
"params": {
"instrument_name": "BTC-PERPETUAL",
"start_timestamp": 1590470872894,
"end_timestamp": 1590480872894,
"count": 2
}
}
'import requests
url = "https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time"
payload = {
"jsonrpc": "2.0",
"id": 276,
"method": "private/get_user_trades_by_instrument_and_time",
"params": {
"instrument_name": "BTC-PERPETUAL",
"start_timestamp": 1590470872894,
"end_timestamp": 1590480872894,
"count": 2
}
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: 276,
method: 'private/get_user_trades_by_instrument_and_time',
params: {
instrument_name: 'BTC-PERPETUAL',
start_timestamp: 1590470872894,
end_timestamp: 1590480872894,
count: 2
}
})
};
fetch('https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => 276,
'method' => 'private/get_user_trades_by_instrument_and_time',
'params' => [
'instrument_name' => 'BTC-PERPETUAL',
'start_timestamp' => 1590470872894,
'end_timestamp' => 1590480872894,
'count' => 2
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 276,\n \"method\": \"private/get_user_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"BTC-PERPETUAL\",\n \"start_timestamp\": 1590470872894,\n \"end_timestamp\": 1590480872894,\n \"count\": 2\n }\n}")
req, _ := http.NewRequest("GET", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 276,\n \"method\": \"private/get_user_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"BTC-PERPETUAL\",\n \"start_timestamp\": 1590470872894,\n \"end_timestamp\": 1590480872894,\n \"count\": 2\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": 276,\n \"method\": \"private/get_user_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"BTC-PERPETUAL\",\n \"start_timestamp\": 1590470872894,\n \"end_timestamp\": 1590480872894,\n \"count\": 2\n }\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 9292,
"result": {
"trades": [
{
"underlying_price": 8994.95,
"trade_seq": 1,
"trade_id": "48078936",
"timestamp": 1590480620145,
"tick_direction": 1,
"state": "filled",
"reduce_only": false,
"price": 0.028,
"post_only": false,
"order_type": "limit",
"order_id": "4008699030",
"matching_id": null,
"mark_price": 0.03135383,
"liquidity": "M",
"iv": 38.51,
"instrument_name": "BTC-27MAY20-8750-C",
"index_price": 8993.47,
"fee_currency": "BTC",
"fee": 0.0004,
"direction": "sell",
"amount": 1
},
{
"trade_seq": 299513,
"trade_id": "47958936",
"timestamp": 1589923311862,
"tick_direction": 2,
"state": "filled",
"reduce_only": false,
"price": 9681.5,
"post_only": false,
"order_type": "limit",
"order_id": "3993343822",
"matching_id": null,
"mark_price": 9684,
"liquidity": "M",
"instrument_name": "BTC-26JUN20",
"index_price": 9679.48,
"fee_currency": "BTC",
"fee": -2.1e-7,
"direction": "buy",
"amount": 10
}
],
"has_more": false
}
}private/get_user_trades_by_instrument_and_time
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
curl --request GET \
--url https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 276,
"method": "private/get_user_trades_by_instrument_and_time",
"params": {
"instrument_name": "BTC-PERPETUAL",
"start_timestamp": 1590470872894,
"end_timestamp": 1590480872894,
"count": 2
}
}
'import requests
url = "https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time"
payload = {
"jsonrpc": "2.0",
"id": 276,
"method": "private/get_user_trades_by_instrument_and_time",
"params": {
"instrument_name": "BTC-PERPETUAL",
"start_timestamp": 1590470872894,
"end_timestamp": 1590480872894,
"count": 2
}
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: 276,
method: 'private/get_user_trades_by_instrument_and_time',
params: {
instrument_name: 'BTC-PERPETUAL',
start_timestamp: 1590470872894,
end_timestamp: 1590480872894,
count: 2
}
})
};
fetch('https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => 276,
'method' => 'private/get_user_trades_by_instrument_and_time',
'params' => [
'instrument_name' => 'BTC-PERPETUAL',
'start_timestamp' => 1590470872894,
'end_timestamp' => 1590480872894,
'count' => 2
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 276,\n \"method\": \"private/get_user_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"BTC-PERPETUAL\",\n \"start_timestamp\": 1590470872894,\n \"end_timestamp\": 1590480872894,\n \"count\": 2\n }\n}")
req, _ := http.NewRequest("GET", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 276,\n \"method\": \"private/get_user_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"BTC-PERPETUAL\",\n \"start_timestamp\": 1590470872894,\n \"end_timestamp\": 1590480872894,\n \"count\": 2\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": 276,\n \"method\": \"private/get_user_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"BTC-PERPETUAL\",\n \"start_timestamp\": 1590470872894,\n \"end_timestamp\": 1590480872894,\n \"count\": 2\n }\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 9292,
"result": {
"trades": [
{
"underlying_price": 8994.95,
"trade_seq": 1,
"trade_id": "48078936",
"timestamp": 1590480620145,
"tick_direction": 1,
"state": "filled",
"reduce_only": false,
"price": 0.028,
"post_only": false,
"order_type": "limit",
"order_id": "4008699030",
"matching_id": null,
"mark_price": 0.03135383,
"liquidity": "M",
"iv": 38.51,
"instrument_name": "BTC-27MAY20-8750-C",
"index_price": 8993.47,
"fee_currency": "BTC",
"fee": 0.0004,
"direction": "sell",
"amount": 1
},
{
"trade_seq": 299513,
"trade_id": "47958936",
"timestamp": 1589923311862,
"tick_direction": 2,
"state": "filled",
"reduce_only": false,
"price": 9681.5,
"post_only": false,
"order_type": "limit",
"order_id": "3993343822",
"matching_id": null,
"mark_price": 9684,
"liquidity": "M",
"instrument_name": "BTC-26JUN20",
"index_price": 9679.48,
"fee_currency": "BTC",
"fee": -2.1e-7,
"direction": "buy",
"amount": 10
}
],
"has_more": false
}
}Query Parameters
Instrument name Unique instrument identifier
"BTC-PERPETUAL"
The earliest timestamp to return result from (milliseconds since the UNIX epoch). When param is provided trades are returned from the earliest The timestamp (milliseconds since the Unix epoch)
1536569522277
The most recent timestamp to return result from (milliseconds since the UNIX epoch). Only one of params: start_timestamp, end_timestamp is truly required The timestamp (milliseconds since the Unix epoch)
1536569522277
Number of requested items, default - 10, maximum - 1000
1 <= x <= 1000Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)
asc, desc, default 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
Id of a subaccount
9
Response
Success response
The JSON-RPC version (2.0)
2.0 Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Unique (per currency) trade identifier
The sequence number of the trade within instrument
Unique instrument identifier
"BTC-PERPETUAL"
The timestamp of the trade (milliseconds since the UNIX epoch)
1517329113791
Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
Always null
Trade direction of the taker
buy, sell Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
0, 1, 2, 3 Index Price at the moment of trade
The price of the trade
Trade amount. For perpetual and inverse futures the amount is in USD units. For options and linear futures it is the underlying base currency coin.
User's fee in units of the specified fee_currency
Currency, i.e "BTC", "ETH", "USDC"
BTC, ETH, USDC, USDT, EURR Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
open, filled, rejected, cancelled, untriggered, archive Mark Price at the moment of trade
Order type: "limit, "market", or "liquidation"
limit, market, liquidation Advanced type of user order: "usd" or "implv" (only for options; omitted if not applicable)
usd, implv Trade size in contract units (optional, may be absent in historical trades)
Option implied volatility for the price (Option only)
Underlying price for implied volatility calculations (Options only)
Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
M, T, MT Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
M, T User defined label (presented only when previously set for order by user)
Block trade id - when trade was part of a block trade
"154"
ID of the Block RFQ - when trade was part of the Block RFQ
ID of the Block RFQ quote - when trade was part of the Block RFQ
true if user order is reduce-only
true if user order is post-only
true if user order is MMP
true if user order is marked by the platform as a risk reducing order (can apply only to orders placed by PM users)
true if user order was created with API
Profit and loss in base currency.
Optional field containing leg trades if trade is a combo trade (present when querying for only combo trades and in combo_trades events)
Optional field containing combo instrument name if the trade is a combo trade
Optional field containing combo trade identifier if the trade is a combo trade
QuoteSet of the user order (optional, present only for orders placed with private/mass_quote)
QuoteID of the user order (optional, present only for orders placed with private/mass_quote)
List of allocations for Block RFQ pre-allocation. Each allocation specifies user_id, amount, and fee for the allocated part of the trade. For broker client allocations, a client_info object will be included.
Hide child attributes
Hide child attributes
Amount allocated to this user.
Fee for the allocated part of the trade.
User ID to which part of the trade is allocated. For brokers the User ID is obstructed.
Optional client allocation info for brokers.
Hide child attributes
Hide child attributes
ID of a client; available to broker. Represents a group of users under a common name.
ID assigned to a single user in a client; available to broker.
Name of the linked user within the client; available to broker.
The id that was sent in the request
Was this page helpful?