How to place an order via the API?

Server Time - 8.02 18 Jan

BTC Price - $881.443

LTC Price - $2.93999

URL: POST @ https://cryptonit.net/apiv2/rest/developer/ccorder
Parameters:

  • bid_currency: Offered currency for selling
  • ask_currency: Requested currency
  • bid_amount: The amount you want to offer in this order
  • ask_amount: The amount you are requesting in this order
  • nonce: nonce parameter increasing with every request
  • timestamp: timestamp when request was signed (optional)

You can place an order by posting your desired pair together with the amount your are offering and requesting at /apiv2/rest/developer/ccorder. The exchange will calculate the correct rate from the amounts.
The steps are the following:

// the currency you are offering
$bid_currency = "LTC";
// the currency you are requesting
$ask_currency = "BTC";
// the amount you are offering
$bid_amount = 1.0;
// the amount your are requesting
$ask_amount = 0.005899;
// a timestamp
$timestamp = time()
// nonce parameter. you may use the timestamp for this
$nonce = $timestamp;
$place_data = array(
"bid_currency" = $bid_currency,
"ask_currency" = $ask_currency,
"bid_amount" = $bid_amount,
"ask_amount" = $ask_amount,
"timestamp" = $timestamp,
"nonce" = $nonce
);
// encode the data as JSON
$data = json_encode($place_data);
// REST Server URL
$place_url = "https://cryptonit.net/apiv2/rest/developer/ccorder";
// cURL http headers including Authorization Bearer header with your API key
$header = array(
"Accept: application/json", // Accept JSON response
"Content-Type: application/json", // Send JSON
"Authorization: Bearer <your token>"
);
$curl = curl_init($place_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Set POST data
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 withdraw 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);
}

$orders will be an array containing your order details indexed by its id.