curl --request GET \
--url https://test.deribit.com/api/v2/public/get_last_trades_by_instrument_and_time \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 3983,
"method": "public/get_last_trades_by_instrument_and_time",
"params": {
"instrument_name": "ETH-PERPETUAL",
"end_timestamp": 1590480022768,
"count": 1
}
}
'import requests
url = "https://test.deribit.com/api/v2/public/get_last_trades_by_instrument_and_time"
payload = {
"jsonrpc": "2.0",
"id": 3983,
"method": "public/get_last_trades_by_instrument_and_time",
"params": {
"instrument_name": "ETH-PERPETUAL",
"end_timestamp": 1590480022768,
"count": 1
}
}
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: 3983,
method: 'public/get_last_trades_by_instrument_and_time',
params: {instrument_name: 'ETH-PERPETUAL', end_timestamp: 1590480022768, count: 1}
})
};
fetch('https://test.deribit.com/api/v2/public/get_last_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/public/get_last_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' => 3983,
'method' => 'public/get_last_trades_by_instrument_and_time',
'params' => [
'instrument_name' => 'ETH-PERPETUAL',
'end_timestamp' => 1590480022768,
'count' => 1
]
]),
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/public/get_last_trades_by_instrument_and_time"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 3983,\n \"method\": \"public/get_last_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"ETH-PERPETUAL\",\n \"end_timestamp\": 1590480022768,\n \"count\": 1\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/public/get_last_trades_by_instrument_and_time")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 3983,\n \"method\": \"public/get_last_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"ETH-PERPETUAL\",\n \"end_timestamp\": 1590480022768,\n \"count\": 1\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://test.deribit.com/api/v2/public/get_last_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\": 3983,\n \"method\": \"public/get_last_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"ETH-PERPETUAL\",\n \"end_timestamp\": 1590480022768,\n \"count\": 1\n }\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 1469,
"result": {
"trades": [
{
"trade_seq": 467,
"trade_id": "415305279",
"timestamp": 1770984454552,
"tick_direction": 2,
"price": 0.0525,
"mark_price": 0.05253883,
"iv": 45.91,
"instrument_name": "BTC-24APR26-72000-C",
"index_price": 66930.31,
"direction": "buy",
"amount": 3,
"contracts": 3
}
],
"has_more": true
}
}public/get_last_trades_by_instrument_and_time
Retrieves the latest trades that have occurred for a specific instrument within a specified time range. Returns trade details including price, amount, direction, timestamp, and trade ID.
Use the count parameter to limit the number of trades returned, and sorting to control the order (ascending or descending by trade ID). This method is useful for analyzing trading activity over specific time periods.
curl --request GET \
--url https://test.deribit.com/api/v2/public/get_last_trades_by_instrument_and_time \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 3983,
"method": "public/get_last_trades_by_instrument_and_time",
"params": {
"instrument_name": "ETH-PERPETUAL",
"end_timestamp": 1590480022768,
"count": 1
}
}
'import requests
url = "https://test.deribit.com/api/v2/public/get_last_trades_by_instrument_and_time"
payload = {
"jsonrpc": "2.0",
"id": 3983,
"method": "public/get_last_trades_by_instrument_and_time",
"params": {
"instrument_name": "ETH-PERPETUAL",
"end_timestamp": 1590480022768,
"count": 1
}
}
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: 3983,
method: 'public/get_last_trades_by_instrument_and_time',
params: {instrument_name: 'ETH-PERPETUAL', end_timestamp: 1590480022768, count: 1}
})
};
fetch('https://test.deribit.com/api/v2/public/get_last_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/public/get_last_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' => 3983,
'method' => 'public/get_last_trades_by_instrument_and_time',
'params' => [
'instrument_name' => 'ETH-PERPETUAL',
'end_timestamp' => 1590480022768,
'count' => 1
]
]),
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/public/get_last_trades_by_instrument_and_time"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 3983,\n \"method\": \"public/get_last_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"ETH-PERPETUAL\",\n \"end_timestamp\": 1590480022768,\n \"count\": 1\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/public/get_last_trades_by_instrument_and_time")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 3983,\n \"method\": \"public/get_last_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"ETH-PERPETUAL\",\n \"end_timestamp\": 1590480022768,\n \"count\": 1\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://test.deribit.com/api/v2/public/get_last_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\": 3983,\n \"method\": \"public/get_last_trades_by_instrument_and_time\",\n \"params\": {\n \"instrument_name\": \"ETH-PERPETUAL\",\n \"end_timestamp\": 1590480022768,\n \"count\": 1\n }\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 1469,
"result": {
"trades": [
{
"trade_seq": 467,
"trade_id": "415305279",
"timestamp": 1770984454552,
"tick_direction": 2,
"price": 0.0525,
"mark_price": 0.05253883,
"iv": 45.91,
"instrument_name": "BTC-24APR26-72000-C",
"index_price": 66930.31,
"direction": "buy",
"amount": 3,
"contracts": 3
}
],
"has_more": true
}
}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 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
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.
Mark Price at the moment of trade
Trade size in contract units (optional, may be absent in historical trades)
Option implied volatility for the price (Option 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 Block trade id - when trade was part of a block trade
"154"
Block trade leg count - when trade was part of a block trade
3
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
ID of the Block RFQ - when trade was part of the Block RFQ
The id that was sent in the request
Was this page helpful?