NAV Navbar
c# py php

Introduction

Welcome to Btcturk API for trader and developers.

We have language bindings in C#, Python and PHP! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

General Information

Authentication

This API supports two types of authentication:

Authentication V1

To authorize, use the following code:

var apiKey = YOUR_API_PUBLIC_KEY;
var apiSecret = YOUR_API_SECRET;
var nonce = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliSeconds();
string message = apiKey + nonce;
using (HMACSHA256 hmac = new HMACSHA256(Convert.FromBase64String(apiSecret)))
{
   byte[] signatureBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(message));
   string X_Signature = Convert.ToBase64String(signatureBytes));
}
apiKey = YOUR_API_PUBLIC_KEY
apiSecret = YOUR_API_SECRET
apiSecret = base64.b64decode(apiSecret)
stamp = str(int(time.time())*1000)
data = "{}{}".format(apiKey, stamp).encode('utf-8')
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
signature = base64.b64encode(signature)

headers= {
  "X-PCK": apiKey,
  "X-Stamp": str(nonce),
  "X-Signature": str(base64.b64encode(signature).decode('utf-8')),
  "Content-Type: application/json"
}
<?php
$apiKey = YOUR_API_PUBLIC_KEY;
$apiSecret = YOUR_API_SECRET;
$message = $apiKey.(time()*1000);
$signatureBytes = hash_hmac('sha256', $message, base64_decode($apiSecret), true);
$signature = base64_encode($signatureBytes);
$nonce = time()*1000;
$headers = array(
  'X-PCK: '.$apiKey,
  'X-Stamp: '.$nonce,
  'X-Signature: '.$signature,
  'Content-Type: application/json',
);

All API calls related to a user account, require authentication.

You need to provide 3 parameters to authenticate a request:

API Public key

You can create the API key from the Account > API Access page in your exchange account.

Nonce

Nonce is a regular integer number. It must be current timestamp in milliseconds.

Signature

Signature is a HMAC-SHA256 encoded message. The HMAC-SHA256 code must be generated using a private key that contains a timestamp as nonce and your API key

Usage

Append [https://api.btcturk.com/] URL to the beginning of the methods to use the API.

For example, to get ticker info from BTCTurk, use https://api.btcturk.com/api/v2/ticker

Testing

You can use our testing platforms to test the APIs. The balances on the test sites are not real and do not represent any real value. The testing platforms work on TESTNET and you can deposit TESTNET coins to your account. The testing platforms are:

Questions & Problems

Please check the F.A.Q for Frequently Asked Questions. You can use the issues on this github project to ask questions and report bugs.

Public Endpoints

Ticker

// 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 tickerList = apiClientV1.GetTicker("BTC_TRY");

if (tickerList.Result.Success)
{
    foreach (var ticker in tickerList.Result.Data)
    {
        Console.WriteLine(ticker.ToString());
    }
}
else
{
    Console.WriteLine(tickerList.Result.ToString());
}
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v2/ticker?pairSymbol=BTC_TRY"
uri = base+method

result = requests.get(url=uri)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$method = "/api/v2/ticker?pairSymbol=BTC_TRY";
$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);

Result:

{
  "data": [
    {
      "pair": "BTCTRY",
      "pairNormalized": "BTC_TRY",
      "timestamp": 1570024156166,
      "last": 47500,
      "high": 48710,
      "low": 47000,
      "bid": 47472,
      "ask": 47670,
      "open": 47988,
      "volume": 304.41,
      "average": 47850.41,
      "daily": -318,
      "dailyPercent": -1.02,
      "denominatorSymbol": "TRY",
      "numeratorSymbol": "BTC"
    },
    {
      "pair": "ETHTRY",
      "pairNormalized": "ETH_TRY",
      "timestamp": 1570024156166,
      "last": 1020,
      "high": 1034,
      "low": 999,
      "bid": 1019,
      "ask": 1023,
      "open": 1032,
      "volume": 5038.27,
      "average": 1015.66,
      "daily": -9,
      "dailyPercent": -1.16,
      "denominatorSymbol": "TRY",
      "numeratorSymbol": "ETH"
    }
...
  ],
  "success": true,
  "message": "",
  "code": 0,
}

If pairSymbol is not set, ticker for all pairs will be returned in a json array.

GET ../api/v2/ticker

OR

GET .../api/v2/ticker?pairSymbol=BTC_TRY

OR

GET .../api/v2/ticker/currency?symbol=USDT

Order Book

// 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("BTC_TRY");

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());
}
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v2/orderbook?pairSymbol=BTC_TRY"
uri = base+method

result = requests.get(url=uri)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$method = "/api/v2/orderbook?pairSymbol=BTC_TRY&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);

Result:

{
  "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"
      ]
    ]
  }
}

GET .../api/v2/orderbook?pairSymbol=BTC_TRY

OR

GET .../api/v2/orderbook?pairSymbol=BTC_TRY&limit=100

Trades

// 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 trades = apiClientV1.GetLastTrades("BTC_TRY", 10);

if (trades.Result.Success)
{
    Console.WriteLine("Last 10 trades in the market");
    foreach (var trade in trades.Result.Data)
    {
        Console.WriteLine(trade.ToString());
    }
}
else
{
    Console.WriteLine(trades.Result.ToString());
}
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v2/trades?pairSymbol=BTC_TRY&last=50"
uri = base+method

result = requests.get(url=uri)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$method = "/api/v2/trades?pairSymbol=BTC_TRY&last=50";
$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);

Result:

  {
  "success": true,
  "message": null,
  "code": 0,
  "data": [
    {
      "pair": BTCTRY,
      "pairNormalized": BTC_TRY,
      "numerator": BTC,
      "denominator": TRY,
      "date": 1533650242300,
      "tid": "636692470417865271",
      "price": "33490",
      "amount": "0.00032747"
    },
    {
      "pair": BTCTRY,
      "pairNormalized": BTC_TRY,
      "numerator": BTC,
      "denominator": TRY,
      "date": 1533650237143,
      "tid": "636692470367947749",
      "price": "33245",
      "amount": "0.00471901"
    }
    ]
  }

GET .../api/v2/trades?pairSymbol=BTC_TRY

OR

GET .../api/v2/trades?pairSymbol=BTC_TRY&last=COUNT (Max. value for count parameter is 50)

OHCL Data (Returns daily cumulative data)

import time, base64, hmac, hashlib, requests, json

base = "https://graph-api.btcturk.com"
method = "/v1/ohlcs?pair=BTC_TRY"
uri = base+method

result = requests.get(url=uri)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://graph-api.btcturk.com";
$method = "/v1/ohlcs?pair=BTC_TRY";
$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);

GET https://graph-api.btcturk.com/v1/ohlcs?pair=BTC_TRY

OR

GET https://graph-api.btcturk.com/v1/ohlcs?pair=BTC_TRY&from=1582132083&to=1582532083

Result:

[
  {
    "pair": "BTCTRY",
    "time": 1582070400,
    "open": 61940,
    "high": 62698,
    "low": 58500,
    "close": 58801,
    "volume": 549.1858885452384,
    "total": 33566080.63598728,
    "average": 61119.71,
    "dailyChangeAmount": -3139,
    "dailyChangePercentage": -5.07
  },
  {
    "pair": "BTCTRY",
    "time": 1582156800,
    "open": 59150,
    "high": 61000,
    "low": 58477,
    "close": 59100,
    "volume": 663.4533811472954,
    "total": 39211283.23027989,
    "average": 59101.79,
    "dailyChangeAmount": -50,
    "dailyChangePercentage": -0.08
  },
  {
    "pair": "BTCTRY",
    "time": 1582243200,
    "open": 59104,
    "high": 60399,
    "low": 58801,
    "close": 59704,
    "volume": 387.62553661495724,
    "total": 23127026.682461508,
    "average": 59663.32,
    "dailyChangeAmount": 600,
    "dailyChangePercentage": 1.02
  }
]

Private Endpoints

Account Balance

// 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 balances = apiClientV1.GetBalances();

if (balances.Result != null && balances.Result.Success)
{
    foreach (var balance in balances.Result.Data)
    {
        Console.WriteLine(balance.ToString());
    }
}
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v1/users/balances"
uri = base+method

apiKey = "YOUR_API_PUBLIC_KEY"
apiSecret = "YOUR_API_SECRET"
apiSecret = base64.b64decode(apiSecret)

stamp = str(int(time.time())*1000)
data = "{}{}".format(apiKey, stamp).encode("utf-8")
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
signature = base64.b64encode(signature)
headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}

result = requests.get(url=uri, headers=headers)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$apiKey = "YOUR_API_PUBLIC_KEY";
$apiSecret = "YOUR_API_SECRET";
$method = "/api/v1/users/balances";
$uri = $base.$method;

$nonce = time()*1000;
$message = $apiKey.$nonce;
$signatureBytes = hash_hmac("sha256", $message, base64_decode($apiSecret), true);
$signature = base64_encode($signatureBytes);
$headers = array(
    "X-PCK: ".$apiKey,
    "X-Stamp: ".$nonce,
    "X-Signature: ".$signature,
    "Cache-Control: no-cache",
    "Content-Type: application/json");

$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);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);

GET .../api/v1/users/balances

Result:

{
  "data": [
    {
      "asset": "TRY",
      "assetname": "Türk Lirası",
      "balance": "103158.9412490031968651",
      "locked": "1023.5699999896000000",
      "free": "102135.3712490135968651"
    },
    {
      "asset": "BTC",
      "assetname": "Bitcoin",
      "balance": "29.6027353000000000",
      "locked": "0.0010000000000000",
      "free": "29.6017353000000000"
    }
    ...
  ],
  "success": true,
  "message": null,
  "code": 0
}

User Transactions

// 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 startdate = new DateTime(2019, 11, 19);
var endatet = new DateTime(2019, 12, 19);
var userTrades = apiClientV1.GetUserTrades(new[] { "buy", "sell" }, new[] { "try", "btc" }, startdate.ToUnixTime(), endatet.ToUnixTime());

if (userTrades.Result.Success)
{
    foreach (var userTrade in userTrades.Result.Data)
    {
        Console.WriteLine(userTrade);
    }
}
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v1/users/transactions/trade?type=buy&type=sell&symbol=btc&symbol=try&symbol=usdt"
uri = base+method

apiKey = "YOUR_API_PUBLIC_KEY"
apiSecret = "YOUR_API_SECRET"
apiSecret = base64.b64decode(apiSecret)

stamp = str(int(time.time())*1000)
data = "{}{}".format(apiKey, stamp).encode("utf-8")
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
signature = base64.b64encode(signature)
headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}

result = requests.get(url=uri, headers=headers)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$apiKey = "YOUR_API_PUBLIC_KEY";
$apiSecret = "YOUR_API_SECRET";
$method = "/api/v1/users/transactions/trade?type=buy&type=sell&symbol=btc&symbol=try&symbol=usdt";
$uri = $base.$method;

$nonce = time()*1000;
$message = $apiKey.$nonce;
$signatureBytes = hash_hmac("sha256", $message, base64_decode($apiSecret), true);
$signature = base64_encode($signatureBytes);
$headers = array(
    "X-PCK: ".$apiKey,
    "X-Stamp: ".$nonce,
    "X-Signature: ".$signature,
    "Cache-Control: no-cache",
    "Content-Type: application/json");

$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);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);

Get .../api/v1/users/transactions/trade?type=buy&type=sell&symbol=btc&symbol=try&symbol=usdt

Result:

{
  "success": true,
  "message": "SUCCESS",
  "code": 0,
  "data": [
    {
      "price": 33700,
      "numeratorSymbol": "BTC",
      "denominatorSymbol": "TRY",
      "orderType": "sell",
      "id": 5553445,
      "timestamp": 1533314288287,
      "amount": -0.003,
      "fee": -0.0685423626,
      "tax": -0.012337625268
    },
    {
      "price": 33700,
      "numeratorSymbol": "BTC",
      "denominatorSymbol": "TRY",
      "orderType": "sell",
      "id": 5553444,
      "timestamp": 1533314254297,
      "amount": -0.001,
      "fee": -0.0514067888,
      "tax": -0.009253221984
    },
    {
      "price": 4.77,
      "numeratorSymbol": "USDT",
      "denominatorSymbol": "TRY",
      "orderType": "buy",
      "id": 5553442,
      "timestamp": 1533313928057,
      "amount": 2.09,
      "fee": -0.0152074094832,
      "tax": -0.002737333706976
    } ...
}

Params

Result

POST .../api/v1/users/transactions/crypto

// 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 userCryptoTransactions = apiClientV1.GetUserCryptoTransactions(new[] { "deposit", "withdrawal" }, new[] { "btc", "eth", "xrp" }, DateTime.UtcNow.AddDays(-30).ToUnixTime(), DateTime.UtcNow.ToUnixTime());

if (userCryptoTransactions.Result.Success)
{
    foreach (var userCryptoTransaction in userCryptoTransactions.Result.Data)
    {
        Console.WriteLine(userCryptoTransaction);
    }
}
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v1/users/transactions/crypto"
uri = base+method

apiKey = "YOUR_API_PUBLIC_KEY"
apiSecret = "YOUR_API_SECRET"
apiSecret = base64.b64decode(apiSecret)

stamp = str(int(time.time())*1000)
data = "{}{}".format(apiKey, stamp).encode("utf-8")
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
signature = base64.b64encode(signature)
headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}

result = requests.get(url=uri, headers=headers)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$apiKey = "YOUR_API_PUBLIC_KEY";
$apiSecret = "YOUR_API_SECRET";
$method = "/api/v1/users/transactions/crypto";
$uri = $base.$method;

$nonce = time()*1000;
$message = $apiKey.$nonce;
$signatureBytes = hash_hmac("sha256", $message, base64_decode($apiSecret), true);
$signature = base64_encode($signatureBytes);
$headers = array(
    "X-PCK: ".$apiKey,
    "X-Stamp: ".$nonce,
    "X-Signature: ".$signature,
    "Cache-Control: no-cache",
    "Content-Type: application/json");

$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);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);

Result:

{
  "success": true,
  "message": "SUCCESS",
  "code": 0,
  "data": [
    {
      "balanceType": "Deposit",
      "currencySymbol": "XRP",
      "id": 676961,
      "timestamp": 1544079921450,
      "funds": 10.8,
      "amount": 0.9,
      "fee": 0,
      "tax": 0
    },

    {
      "balanceType": "Withdrawal",
      "currencySymbol": "XRP",
      "id": 516136,
      "timestamp": 1544079921450,
      "funds": 8.9,
      "amount": -1,
      "fee": 0,
      "tax": 0
    } ...
  ]
}

Params

POST .../api/v1/users/transactions/fiat

// 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 userFiatTransactions = apiClientV1.GetUserFiatTransactions(new[] { "deposit", "withdrawal" }, new[] { "try" }, DateTime.UtcNow.AddDays(-30).ToUnixTime(), DateTime.UtcNow.ToUnixTime());

if (userFiatTransactions.Result.Success)
{
    foreach (var userFiatTransaction in userFiatTransactions.Result.Data)
    {
        Console.WriteLine(userFiatTransaction);
    }
}
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v1/users/transactions/fiat"
uri = base+method

apiKey = "YOUR_API_PUBLIC_KEY"
apiSecret = "YOUR_API_SECRET"
apiSecret = base64.b64decode(apiSecret)

stamp = str(int(time.time())*1000)
data = "{}{}".format(apiKey, stamp).encode("utf-8")
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
signature = base64.b64encode(signature)
headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}

result = requests.get(url=uri, headers=headers)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$apiKey = "YOUR_API_PUBLIC_KEY";
$apiSecret = "YOUR_API_SECRET";
$method = "/api/v1/users/transactions/fiat";
$uri = $base.$method;

$nonce = time()*1000;
$message = $apiKey.$nonce;
$signatureBytes = hash_hmac("sha256", $message, base64_decode($apiSecret), true);
$signature = base64_encode($signatureBytes);
$headers = array(
    "X-PCK: ".$apiKey,
    "X-Stamp: ".$nonce,
    "X-Signature: ".$signature,
    "Cache-Control: no-cache",
    "Content-Type: application/json");

$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);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);

Result:

{
  "success": true,
  "message": "SUCCESS",
  "code": 0,
  "data": [
    {
      "balanceType": "Deposit",
      "currencySymbol": "TRY",
      "id": 93214,
      "timestamp": 1544079972687,
      "funds": 100000,
      "amount": 1000,
      "fee": 0,
      "tax": 0
    },
    {
      "balanceType": "Deposit",
      "currencySymbol": "TRY",
      "id": 919664,
      "timestamp": 1544079972687,
      "funds": 100000.04,
      "amount": 100000,
      "fee": 0,
      "tax": 0
    } ...
}

Params

Result

Open Orders

// 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 openOrders = apiClientV1.GetOpenOrders();

if (openOrders.Result != null && openOrders.Result.Success)
{
    foreach (var askOrder in openOrders.Result.Data.Asks)
    {
        Console.WriteLine(askOrder);
    }

    foreach (var bidOrder in openOrders.Result.Data.Bids)
    {
        Console.WriteLine(bidOrder);
    }
}
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v1/openOrders?pairSymbol=BTC_TRY"
uri = base+method

apiKey = "YOUR_API_PUBLIC_KEY"
apiSecret = "YOUR_API_SECRET"
apiSecret = base64.b64decode(apiSecret)

stamp = str(int(time.time())*1000)
data = "{}{}".format(apiKey, stamp).encode("utf-8")
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
signature = base64.b64encode(signature)
headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}

result = requests.get(url=uri, headers=headers)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$apiKey = "YOUR_API_PUBLIC_KEY";
$apiSecret = "YOUR_API_SECRET";
$method = "/api/v1/openOrders?pairSymbol=BTC_TRY";
$uri = $base.$method;

$nonce = time()*1000;
$message = $apiKey.$nonce;
$signatureBytes = hash_hmac("sha256", $message, base64_decode($apiSecret), true);
$signature = base64_encode($signatureBytes);
$headers = array(
    "X-PCK: ".$apiKey,
    "X-Stamp: ".$nonce,
    "X-Signature: ".$signature,
    "Cache-Control: no-cache",
    "Content-Type: application/json");

$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);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);

GET .../api/v1/openOrders?pairSymbol=BTC_TRY

Result:

{
  "success": true,
  "message": null,
  "code": 0,
  "data": {
    "asks": [
      {
        "id": 9932533,
        "price": "21000.00",
        "amount": "0.001",
        "quantity": "0.001",
        "pairsymbol": "BTCTRY",
        "type": "Sell",
        "method": "Limit",
        "orderClientId": "test",
        "time": 1543994632920,
        "updateTime": 1543994632920,
        "status": "Untouched"
      }
    ],
    "bids": [
      {
        "id": 9932534,
        "price": "20000.00",
        "amount": "0.001",
        "quantity": "0.001",
        "pairsymbol": "BTCTRY",
        "type": "Buy",
        "method": "Limit",
        "orderClientId": "test",
        "time": 1543996112263,
        "updateTime": 1543996112263,
        "status": "Untouched"
      }
    ]
  }
}

Cancel Order

// 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 orderId = 123456;
var cancelOrder = apiClientV1.CancelOrder(orderId);

if (cancelOrder.Result)
{
    Console.WriteLine($"Successfully canceled order {orderId}");
}
else
{
    Console.WriteLine("Could not cancel order");
}
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v1/order?id=ORDER_ID"
uri = base+method

apiKey = "YOUR_API_PUBLIC_KEY"
apiSecret = "YOUR_API_SECRET"
apiSecret = base64.b64decode(apiSecret)

stamp = str(int(time.time())*1000)
data = "{}{}".format(apiKey, stamp).encode("utf-8")
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
signature = base64.b64encode(signature)
headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}

result = requests.delete(url=uri, headers=headers)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$apiKey = "YOUR_API_PUBLIC_KEY";
$apiSecret = "YOUR_API_SECRET";
$method = "/api/v1/order?id=ORDER_ID";
$uri = $base.$method;

$nonce = time()*1000;
$message = $apiKey.$nonce;
$signatureBytes = hash_hmac("sha256", $message, base64_decode($apiSecret), true);
$signature = base64_encode($signatureBytes);
$headers = array(
    "X-PCK: ".$apiKey,
    "X-Stamp: ".$nonce,
    "X-Signature: ".$signature,
    "Cache-Control: no-cache",
    "Content-Type: application/json");

$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);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);

DELETE .../api/v1/order?id=1

Result:

{
  "success": true,
  "message": "string",
  "code": "",
  "data": {
  }
}

Submit Order

// 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 limitSellOrder = new OrderInput
{
    Quantity = 0.001m,
    Price = 40000m,
    NewOrderClientId = "test",
    OrderMethod = OrderMethod.Limit,
    OrderType = OrderType.Sell,
    PairSymbol = "BTC_TRY"
};

////Create New Order
var orderOutput = apiClientV1.CreateOrder(limitSellOrder);

Console.WriteLine(!orderOutput.Result.Success
    ? $"Code:{orderOutput.Result.Code} , Message: {orderOutput.Result.Message}"
    : orderOutput.Result.Data.ToString());
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v1/order"
uri = base+method

apiKey = "YOUR_API_PUBLIC_KEY"
apiSecret = "YOUR_API_SECRET"
apiSecret = base64.b64decode(apiSecret)

stamp = str(int(time.time())*1000)
data = "{}{}".format(apiKey, stamp).encode("utf-8")
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
signature = base64.b64encode(signature)
headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}

params={"quantity": 0.001,"price": 50000,"stopPrice": 0, "newOrderClientId":"BtcTurk Python API Test", "orderMethod":"limit", "orderType":"sell", "pairSymbol":"BTC_TRY"}

result = requests.post(url=uri, headers=headers, json=params)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$apiKey = "YOUR_API_PUBLIC_KEY";
$apiSecret = "YOUR_API_SECRET";
$method = "/api/v1/order";
$uri = $base.$method;

$post_data = "{ 'quantity' : '0.12345678', 'price' : '50000', 'stopPrice' : 0, newOrderClientId: 'BtcTurk API PHPClient', 'orderMethod':'limit', 'orderType':'sell', 'pairSymbol':'BTC_TRY' }";

$nonce = time()*1000;
$message = $apiKey.$nonce;
$signatureBytes = hash_hmac("sha256", $message, base64_decode($apiSecret), true);
$signature = base64_encode($signatureBytes);
$headers = array(
    "X-PCK: ".$apiKey,
    "X-Stamp: ".$nonce,
    "X-Signature: ".$signature,
    "Cache-Control: no-cache",
    "Content-Type: application/json");

$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);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);

POST .../api/v1/order

Result:

{
  "success": true,
  "message": "OK",
  "code": 0,
  "data": {
    "id": 9932534,
    "datetime": 1543996112263,
    "type": "Buy",
    "method": "Limit",
    "price": "20000.00",
    "stopPrice": "20000.00",
    "quantity": "0.001",
    "pairSymbol": "BTCTRY",
    "pairSymbolNormalized": "BTC_TRY",
    "newOrderClientId": "test"
  }
}

Params:

Expected Errors:

All Orders

import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v1/allOrders?pairSymbol=BTCTRY"
uri = base+method

apiKey = "YOUR_API_PUBLIC_KEY"
apiSecret = "YOUR_API_SECRET"
apiSecret = base64.b64decode(apiSecret)

stamp = str(int(time.time())*1000)
data = "{}{}".format(apiKey, stamp).encode("utf-8")
signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
signature = base64.b64encode(signature)
headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}

result = requests.get(url=uri, headers=headers)
result = result.json()
print(json.dumps(result, indent=2))
<?php
$base = "https://api.btcturk.com";
$apiKey = "YOUR_API_PUBLIC_KEY";
$apiSecret = "YOUR_API_SECRET";
$method = "/api/v1/allOrders?pairSymbol=BTCTRY";
$uri = $base.$method;

$nonce = time()*1000;
$message = $apiKey.$nonce;
$signatureBytes = hash_hmac("sha256", $message, base64_decode($apiSecret), true);
$signature = base64_encode($signatureBytes);
$headers = array(
    "X-PCK: ".$apiKey,
    "X-Stamp: ".$nonce,
    "X-Signature: ".$signature,
    "Cache-Control: no-cache",
    "Content-Type: application/json");

$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);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);

GET .../api/v1/allOrders?pairSymbol=BTC_TRY

Result

{
  "success": true,
  "message": null,
  "code": 0,
  "data": [
    {
      "id": 9932534,
      "price": "20000.00",
      "amount": "0.001",
      "quantity": "0.001",
      "pairsymbol": "BTCTRY",
      "pairsymbolnormalized":"BTC_TRY",
      "type": "Buy",
      "method": "Limit",
      "orderClientId": "test",
      "time": 1543996112263,
      "updateTime": 1543996112263,
      "status": "Untouched"
    },
    {
      "id": 9932533,
      "price": "21000.00",
      "amount": "0.001",
      "quantity": "0.001",
      "pairsymbol": "BTCTRY",
      "pairsymbolnormalized":"BTC_TRY",
      "type": "Buy",
      "method": "Limit",
      "orderClientId": "test",
      "time": 1543994632920,
      "updateTime": 1543994632920,
      "status": "Untouched"
    },
    {
      "id": 9932523,
      "price": "2000.00",
      "amount": "0.01",
      "quantity": "0.01",
      "pairsymbol": "BTCTRY",
      "pairsymbolnormalized":"BTC_TRY",
      "type": "Buy",
      "method": "Limit",
      "orderClientId": "test",
      "time": 1543500891493,
      "updateTime": 1543501769613,
      "status": "Canceled"
    }
  ]
}

Params:

Result

Rate Limits

Retry-After When you receive 429 (Too Many Requests) response, this indicates how long you have to wait before making a new request. Please refer to this link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After

Endpoints Method Requests per minute
All Endpoints    
api/v1/* * 600
Balance    
/api/v1/users/balances GET 90
CryptoWithdrawal    
/api/v1/withdrawals/crypto POST 10
Order    
/api/v1/order POST 300
/api/v1/order DELETE 300
/api/v1/openOrders GET 300
/api/v1/allOrders GET 300
Trade    
/api/v1/trades GET 90
UserTransactions    
/api/v1/users/transactions/trade GET 90
/api/v1/users/transactions/trade/* GET 90
/api/v1/users/transactions/crypto GET 90
/api/v1/users/transactions/fiat GET 90
Ticker    
/api/v2/ticker GET 600
/api/v2/orderBook GET 60

Websocket Feed

Btcturk websocket feed provides real-time market data for orders and trades.

We can list the general information about the life cycle after the connection to the server is as follows.

General information about server connection and user login operations can be listed as follows:

Porotocol

The websocket feed uses a bidirectional protocol, which encodes all messages as JSON objects. All messages have a type attribute that can be used to handle the message appropriately.

Please note that new message types can be added at any point in time. Clients are expected to ignore messages they do not support.

Channels and Events

Data such as order book, ticker, last transactions are not sent directly after connection or user login is made. There is a specific channel and event for each process. By subscribing to these channels and events, this data is received. Once subscribed to a channel, the server sends events to that channel continuously to the client, unless the unsubscribe message is sent.

On the server, the channels generally represent the places where the transaction takes place (order book,last transactions, etc.) and the events represent the pair value (such as BTCTRY, ETHTRY, XLMUSDT) where the transaction takes place. In some special cases, these values ​​may change. For example, to receive ticker data for all pairs, it is necessary to subscribe to the all event of the ticker channel . The server runs on 3 channels:

1) orderbook : Sends the transactions in the order book. The event name is the upper-case name of the pair. Ex: BTCTRY

2) trade : Sends data for recent transactions. Depending on the data type, incoming data can be individual or aggregated. The event name is the upper-case name of the pair. Ex: BTCTRY

3) ticker : Sends the current ticker data. There are two types of events. In the all event, the data for all pairs comes. To receive only events of a particular pair, you must subscribe to the upper-case pair name event. Ex: BTCTRY

The sample code to subscribe to the event is as follows:

[151,
    {
        type: 151,
        channel: 'trade',
        event: 'ETHTRY',
        join: true
    }
]

Similarly, a message like the following is sent to exit the subscribed event


[151,
    {
        type: 151,
        channel: 'ticker',
        event: 'all',
        join: false
    }
]

Models

The supported model types between Server and Client are given in the following tables.

100

Result

P

A message sent from the server to the client. These are model-free results returned from requests sent to the server. For example, UserLogin, Subscription, and so on.

Type

number

Model type

ID

number

Id value of the model being processed. It is used in some Result models. The value can be 0 when not in use.

Ok

boolean

Transaction success

message

string

transaction message. It usually contains short codes for the transaction. It should not be shown to the end user. For example, the value returned as subscription result: “join | trade: BTCTRY” is similar.

101

Request

P

Extra requests sent to the server. For example, the Request model is sent when the last operations list is requested again.

type

number

Model type

code

number

The request code. Designed in the same way as possible with package types. These request codes are listed at the end of the document. For example, the client must send this code value 421 (model type of final operations) to request that the last transactions be sent back to it.

channel

string

If the request is sent over a particular channel, this value must be written to the channel name. For non-channel requests, null can be sent.

event

string

If the request is sent over a particular event, this value must be written to the name of the event. For non-event requests, null can be sent.

111

UserLogin

P

A message sent from the client to the server. User input model.

type

number

Model type

ID

number

The id value of the user. Must be sent. The server checks for its equality with the value read from the Token. If you want to make a guest login notification, send 0 to this value. (Guest login notification is not mandatory in the system)

username

string

User name. E-mail address for BtcTurk. Giriş guest. Should be written in the guest entrance notifications.

token

string

The current token value of the user from SSO. Null must be sent in guest notifications.

app

string

Application name: “pro” or “easy”

platform

string

User's operating system or browser information: “android”, “ios”, “windows”, “linux”

112

UserLoginResult

P

A message sent from the server to the client. This is the answer to the user input model. It is exactly the same as the Result model. Only the model type is 112.

113

UserLogout

U

It is a message that is sent back from client to server and back from server to client. The user is the output model. After this model is taken, the server will terminate the socket connection.

type

number

Model type

ID

number

User Id

151

Subscription

P

A message sent from the client to the server. A model sent to subscribe to or unsubscribe from an event on a channel. Messages related to subscribed events are continuously sent to the user.

type

number

Model type

channel

string

The name of the channel. For example; trade, orderbook, ticker etc.

event

string

speak event name event name. Event names are often used as “all” or upper-case as pair name (eg BTCTRY, ETHTRY).

jon

boolean

If true, it means that you want to subscribe, if false, you can unsubscribe.

201

BalanceUpdated

U

The model sent by the server when the user's balance changes for any reason (confirmation, withdrawal request, deposit request, request confirmations, etc.). When this message is received, the user's balance must be updated from the API endpoint.

type

number

Model type

UserID

number

User Id

payload

string

Transaction description. For informational purposes.

401

TickerAll

C

A message sent from the server to the client. It is the model of all ticker data belonging to all Pairs.

type

number

Model type

items

TickerPair []

An array of type TickerPair. The only difference is that there is no type variable in every TickerPair model. The TickerPair model is described below.

402

TickerPair

C

A message sent from the server to the client. It is only a model of all ticker data for a particular Pair.

type

number

Model type

PS

string

Pair Symbol. For example; BTCTRY

H

string

High. Highest price in the last 24 hours.

L

string

Lower. The lowest price in the last 24 hours.

La

string

Last. The price of the last transaction.

SHE IS

string

Open. Price of the first transaction of the day

V

string

Volume. Volume.

AV

string

Average. Average price.

D

string

Daily. Daily change amount.

DS

string

Denominator Symbol. For example BTCTRY TRY.

NS

string

Numerator Symbol. For example BTCTRY for BTC.

PID

number

Pair Id value.

NPr

number

Numerator precision value. For example BTC 8

Dpr

number

Denominator precision value. For example TRY 2

Ord

number

Pair's display sequence.

B

string

Bidar. Best purchase order price.

A

string

Love. Best selling order price.

DP

string

Daily percent. 24-hour exchange rate.

421

TradeList

C

A message sent from the server to the client. This is the list of all recent transactions of the specified Pair.

type

number

Model type

channel

string

Message channel

event

string

The name of the event to which the message was delivered.

symbol

string

Pair symbol. For example; BTCTRY

items

TradeSingle []

An array in the list that contains a transaction log. The TradeSingle model is described below. The TradeSingle models in the TradeList model do not contain the PS and type variables.

422

TradeSingle

C

A message sent from the server to the client. It is a single trade data of the specified Pair. This data is sent as it occurs.

type

number

Model type

PS

number

Pair Symbol. For example; BTCTRY.

A

string

Amount. The amount of the transaction.

D

number

Date. Transaction date. UnixTime is the value in milliseconds.

P

string

Price. The price at which the transaction was made.

I

string

The unique number of the transaction. (Uniqueness is valid only in its own pairi)

431

OrderBookFull

C

A message sent from the server to the client. It is the entire order book model of a particular Pair.

type

number

Model type

CS

number

ChangeSet. Change number. It comes in the form of sequential values. There is no control at this time.

PS

string

Pair Symbol value. For example; BTCTRY

AO

Order []

List of sales orders. The Order object contains two variables: A, amount, and transaction quantity. P is the price, the transaction price.

BO

Order []

List of purchase orders.

432

OrderBookDifference

C

A message sent from the server to the client. Sends order book data of only a particular Pair's changes. The user must have previous order book data to use this model. This data is sent automatically from the server when the event is subscribed.

changingord is
 

  •                 PS: Orders are transaction type. 0: Updated, 1: New added, 3: Deleted
  •                 P: Order price value.
  •                 A: Orders is the quantity.
     

type

number

Model type

CS

number

ChangeSet. Change number. It comes in the form of sequential values. There is no control at this time.

PS

string

Pair Symbol value. For example; BTCTRY

AO

ChangingOrder []

List of sales orders. The Order object contains two variables: A, amount, and transaction quantity. P is the price, the transaction price.

BO

ChangingOrder []

List of purchase orders.

441

UserOrderMatch

U

It is the model that contains the details of this process, which is sent from the server to the user when an order of the connected user is executed.

type

number

Model type

ID

number

Id value of the model being processed.

user

boolean

The id of the user being processed.

IsBid

string

True if the transaction is buying or false if the transaction is buying.

method

number

transaction method. 0: limit, 1: market, 2: stop limit

pair

number

pair id value of the transaction

symbol

string

The pair symbol value of the operation. For example; BTCTRY

numTotal

string

Total Numerator amount of the order

numleft

string

The quantity of the numerator remaining after the trade has been executed.

denomTotal

string

Total denominator amount of order

denomLeft

string

The denominator amount of the order remaining after the trade has taken place.

amount

string

The amount of the transaction.

price

string

The price at which the transaction occurred.

451

orderınsert

U

A message sent from the server to the client. When a user's order is added to the system, it is the model sent to the user. Newly added orders will be sent with the model. When this model is received from the server, the user's orders can be updated from the endpoint.

type

number

Model type

pairId

number

The pair id value of the order.

symbol

string

The pair symbol value of the order.

ID

number

Order Id value.

method

number

Type of order (0: limit, 1: market, 2: stop limit)

userId

number

The Id value of the user who issued the order.

price

string

Price of the order

amount

string

Amount of order

452

OrderDelete

U

A message sent from the server to the client. When a user's order is deleted from the system, it is the model that is sent to the user. Deleted orders with model will be sent. When this model is received from the server, the user's orders can be updated from the endpoint. The model is the same as the OrderInsert model.

453

OrderUpdate

U

A message sent from the server to the client. This is the model sent to the user when an order of the user is updated in the system. Orders updated with the model will be sent. When this model is received from the server, the user's orders can be updated from the endpoint. The model is the same as the OrderInsert model.

Channel, Event and Model

For use on browsers or platforms where WebSocket is not supported, it is also possible to access data sent via WebSocket with specific endpoints.

Channel

Event

Model

Explanation

ticker

all

401

Data is sent at specified intervals (not later than once per second). Contains all pair ticker data.

ticker

[PAIR]

402

Data is sent at specified intervals (not later than once per second).

trade

[PAIR]

421
422

One-time full trade model 421 is sent as subscribed . Only new incoming trade models 422 are then sent.

orderbook

[PAIR]

431

All order book data is sent at certain intervals (at the latest every second).

obdiff

[PAIR]

431
432

As ordered , a one-time full orderbook model 431 is sent. Only the exchange model 432 is then sent.

Tradingview

radingView data is transmitted over the tradeview channel. PAIR_RESOLUTION events must be subscribed to on this channel . Supported resolution values ​​for TradingView data are 1, 5, 15, 30, 60, 240 for minutes up to 4 hours . Daily, weekly and monthly ones are 1D, 1W, 1M . For example, a user who wants to view the trading hours BTCTRY follow the data tradeview the remaining BTCTRY_60 must subscribe to the event. With another example, if you want to follow the daily ETHTRY trading view data, you should subscribe to the ETHTRY_1D event of the tradeview channel . NOTE: Only the last column data is sent via WebSocket for TradingView. For example, when the time is 14:40:50, the minute data represents data between 14:40 and 14:41, and the hourly data represents data between 14:00 and 15:00. The data sent contains the UNIX timestamp value, which specifies the time zone for which the data belongs.

428

TradingView

C

A message sent from the server to the client. Contains the current candle data for the pair and resolution specified in the event.

type

number

Model type

D

number

UNIX timestamp, in seconds.

P

string

Pair. For example BTCTRY

R

string

Resolution. For example 1W.

O

Stringer

Open. The opening value of the data.

H

Stringer

High. The highest value the data reaches.

L

Stringer

Lower. The lowest value that the data reaches.

C

Stringer

Close. The last value the data takes. (Ticker last)

V

string

Volume. The total volume in the specified time.

Communicating Directly with HTTP EndPoints

For use on browsers or platforms where WebSocket is not supported, it is also possible to access data sent via WebSocket with specific endpoints. Values ​​returned to HTTP Requests sent to EndPoints are the last data fed by the BTC Trader socket server. For example, if the ticker data is updated on average every second, all requests sent within the same seconds will return the same result.

Order Book

There is one endpoint for each pair in the Order Book. The URL to which requests will be sent is as follows:

GET https://ws-feed-sandbox.btctrader.com/orderbook/{PAIR}

The format of the parameter Pair must be BTCTRY, ETHTRY, XRPUSDT. for example

https://ws-feed-sandbox.btctrader.com/orderbook/btctry

Sends the current BTC/TRY order book model.

The returned result is in JSON format of the model code OrderBookFull 431 specified in the above models.

Ticker

The ticker data consists of a single endpoint that returns ticker data for all pairs. Taken as follows. GET https://ws-feed-sandbox.btctrader.com/ticker/all The result returned is the Items variable of the code-named model TickerAll 401 in the above models. (Not the model itself) The following endpoint is available when you want to display a user-friendly HTML design version of the ticker data. GET https://ws-feed-sandbox.btctrader.com/ticker/html The following endpoint can only be used to receive ticker data for a particular pair. The following link is exemplified by BTCTRY. You can change the parameter here for other pair ticker data available in the system. GET https://ws-feed-sandbox.btctrader.com/ticker/pair/BTCTRY

Recent Actions

The last operations return the operations of a specified pair. The user can specify the last number of operations by parameter. The maximum number of records in the last transactions is 50. If a value greater than 50 is entered, the last 50 transactions will be sent again. The request for final transactions should be sent as follows.

GET https://ws-feed-sandbox.btctrader.com/trade/last/{PAIR{/{COUNT}

Pair should be entered as BTCTRY. Count value must be sent from 1 to 50 numerically. If Count is not sent, the default is 50. For example, requests are valid as follows. https://ws-feed-sandbox.btctrader.com/trade/last/btctry/10 https://ws-feed-sandbox.btctrader.com/trade/last/ethtry/76 https://ws-feed-sandbox.btctrader.com/trade/last/xrptry

Errors

Btcturk API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your Public/Private API key is wrong.
429 Too Many Requests -- You exceeded request rate limit.
5xx Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.

Pairs Scale (Quantity/Price)

Pair Quantity Scale Price Scale
BTC/TRY 8 0
EOS/TRY 2 2
ETH/TRY 8 0
LTC/TRY 8 2
NEO/TRY 4 2
USDT/TRY 2 2
XLM/TRY 4 4
XRP/TRY 4 2
XTZ/TRY 2 2
BTC/USDT 8 0
EOS/USDT 2 3
ETH/USDT 8 1
LTC/USDT 8 2
NEO/USDT 4 2
XLM/USDT 4 4
XRP/USDT 4 4
EOS/BTC 4 5
ETH/BTC 8 8
LTC/BTC 8 5
NEO/BTC 8 5
XLM/BTC 4 8
XRP/BTC 4 8

FAQ

White label exchange API Frequently Asked Questions

The documentation for frequently asked questions of BTCTrader's white label exchange platform API.

Why do I receive 401 - Unauthorized error

You need to authorize before sending your request on all user related operations like buy/sell/cancel orders, user balances, open orders etc.

Please check and confirm that you've created the API key from PRO website. Also, check the API Key's permissions. If you don't have the necessary permissions, your requests will be unauthorized. Also if you had limited API with an IP address and your server has a different address, your API requests won't be authorized.

Why do I receive Invalid nonce error

Nonce is a regular integer number. It must be Unix Timestamp in milliseconds format. We do have a 5 seconds tolerance in timestamps within the requests but your server’s current time must be synced with the API server time which is in milliseconds format. Our servers are using UTC timezone.

You can check the server time from here

Why do I receive 502 - Not enough balance error

For TRY pairs, you need to calculate the commission and deduct from the total amount. For example, if you would like to order 1.00000000 BTC for 50,000TRY, your free balance must be at least 50,090TRY (Maker/Taker commissions are being calculated after your order executed. If your order matches immediately you'll be charged as Taker. Otherwise, you'll be charged as Maker and the commission difference will be added to your balance)

Why do I receive 429 - Too many requests

This means you exceeded the rate limit. Refer to Rate Limits section. Also please check the Retry-After response HTTP header. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After It indicates how long the user agent should wait before making a follow-up request.

What is the difference between API versions and which one is suitable for me

There are two versions v1 and v2.

V1 is used for all authentication required requests like checking balances, listing open orders, creating or canceling orders etc. with HMAC authentication.

V2 is used for all authentication required requests like checking balances, listing open orders, creating or canceling orders etc. with OAUTH2 authentication. V2 is also used for all public requests like ticker, OHLC (open, high, low, close) data, orderbook etc.

If you would like to request a data, related to your user account, you should use v1 with HMAC authentication or v2 with OAUTH2 authentication.

All public data is being served on v2.

401 Unauthorized - Invalid Signature

You might compute a wrong signature. You might not set the signature in the headers. You might use this signature before so the time is changed and therefore you cannot use it anymore. Please check your public/private keys are correct. You may need to encode the key as UTF-8 in some languages.

401 Unauthorized - Invalid Public/Private key

Your public or private keys are missing.

401 Unauthorized - Unauthorized - Headers are missing

Your request does not have requested headers.

401 Unauthorized - Invalid Request

Your current account could be unverified yet you should contact support. Your private key (API Secret) might be wrong. Please check your private key is correct. You may need to decode the key as base64 in some languages.

401 Unauthorized - Invalid Nonce

Nonce should not be different than the current timestamp we are giving a tolerance ±5 seconds.

Please check your server's timezone and timestamp output. It should be in milliseconds format and you need to declare your server's timezone to match UTC.

You can check the server time from here

Have more questions

If you have more questions please feel free to send your questions to issues section