cURL
curl --request GET \
--url https://drb.coinbase.com/api/v2/public/get_order_book \
--header 'Content-Type: application/json' \
--data '
{
"id": 8772,
"jsonrpc": "2.0",
"method": "public/get_order_book",
"params": {
"depth": 5,
"instrument_name": "BTC-PERPETUAL"
}
}
'import requests
url = "https://drb.coinbase.com/api/v2/public/get_order_book"
payload = {
"id": 8772,
"jsonrpc": "2.0",
"method": "public/get_order_book",
"params": {
"depth": 5,
"instrument_name": "BTC-PERPETUAL"
}
}
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({
id: 8772,
jsonrpc: '2.0',
method: 'public/get_order_book',
params: {depth: 5, instrument_name: 'BTC-PERPETUAL'}
})
};
fetch('https://drb.coinbase.com/api/v2/public/get_order_book', 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://drb.coinbase.com/api/v2/public/get_order_book",
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([
'id' => 8772,
'jsonrpc' => '2.0',
'method' => 'public/get_order_book',
'params' => [
'depth' => 5,
'instrument_name' => 'BTC-PERPETUAL'
]
]),
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://drb.coinbase.com/api/v2/public/get_order_book"
payload := strings.NewReader("{\n \"id\": 8772,\n \"jsonrpc\": \"2.0\",\n \"method\": \"public/get_order_book\",\n \"params\": {\n \"depth\": 5,\n \"instrument_name\": \"BTC-PERPETUAL\"\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://drb.coinbase.com/api/v2/public/get_order_book")
.header("Content-Type", "application/json")
.body("{\n \"id\": 8772,\n \"jsonrpc\": \"2.0\",\n \"method\": \"public/get_order_book\",\n \"params\": {\n \"depth\": 5,\n \"instrument_name\": \"BTC-PERPETUAL\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://drb.coinbase.com/api/v2/public/get_order_book")
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 \"id\": 8772,\n \"jsonrpc\": \"2.0\",\n \"method\": \"public/get_order_book\",\n \"params\": {\n \"depth\": 5,\n \"instrument_name\": \"BTC-PERPETUAL\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 8772,
"jsonrpc": "2.0",
"result": {
"asks": [],
"best_ask_amount": 0,
"best_ask_price": 0,
"best_bid_amount": 30,
"best_bid_price": 3955.75,
"bids": [
[
3955.75,
30
],
[
3940.75,
102020
],
[
3423,
42840
]
],
"change_id": 474988,
"current_funding": 0.00500063,
"funding_8h": 0.00455263,
"index_price": 3910.46,
"instrument_name": "BTC-PERPETUAL",
"last_price": 3955.75,
"mark_price": 3931.97,
"max_price": 3971.74,
"min_price": 3932.22,
"open_interest": 45.27600333464605,
"settlement_price": 3925.85,
"state": "open",
"stats": {
"high": 3976.25,
"low": 3940.75,
"price_change": 0.6913,
"volume": 93.35589552
},
"timestamp": 1550757626706
}
}Market Data
public/get_order_book
Retrieves the order book (bids and asks) for a given instrument, along with other market values such as best bid/ask prices, last trade price, mark price, and index price.
The order book depth can be controlled using the depth parameter, which accepts values from 1 to 10000. The response includes price levels sorted by price (bids descending, asks ascending).
GET
/
public
/
get_order_book
cURL
curl --request GET \
--url https://drb.coinbase.com/api/v2/public/get_order_book \
--header 'Content-Type: application/json' \
--data '
{
"id": 8772,
"jsonrpc": "2.0",
"method": "public/get_order_book",
"params": {
"depth": 5,
"instrument_name": "BTC-PERPETUAL"
}
}
'import requests
url = "https://drb.coinbase.com/api/v2/public/get_order_book"
payload = {
"id": 8772,
"jsonrpc": "2.0",
"method": "public/get_order_book",
"params": {
"depth": 5,
"instrument_name": "BTC-PERPETUAL"
}
}
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({
id: 8772,
jsonrpc: '2.0',
method: 'public/get_order_book',
params: {depth: 5, instrument_name: 'BTC-PERPETUAL'}
})
};
fetch('https://drb.coinbase.com/api/v2/public/get_order_book', 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://drb.coinbase.com/api/v2/public/get_order_book",
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([
'id' => 8772,
'jsonrpc' => '2.0',
'method' => 'public/get_order_book',
'params' => [
'depth' => 5,
'instrument_name' => 'BTC-PERPETUAL'
]
]),
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://drb.coinbase.com/api/v2/public/get_order_book"
payload := strings.NewReader("{\n \"id\": 8772,\n \"jsonrpc\": \"2.0\",\n \"method\": \"public/get_order_book\",\n \"params\": {\n \"depth\": 5,\n \"instrument_name\": \"BTC-PERPETUAL\"\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://drb.coinbase.com/api/v2/public/get_order_book")
.header("Content-Type", "application/json")
.body("{\n \"id\": 8772,\n \"jsonrpc\": \"2.0\",\n \"method\": \"public/get_order_book\",\n \"params\": {\n \"depth\": 5,\n \"instrument_name\": \"BTC-PERPETUAL\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://drb.coinbase.com/api/v2/public/get_order_book")
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 \"id\": 8772,\n \"jsonrpc\": \"2.0\",\n \"method\": \"public/get_order_book\",\n \"params\": {\n \"depth\": 5,\n \"instrument_name\": \"BTC-PERPETUAL\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 8772,
"jsonrpc": "2.0",
"result": {
"asks": [],
"best_ask_amount": 0,
"best_ask_price": 0,
"best_bid_amount": 30,
"best_bid_price": 3955.75,
"bids": [
[
3955.75,
30
],
[
3940.75,
102020
],
[
3423,
42840
]
],
"change_id": 474988,
"current_funding": 0.00500063,
"funding_8h": 0.00455263,
"index_price": 3910.46,
"instrument_name": "BTC-PERPETUAL",
"last_price": 3955.75,
"mark_price": 3931.97,
"max_price": 3971.74,
"min_price": 3932.22,
"open_interest": 45.27600333464605,
"settlement_price": 3925.85,
"state": "open",
"stats": {
"high": 3976.25,
"low": 3940.75,
"price_change": 0.6913,
"volume": 93.35589552
},
"timestamp": 1550757626706
}
}Query Parameters
The instrument name for which to retrieve the order book, see public/get_instruments to obtain instrument names.
Example:
"BTC-PERPETUAL"
The number of entries to return for bids and asks, maximum - 10000.
Available options:
1, 5, 10, 20, 50, 100, 1000, 10000 Example:
5
Was this page helpful?
⌘I