Public API

Methods list

Trade Fee:
https://api.bitok.com/open_api/<pair>/fee
Ticker:
https://api.bitok.com/open_api/<pair>/ticker
Trades:
https://api.bitok.com/open_api/<pair>/trades
Depth:
https://api.bitok.com/open_api/<pair>/depth
Trade pairs:
https://api.bitok.com/open_api/pairs
Parameter Req. Description Type
<pair> Yes Currencies pair separated by an underscore, e.g. "btc_usd", "ltc_eur", etc. string

Trade API

Authentication is managed by sending the next http headers:

Key:
API-key, e.g. b355c2770b0f5710a447e305fc2fa689
Sign:
POST data (?param=val&param1=val1), signed with HMAC-SHA512 method with API-secret as a key

Data should be sent to https://api.bitok.com.
You should also send nonce POST-parameter. nonce should be positive and should be incremented with each request.

Method name is sent as POST parameter method. All method parameters are sent as POST data.
All responses are in JSON format.

If request was successfull, the response looks like:

{
    "success": 1,
    "return": {

    }
}

Error response:

{
    "success": 0,
    "error": "<Error text>"
} 

Methods list

getInfo

Returns information about user's current balance, API-key privileges, transactions number, active orders count.
Method has no parameters.

Response example:

{
  "success": 1,
  "return": {
    "funds": {
      "usd": 325,
      "btc": 23.998,
      "sc": 121.998,
      "ltc": 0,
      "ruc": 0,
      "nmc": 0
    },
    "funds_on_hold": {
      "usd": 0,
      "btc": 1,
      "sc": 0,
      "ltc": 0.02,
      "ruc": 0,
      "nmc": 0
    },
    "affiliate_amount": {
      "usd": 0.0000123,
      "btc": 0,
      "sc": 0,
      "ltc": 0.0002,
      "ruc": 0,
      "nmc": 0
    },
    "rights": {
      "info": 1,
      "trade": 1
    },
    "transaction_count": 80,
    "open_orders": 1,
    "server_time": 1342123547
  }
}
TransHistory

Returns transaction history.

Parameter Req. Description Type Default value
from No offset to start with integer 0
count No transactions count to display integer 1000
from_id No tx id, to start from integer 0
end_id No tx id, to end with integer Inf
order No sort order ASC or DESC DESC
since No timestamp to start with UNIX time 0
end No timestamp to end with UNIX time Inf

If you use since or end parameters, order param is automatically set to ASC.

Response example:

{
    "success": 1,
    "return":{
        "total": 173,
        "rows": {
            "1081672":{
                "type": "trade",
                "amount": "0.5135923100",
                "currency": "btc",
                "timestamp": 1457960494,
                "direction": "income",
                "status": 2,
                "desc": "BTC payment"
            }
        }
    }
}
TradeHistory

Returns closed orders history.

Parameter Req. Description Type Default value
from No offset to start with integer 0
count No transactions count to display integer 1000
from_id No tx id, to start from integer 0
end_id No tx id, to end with integer Inf
order No sort order ASC or DESC DESC
since No timestamp to start with UNIX time 0
end No timestamp to end with UNIX time Inf
pair No pair to filter orders btc_usd (i.e.) all available pairs

If you use since or end parameters, order param is automatically set to ASC.

Response example:

{
    "success": 1,
    "return":{
        "166830":{
            "pair": "btc_usd",
            "type": "sell",
            "amount": 1,
            "rate": 1,
            "order_id": 343148,
            "is_your_order": 1,
            "timestamp": 1342445793
        }
    }
}
ActiveOrders

Returns all open orders.

Parameter Req. Description Type Default value
pair No pair to filter orders btc_usd (i.e.) all available pairs

Response example:

{
    "success": 1,
    "return": {
        "343152": {
            "pair": "btc_usd",
            "type": "sell",
            "amount": 1.00000000,
            "rate": 3.00000000,
            "timestamp_created": 1342448420,
            "status": 0
        }
    }
}
Trade

Performs trade operation.

Parameter Req. Description Type Default value
pair Yes pair btc_usd (i.e.) -
type Yes operation type buy or sell -
rate Yes trade rate you want to buy/sell numeric -
amount Yes amount of currency you want to buy/sell numeric -

Response example:

{
    "success": 1,
    "return": {
        "received": 0.1,
        "remains": 0,
        "order_id": 0,
        "funds": {
            "usd": 325,
            "btc": 2.498,
            "sc": 121.998,
            "ltc": 0,
            "ruc": 0,
            "nmc": 0
        }
    }
}
CancelOrder

Cancels opened order.

Parameter Req. Description Type Default value
order_id Yes order id integer -

Response example:

{
    "success": 1,
    "return": {
        "order_id": 343154,
        "funds": {
            "usd": 325,
            "btc": 24.998,
            "sc": 121.998,
            "ltc": 0,
            "ruc": 0,
            "nmc": 0
        }
    }
}
WithdrawDepositHistory

Returns withdraws and deposits transactions history

Parameter Req. Description Type Default value
from No offset to start with integer 0
count No transactions count to display integer 10
currency No filter transaction by specific currency btc (i.e.) all available currencies

Response example:

{
    "success": 1,
    "return": {
        "40": {
            "tx_id": 40,
            "amount": "2.00",
            "base_amount": "2.00",
            "fee": "0.01",
            "type": "deposit",
            "status": "confirmed",
            "rejected": 0,
            "timestamp": 1394698058,
            "currency": "btc",
            "provider": "coins",
            "extra": {
                "ps_id": "ed6c1c20588be8d29abe25f23b7cda314187cb22bf2bbad4de23192b7e1913b0",
                "confirmations": 3
            }
        },
    }
}
fee

Returns user's fee for the pair

Parameter Req. Description Type Default value
pair Yes pair btc_usd (i.e.) -

Response example:

{
    "trade": 0.002
}
DepositAddress

Returns coins deposit address

Parameter Req. Description Type Default value
currency Yes crypto currency btc (i.e.) -

Response example:

{
    "success": 1,
    "return": {
        "address": "1G3FtRHSfW5Saiq3pti2qm1dJ1bwFL48RD1"
    }
}
WithdrawCrypt

Withdraw cryptocurrency

Parameter Req. Description Type Default value
amount Yes withdraw amount numeric -
currency Yes crypto currency acronym btc (i.e.) -
crypto_address Yes crypto wallet address string -
invoice Yes unique identification string in your system string -
notify_url No instant payment notification URL https://yourdomain.com/nofify-url (i.e.) -

Response example:

{
    "success": 1,
    "return": {
        "status": "new",
        "id" : 12345678
    }
}

Notification will be sent to your notify_url via HTTP POST after tx processing. Example:

Key Value Description
id 12345678 Bitok.com TX ID
invoice XXXXXXXXX unique identification string in your system
amount 0.123 withdraw amount
currency btc currency acronym
status processed transaction status, can be "paid" or "cancelled"
txid 12345678 blockchain transaction id, only if status="paid"
error Not enough funds error message, only if status="cancelled"
signature 5905...71cc IPN request signature (see IPN verification)
CreateVoucher

Create Bitok.com voucher

Parameter Req. Description Type Default value
amount Yes withdraw amount numeric -
currency Yes currency acronym usd (i.e.) -
invoice Yes unique identification string in your system string -
notify_url No instant payment notification URL https://yourdomain.com/nofify-url (i.e.) -

Response example:

{
    "success": 1,
    "return": {
        "status": "new",
        "id" : 12345678
    }
}

Notification will be sent to your notify_url via HTTP POST after tx processing. Example:

Key Value Description
id 12345678 Bitok.com TX ID
invoice XXXXXXXXX unique identification string in your system
amount 0.123 withdraw amount
currency btc currency acronym
status processed transaction status, can be "paid" or "cancelled"
voucher_code 8v34408a987ax35d voucher code, only if status="paid"
error Not enough funds error message, only if status="cancelled"
signature 5905...71cc IPN request signature (see IPN verification)
RedeemVoucher

Redeem Bitok.com voucher

Parameter Req. Description Type Default value
voucher_code Yes Bitok.com voucher code string -
invoice Yes unique identification string in your system string -
notify_url No instant payment notification URL https://yourdomain.com/nofify-url (i.e.) -

Response example:

{
    "success": 1,
    "return": {
        "status": "new",
        "id" : 12345678
    }
}

Notification will be sent to your notify_url via HTTP POST after tx processing. Example:

Key Value Description
id 12345678 Bitok.com TX ID
invoice XXXXXXXXX unique identification string in your system
amount 0.123 withdraw amount
currency btc currency acronym
status processed transaction status, can be "paid" or "cancelled"
error Voucher does not exist error message, only if status="cancelled"
signature 5905abcd...34rd71cc IPN request signature (see IPN verification)
IPN verification:

To verify IPN request you will need to perform the following:

  1. Generate urlencoded HTTP query string from given POST data excluding "signature" field;
  2. Make sha512 HMAC-hash of given query string using API Secret;
  3. Compare given hash string and "signature" string from origin request, both should be identical;

PHP example:

// Your API secret
$apiSecret = 'MY API SECRET';

$request = $_POST;

unset($request['signature']);
$hash = hash_hmac('sha512', http_build_query($request, '', '&'), $apiSecret);

// Strings should be identical
$verified = ($hash === $_POST['signature']);