BTCTrader / broker-api-docs

The documentation for BTCTrader's white label exchange platform API. Use this documentation to access the APIs of BTCTurk other BTCTrader partners.
110 stars 32 forks source link

Note: This API will be deprecated soon. Please use the new version. here.

White label exchange API documentation

The documentation for BTCTrader's white label exchange platform API.

These docs are for the APIs of BTCTurk and other BTCTrader partners.

Usage

Append your exchange's URL to the beginning of the methods to use the API. For example, to get ticker info from BTCTurk, use https://www.btcturk.com/api/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 Bitcoin TESTNET and you can deposit TESTNET coins to your account. The testing platforms are:

Important Our mobile applications will not work with the testing platforms. They can only be synced with our live platforms.

Questions & Problems

Please use the issues on this github project to ask questions and report bugs.

Request Limits

Ticker

GET .../api/ticker

Result:

[
    {
    pair: "BTCTRY",
    high: 20950,
    last: 20659.95,
    timestamp: 1508242980,
    bid: 20556.51,
    volume: 142.95,
    low: 20500,
    ask: 20659.95,
    open: 20830,
    average: 20761.68
    },
    {
    pair: "ETHBTC",
    high: 0,
    last: 0,
    timestamp: 1508242980,
    bid: 0.06,
    volume: 0,
    low: 0,
    ask: 0.0635,
    open: 0,
    average: 0
    },
    {
    pair: "ETHTRY",
    high: 1274,
    last: 1227.99,
    timestamp: 1508242980,
    bid: 1210,
    volume: 757.85,
    low: 1210,
    ask: 1227.99,
    open: 1265.99,
    average: 1238.73
    }
]

Order Book

GET .../api/orderbook?pairSymbol=BTCTRY

Result:

{
  "timestamp":1439279819.0,
  "bids":[["761.68","1.17474867"],["761.67","0.23928215"]],
  "asks":[["767.48","0.12456411"],["767.49","4.07185043"]]
}

Trades

GET .../api/trades?pairSymbol=BTCTRY

OR

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

Result:


  [
    {
     "date": 1439280491.0,
     "tid": "55c9ad6b1ac4dc12b06131dc",
     "price":767.47,
     "amount":0.06486361
    },
    {
     "date": 1439280491.0,
     "tid": "55c9ad6b1ac4dc12b06131dc",
     "price":767.47,
     "amount":0.06486361
    } 
  ]

OHCL Data (Daily)

GET .../api/ohlcdata

OR

GET .../api/ohlcdata?last=COUNT

Result:

[
    {
     "Date":"2016-05-18T00:00:00",
     "Open":1367.01,
     "High":1375.61,
     "Low":1362.61,
     "Close":1375.61,
     "Volume":125.17664557,
     "Average":1371.06,
     "DailyChangeAmount":0.63,
     "DailyChangePercentage":8.6
    },
    {
     "Date":"2016-05-17T00:00:00",
     "Open":1365.13,
     "High":1379.8,
     "Low":1365.01,
     "Close":1371.0,
     "Volume":541.47093778,
     "Average":1373.57,
     "DailyChangeAmount":0.43,
     "DailyChangePercentage":5.87
    } 
  ]

API Authentication

All API calls related to a user account require authentication.

You need to provide 3 parameters to authenticate a request:

API 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 increasing with every request you make.

A common practice is to use unix timestamp for that parameter.

Signature

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

Example (C#):

string message = yourAPIKey + nonce;
using (HMACSHA256 hmac = new HMACSHA256(Convert.FromBase64String(yourPrivateKey)))
{
   byte[] signatureBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(message));
   string X-Signature = Convert.ToBase64String(signatureBytes);
}

After creating the parameters, you have to send them in the HTML Header of your request with their name

Example (C#):

client.DefaultRequestHeaders.Add("X-PCK", yourAPIKey);
client.DefaultRequestHeaders.Add("X-Stamp", nonce.ToString());
client.DefaultRequestHeaders.Add("X-Signature", signature);

Warning: Your IP address can be blocked if you make too many unauthorized requests. Make sure you implement the authentication method properly.

Account Balance (Requires Authentication)

GET .../api/balance

Result:

{
    "try_balance": 1000,
    "btc_balance": 0.84053883,
    "eth_balance": 0.0660681,
    "try_reserved": 1003.54,
    "btc_reserved": 0,
    "eth_reserved": 0,
    "try_available": 1000,
    "btc_available": 0.84053883,
    "eth_available": 0.0660681,
    "btctry_taker_fee_percentage": 0.005,
    "btctry_maker_fee_percentage": 0.002,
    "ethtry_taker_fee_percentage": 0.005,
    "ethtry_maker_fee_percentage": 0.002,
    "ethbtc_taker_fee_percentage": 0.004,
    "ethbtc_maker_fee_percentage": 0.001
}

User Transactions (Requires Authentication)

GET .../api/userTransactions?offset=OFFSET&limit=LIMIT&sort=SORT

Params:

Result:

[
  {
    "id":"123456",
    "date":"2015-08-11T11:40:17.278",
    "operation":"buy",
    "amount":1.9449023,
    "currency":"TRY",
    "price":734.52,
    "funds":10,
    "fee" : 0.005,
    "tax" : 0.18
  },
  {
    "id":"123456",
    "date":"2015-08-11T11:40:17.325",
    "operation":"commission",
    "amount":0.0,
    "currency":"TRY",
    "price":0.0,
    "funds":10,
    "fee" : 0.005,
    "tax" : 0.18
  },
  {
    "id":"123456",
    "date":"2015-08-11T11:44:10.162",
    "operation":"sell",
    "amount":-2.18674928,
    "currency":"BTC",
    "price":737.71,
    "funds":10,
    "fee" : 0.005,
    "tax" : 0.18
  },
  {
    "id":"123456",
    "date":"2015-08-11T11:44:10.209",
    "operation":"commission",
    "amount":0.0,
    "currency":"BTC",
    "price":0.0,
    "funds":10,
    "fee" : 0.005,
    "tax" : 0.18
  }
]

Open Orders (Requires Authentication)

GET .../api/openOrders?pairSymbol=BTCTRY

Result:

[
  {
    "id":"123654",
    "datetime":"2015-07-28T04:43:00.271Z",
    "type":"SellBtc",
    "price":820.02,
    "amount":4.65915461,
    "PairSymbol" : "BTCTRY"
  },
  {
    "id":"123657",
    "datetime":"2015-07-30T10:01:39.619Z",
    "type":"BuyBtc",
    "price":790.61,
    "amount":10.42124175,
    "PairSymbol" : "BTCTRY"
  },
]

Cancel Order (Requires Authentication)

POST .../api/cancelOrder

Params:

Result:

{
  "result":true
}

Buy Order (Requires Authentication)

POST .../api/exchange

Params:

For market orders:

Result:

{
  "id":"123753",
  "datetime":"2015-08-11T10:37:44.4786271Z",
  "type":"Buy",
  "price":739.16,
  "amount":2.77891473
}

Sell Order (Requires Authentication)

POST .../api/exchange

Params:

For market orders:

Result:

{
  "id":"147852",
  "datetime":"2015-08-11T10:37:44.4786271Z",
  "type":"Sell",
  "price":739.16,
  "amount":2.77891473
}