Public API

Server Time - 18.11 29 Mar

BTC Price - $1058.1

LTC Price - $2.93999

Introduction

cryptonit offers a public API which can be used without setup an account. This public API gives you the possibility to query for current orders (ordersbook), as well as the history of successful trades (executed transactions). It is also possible to get a calculated last price by specifying a number of last transactions to use in averaging.

Limitations

When using the public API some limitations are implemented to prevent excessive use or even abuse. When using the public API all queries are cached. This means that the result you receive might be a few seconds old and does not represent the latest state. For services mirroring the orders on their own sites this is normally enough. If you intent to use this data to make trading decisions, we recommend to register an account at cryptonit and use Developer API. Registered user will always receive the latest state

How to receive placed orders (Orderbook)?

URL: GET @ https://cryptonit.net/apiv2/rest/public/ccorder
Parameters:

  • bid_currency: Offered currency for selling (optional)
  • ask_currency: Requested currency (optional)
  • type: type of the order. You must set it to "placed" or do not pass at all because default value is "placed")
  • limit: maximum number of returned orders (optional)

You can receive a listing of all orders by appending your desired parameters at /apiv2/rest/public/ccorder?<paramter>=<value>&..
The steps are the following:


// REST Server URL
$index_url = "https://cryptonit.net/apiv2/rest/public/ccorder";
// some parameters
$bid_currency = "btc";
$ask_currency = "ltc";
// cURL http headers
$header = array(
"Accept: application/json" // Accept JSON response
);
// cURL
$curl = curl_init($index_url . "?bid_currency=" . $bid_currency . "&ask_currency=" . $ask_currency);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_HEADER, FALSE); // Ask to not return Header
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); // set header data
// get the response
$response = curl_exec($curl);
// get the http code to check the reply
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Check if index was successful
if ($http_code == 200) {
// Convert json response as array
$orders = json_decode($response);
} else {
// Get error msg
$http_message = curl_error($curl);
die($http_message);
}
print_r($orders);

$orders will contain an array with all open (not filled) orders.

"id": {
"type": XXX, // placed, filled or canceled
"bid_currency": "BTC", // some currency (LTC, USD, etc.)
"ask_currency": "LTC", // some currency (LTC, USD, etc.)
"bid_amount": "4.87696051", // amount in current bid
"ask_amount": "487.696051", // amount in current ask
"bid_rate": "100.0", // bid rate
"ask_rate": "0.01", // ask rate
"created": "12312312" // timestamp when order was placed
}

How to receive executed orders (Transactions or Trades)?

In fact in order to get a list of transactions you must follow a procedure similar to requesting Orderbook but set type of orders to "filled". Because filled order is a transaction, as soon as order is filled it goes away from orderbook and becomes an executed transaction. However keep in mind that every transaction has correspondent filled order in both exchange directions, that means that you must make only one direction request to get a full transaction history.

URL: GET @ https://cryptonit.net/apiv2/rest/public/ccorder
Parameters:

  • bid_currency: Offered currency for selling (optional)
  • ask_currency: Requested currency (optional)
  • type: type of the order. Must be set to "filled"
  • limit: maximum number of returned orders (optional)

You can receive a listing of all transactions by appending your desired parameters at /apiv2/rest/public/ccorder?<paramter>=<value>&..
Once again, if you want for example to receive USD/BTC trades then you just need only one request that has bid_currency=USD&ask_currency=BTC or bid_currency=BTC&ask_currency=USD in parameters. They will return the same list of trades, only drop direction will differ.
The steps are the following:


// REST Server URL
$index_url = "https://cryptonit.net/apiv2/rest/public/ccorder";
// some parameters
$bid_currency = "btc";
$ask_currency = "ltc";
// cURL http headers
$header = array(
"Accept: application/json" // Accept JSON response
);
// cURL
$curl = curl_init($index_url . "?bid_currency=" . $bid_currency . "&ask_currency=" . $ask_currency . "&type=filled");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_HEADER, FALSE); // Ask to not return Header
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); // set header data
// get the response
$response = curl_exec($curl);
// get the http code to check the reply
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Check if index was successful
if ($http_code == 200) {
// Convert json response as array
$orders = json_decode($response);
} else {
// Get error msg
$http_message = curl_error($curl);
die($http_message);
}
print_r($orders);

$orders will contain an array with all open (not filled) orders.

"id": {
"type": XXX, // placed, filled or canceled
"bid_currency": "BTC", // some currency (LTC, USD, etc.)
"ask_currency": "LTC", // some currency (LTC, USD, etc.)
"bid_amount": "4.87696051", // amount in current bid
"ask_amount": "487.696051", // amount in current ask
"bid_rate": "100.0", // bid rate
"ask_rate": "0.01", // ask rate
"created": "12312312" // timestamp when order was placed
"filled": "12312313" // timestamp when order was filled (transaction time)
}

HINT 1:

By default the number of rendered orders or transactions is limited to 100 (or other value that you set using limit parameter). If you want to go deep and see more orders/transactions by appending your GET request URL with page parameter: &page=2 or &page=3 etc...
The higher page is the earlier transactions/order you get.
Please note that maximum limit parameter value is 100, if you set to some value more than 100 it will be reset to 100.

HINT 2:

In JSON output before every item you will see an integer value. It is order_id, a unique value that is assigned to every order and always increases (auto incremented). Use it in the way you like. If you store transactions history on your side for example it may help you to be uptodate with our history. If you attach to your query &id= parameter you will receive orders/transaction with order id higher or equal to the passed id parameter. For example:
cryptonit.net/apiv2/rest/public/ccorder.json?ask_currency=usd&bid_currency=btc&type=filled&id=200000
Use "page=..." and "limit=..." parameters if your request returns more than 100 default records and you want to fetch them all.

How to receive the last rate?

URL: GET @ https://cryptonit.net/apiv2/rest/public/ccorder
Parameters:

  • bid_currency: Offered currency for selling (required)
  • ask_currency: Requested currency (required)
  • rate: Take mean over number of order (required)

You can receive the last rate (the price of the most recent transaction) for a given pair /apiv2/rest/public/ccorder?<paramter>=<value>&.. Both, bid and ask currency must be set. Also rate must be set but can be left empty (rate=). Rate is a positive integer number indicating how many completed orders (transactions) should be taken into account to calculate the average last rate. If rate=1 only last transaction is considered. Please be aware, that 1 cent orders are valid and returned as last rate. Setting rate=5 might be a reasonable decision.
The steps are the following:

// REST Server URL
$index_url = "https://cryptonit.net/apiv2/rest/public/ccorder";
// some parameters
$bid_currency = "usd";
$ask_currency = "btc";
$rate = 5;
// cURL http headers
$header = array(
"Accept: application/json" // Accept JSON response
);
// cURL
$curl = curl_init($index_url . "?bid_currency=" . $bid_currency . "&ask_currency=" . $ask_currency . "&rate=" . $rate);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_HEADER, FALSE); // Ask to not return Header
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
// get the response
$response = curl_exec($curl);
// get the http code to check the reply
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Check if index was successful
if ($http_code == 200) {
// Convert json response as array
$rate = json_decode($response);
} else {
// Get error msg
$http_message = curl_error($curl);
die($http_message);
}
print_r($rate);

$rate will be a float containing the last rate. [745.34]This data is available in our combined Lazy Ticker too, look at the end of this section.

How to receive best ASK/BID price?

You can receive the highest ask price (best ask) or the lowest bid price (best bid) for any pair.

URL: GET @ https://cryptonit.net/apiv2/rest/public/ccorder
Parameters:

  • bid_currency: Offered currency for selling (required)
  • ask_currency: Requested currency (required)
  • best_rate: Must be passed without any value (required)

Both, bid and ask currency must be set. Parameter best_rate must be added. You can receive for example best ask BTC price in USD/BTC trading pair by simple get request:
cryptonit.net/apiv2/rest/public/ccorder?bid_currency=usd&ask_currency=btc&best_rate
The result must be something like:["624.15400000"]

In the similar way you can receive best bid BTC price in USD/BTC trading pair by making get request:
cryptonit.net/apiv2/rest/public/ccorder?bid_currency=btc&ask_currency=usd&best_rate
The result must be something like:["604.22960725"]This data is available in our combined Lazy Ticker too, look at the end of this section.

How to receive high low price per 24 hours?

You can receive the highest and the lowest price of executed transactions (filled orders) during the last 24 hours for any trading pair.

URL: GET @ https://cryptonit.net/apiv2/rest/public/ccorder
Parameters:

  • bid_currency: Offered currency for selling (required)
  • ask_currency: Requested currency (required)
  • best_rate: Must be set to 86400 (required)

Both, bid and ask currency must be set. Parameter best_rate must be passed and set to 86400. For example if you want to receive the lowest BTC price from USD/BTC pair you should make a simple GET request:
cryptonit.net/apiv2/rest/public/ccorder?bid_currency=usd&ask_currency=btc&best_rate=86400
The result must be something like:["618.12100000"]

In the similar way you can receive the highest BTC price from USD/BTC trading pair simply make a get request:
cryptonit.net/apiv2/rest/public/ccorder?bid_currency=btc&ask_currency=usd&best_rate=86400
The result must be something like:["654.27909722"]This data is available in our combined Lazy Ticker too, look at the end of this section.

How to receive trading volume per 24 hours?

You can receive trading volume during the last 24 hours for any trading pair calculated in both ASK and BID currencies.

URL: GET @ https://cryptonit.net/apiv2/rest/public/ccorder
Parameters:

  • bid_currency: Offered currency for selling (required)
  • ask_currency: Requested currency (required)
  • volume: Must be set to 86400 (required)

Both, bid and ask currency must be set. Parameter volume must be passed and set to 86400. For example if you want to receive trading volume in USD/BTC trading pairs you should make a simple GET request:
cryptonit.net/apiv2/rest/public/ccorder?bid_currency=usd&ask_currency=btc&volume=86400
The result must be something like:{"BTC":"289.23750959","USD":"187523.65308000"}This data is available in our combined Lazy Ticker too, look at the end of this section.

How to receive overall current ASK and BID volumes?

You can receive overall current ASK and BID volume. It will be a sum of all BID and ASK orders for some trading pair (volume of the orderbook).

URL: GET @ https://cryptonit.net/apiv2/rest/public/ccorder
Parameters:

  • bid_currency: Offered currency for selling (required)
  • ask_currency: Requested currency (required)
  • volume: Must be passed but without any value(required)

Both, bid and ask currency must be set. Parameter volume must be passed but without any value. For example if you want to receive current BTC bid volume (calculated in BTC) and BTC ask volume (calculated in USD) in USD/BTC trading pair you should make a simple GET request:
cryptonit.net/apiv2/rest/public/ccorder?bid_currency=btc&ask_currency=usd&volume
The result must be something like:{"BTC":"4.95649338","USD":"3495.04171559"}

HINT 3:

If you receive output in XML but not JSON then you should add appropriate http header "Accept: application/json". Thus our server will return you JSON response. If you dont have such a possibility (for example you use php include or fopen instead of CURL) then substitute in example above "ccorder" to "ccorder.json" and you will get JSON independently of JSON http header.For example:
cryptonit.net/apiv2/rest/public/ccorder.json?bid_currency=btc&ask_currency=usd&volume

How to receive a list of supported trading pairs?

You can receive a list of currently supported trading pair with simple GET request:
cryptonit.net/apiv2/rest/public/pairs
and JSON format as usually by simply adding .json:
cryptonit.net/apiv2/rest/public/pairs.json

Combined "Lazy Ticker"

If you do not want to make separated requests to get the most popular trade tickers you may use our Lazy Ticker. It returns the most useful information for a specified trading pair: trading volume for 24 hours, high/low price, best ASK/BID and the last rate (last transaction price).For example:
cryptonit.net/apiv2/rest/public/ccorder?bid_currency=usd&ask_currency=btc&ticker