Get OrderBook
info
Get a list of all open orders for a product.
2 parameters are used for orderbook:
pairSymbolandlimit- If
limitparameter is not set, default 100 orders are listed.
There are 2 possible options:
Without limit parameter | https://api.btcturk.com/api/v2/orderbook?pairSymbol=BTCUSDT | Default 100 orders of BTCUSDT |
With limit parameter | https://api.btcturk.com/api/v2/orderbook?pairSymbol=BTCUSDT&limit=25 | 25 orders of BTCUSDT |
OrderBook
GET https://api.btcturk.com/api/v2/orderbook
Query Parameters
| Name | Type | Description |
|---|---|---|
| pairSymbol | string | BTCTRY, ETHTRY etc. |
| limit | integer | limit the number of results (default 25) |
- 200
{
"success": true,
"message": null,
"code": 0,
"data": {
"timestamp": 1543836448605,
"bids": [
[
"33245.00",
"2.10695265"
],
[
"33209.00",
"0.001"
]
],
"asks": [
[
"33490.00",
"0.03681877"
],
[
"33499.00",
"1.00000000"
]
]
}
Code Example
- C#
- PHP
- Python
- GoLang
- Node.js
- Ruby
// You can download ApiClient .net core complete library from github https://github.com/BTCTrader/broker-api-csharp-v2
var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var publicKey = configuration["publicKey"];
var privateKey = configuration["privateKey"];
var resourceUrl = configuration["resourceUrl"];
var apiClientV1 = new ApiClientV1(publicKey, privateKey, resourceUrl);
var orderbook = apiClientV1.GetOrderBook("BTCTRY");
if (orderbook.Result.Success)
{
var bestBidPrice = orderbook.Result.Data.Bids[0][0];
var bestBidAmount = orderbook.Result.Data.Bids[0][1];
Console.WriteLine("Best bid price:" + bestBidPrice);
Console.WriteLine("Best bid amount:" + bestBidAmount);
}
else
{
Console.WriteLine(orderbook.Result.ToString());
}
<?php
$base = "https://api.btcturk.com";
$method = "/api/v2/orderbook?pairSymbol=BTCTRY&limit=100";
$uri = $base.$method;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_HTTP_VERSION, "CURL_HTTP_VERSION_1_2");
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
if (curl_errno($ch)) {
print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);
import time, base64, hmac, hashlib, requests, json
base = "https://api.btcturk.com"
method = "/api/v2/orderbook?pairSymbol=BTCTRY"
uri = base+method
result = requests.get(url=uri)
result = result.json()
print(json.dumps(result, indent=2))
uri := "https://api.btcturk.com/api/v2/orderbook?pairSymbol=BTCUSDT"
request, _ := http.NewRequest("GET", uri, nil)
request.Header.Add("Content-Type", "application/json")
response, _ := http.DefaultClient.Do(request)
defer response.Body.Close()
body, _ := ioutil.ReadAll(response.Body)
fmt.Println(response)
fmt.Println(string(body))
const base = 'https://api.btcturk.com'
const method = '/api/v2/orderbook?pairSymbol=BTCUSDT'
const uri = base+method;
const options = {method: 'GET', headers: {'Content-type': 'application/json'}};
fetch(uri, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.btcturk.com/api/v2/orderbook?pairSymbol=BTCUSDT")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-type"] = 'application/json'
response = http.request(request)
puts response.read_body
warning
In case of a system failure and delays in real time orderbook data, this endpoint will return HTTP 503 in order to prevent false market data feed to clients.