Cancel Order

delete
Cancel Order

https://api.btcturk.com/api/v1/order
Request
Response
Request
Headers
X-PCK
required
string
API public key. You can create the API key from the Account > API Access page in your exchange account.
X-Stamp
required
integer
Nonce must be current timestamp in miliseconds. It is a must to sync your current time with API server time which is in miliseconds format. Our servers are using UTC timezone.
X-Signature
required
string
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.
Query Parameters
id
required
integer
id of the order
Response
200: OK
Returns true if cancellation is successful, false if failed.
{
"success": true,
"message": "string",
"code": "",
"data": {
}
}

C# Code Example

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

Python Code Example

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 Code Example

<?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);