BtcTurk | Kripto API Documentation
  • General Information
  • API Access Permissions
  • Data Center
  • Recent changes
  • Authentication
    • Authentication V1
    • Usage
  • Public Endpoints
    • All Public Endpoints
    • Get Exchange Info
    • Get Tickers
    • Get OrderBook
    • Get Trades
    • Get OHLC Data
    • Get Kline Data
  • Private Endpoints
    • All Private Endpoints
    • Get Account Balance
    • Get User Transactions
    • Get Fiat Transactions
    • Get Crypto Transactions
    • Get Open Orders
    • Get All Orders
    • Get Single Order
    • Submit an Order
    • Cancel an Order
  • Rate Limits
  • Websocket Feed
    • WebSocket Authentication
    • Channel, Event and Model
    • Models
    • TradingView
  • Errors
  • Error Handling For Order Operations
    • Retry Strategy Guideline
  • Pairs Scale (Quantity/Price)
  • FAQ (Frequently Asked Questions)
  • Contact Us
Powered by GitBook
On this page
  • Trade
  • Trade Transaction Code Example

Was this helpful?

  1. Private Endpoints

Get User Transactions

PreviousGet Account BalanceNextGet Fiat Transactions

Last updated 2 years ago

Was this helpful?

Retrieve all trade transactions.

For all transactions related to the private endpoint, you must authorize before sending your request.

For more information you can check our article.

  • 6 parameters can be used to access user transactions.

  • You can access user transactions with orderId, type, symbol, pairSymbol,startDate and endDate parameters.

  • If the startDate and endDate parameters are not used, the last 30 days of transactions are displayed.

The startDate and endDate parameters must be used with Unix timestamps in milliseconds.

Trade

GET https://api.btcturk.com/api/v1/users/transactions/trade

Query Parameters

Name
Type
Description

orderId

integer

long, Optional you can not combine this parameter with other parameters. So you should send this parameter alone.

type

array

string array, {"buy", "sell"}

symbol

array

string array, {"btc", "try", ...etc.}

startDate

integer

long, Optional timestamp if null will return last 30 days

endDate

integer

long, Optional timestamp if null will return last 30 days

pairSymbol

string

BTCTRY, ETHTRY etc.

Headers

Name
Type
Description

X-PCK*

string

API public key. You can create the API key from the Account > API Access page in your exchange account.

X-Stamp*

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*

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.

{
    "success": true,
    "message": "SUCCESS",
    "code": 0,
    "data": [
        {
            "id": 1181163798924649598,
            "timestamp": 1663848223334,
            "amount": "-0.3384",
            "preciseAmount": -0.3384081100000000,
            "fee": "-0.06297817",
            "tax": "-0.01133607",
            "price": "122.00",
            "numeratorSymbol": "ETHW",
            "denominatorSymbol": "TRY",
            "orderType": "sell",
            "orderId": 10938696222,
            "orderClientId": null
        },
        {
            "id": 1020163798374837834,
            "timestamp": 1663622424245,
            "amount": "-0.01560000",
            "preciseAmount": -0.0156,
            "fee": "-0.00908237",
            "tax": "-0.00163483",
            "price": "1374.0",
            "numeratorSymbol": "ETH",
            "denominatorSymbol": "USDT",
            "orderType": "sell",
            "orderId": 10897282010,
            "orderClientId": "ask"
        },
        {
            "id": 1020163798374837164,
            "timestamp": 1663604612625,
            "amount": "-0.01000000",
            "preciseAmount": -0.01,
            "fee": "-0.01025161",
            "tax": "-0.00184529",
            "price": "1344.1",
            "numeratorSymbol": "ETH",
            "denominatorSymbol": "USDT",
            "orderType": "sell",
            "orderId": 10894536211,
            "orderClientId": "advanced"
        }
    ]
}

Trade Transaction 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 startdate = new DateTime(2019, 11, 19);
var endatet = new DateTime(2019, 12, 19);
var userTrades = apiClientV1.GetUserTrades(new[] { "buy", "sell" }, new[] { "try", "btc" }, startdate.ToUnixTime(), endatet.ToUnixTime());

if (userTrades.Result.Success)
{
    foreach (var userTrade in userTrades.Result.Data)
    {
        Console.WriteLine(userTrade);
    }
}c
<?php
$base = "https://api.btcturk.com";
$apiKey = "YOUR_API_PUBLIC_KEY";
$apiSecret = "YOUR_API_SECRET";
$method = "/api/v1/users/transactions/trade?type=buy&type=sell&symbol=btc&symbol=try&symbol=usdt";
$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_HTTPHEADER, $headers);
$result = curl_exec($ch);

if (curl_errno($ch)) {
    print_r(curl_error($ch));
}
$answer = json_decode($result);
print_r($answer);
import time, base64, hmac, hashlib, requests, json

base = "https://api.btcturk.com"
method = "/api/v1/users/transactions/trade?type=buy&type=sell&symbol=btc&symbol=try&symbol=usdt"
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.get(url=uri, headers=headers)
result = result.json()
print(json.dumps(result, indent=2))
publicKey := "PUBLIC_KEY_HERE"
privateKey := "PRIVATE_KEY_HERE"

base       = "https://api.btcturk.com"
method     = "/api/v1/users/transactions/trade"
uri        = base + method

key, error := base64.StdEncoding.DecodeString(privateKey)

if error != nil {
	return error
}

nonce := fmt.Sprint(time.Now().UTC().UnixMilli())
message := publicKey + nonce
hmac := hmac.New(sha256.New, key)
hmac.Write([]byte(message))
signature := base64.StdEncoding.EncodeToString(hmac.Sum(nil))

request, _ := http.NewRequest("GET", uri, nil)

request.Header.Set("X-PCK", publicKey)
request.Header.Set("X-Stamp", nonce)
request.Header.Set("X-Signature", signature)
request.Header.Set("Content-Type", "application/json")

response, _ := http.DefaultClient.Do(request)

defer response.Body.Close()
body, _ := ioutil.ReadAll(response.Body)

fmt.Println(response)
fmt.Println(string(body))
const API_KEY = "API_KEY_HERE"
const API_SECRET = "API_SECRET_HERE"

const base = 'https://api.btcturk.com'
const method = '/api/v1/users/transactions/trade'
const uri = base+method;

const options = {method: 'GET', headers: authentication()};

fetch(uri, options)
    .then(res => res.json())
    .then(json => console.log(json))
    .catch(err => console.error('error:' + err));


function authentication() {
    const stamp = (new Date()).getTime()
    const data = Buffer.from(`${API_KEY}${stamp}`, 'utf8')
    const buffer = crypto.createHmac('sha256', Buffer.from(API_SECRET, 'base64'))
    buffer.update(data)
    const digest = buffer.digest()
    const signature = Buffer.from(digest.toString('base64'), 'utf8').toString('utf8')

    return {
        "Content-type": 'application/json',
        "X-PCK": API_KEY,
        "X-Stamp": stamp.toString(),
        "X-Signature": signature,
    }
}
public_key = 'PUBLIC_KEY_HERE'
private_key = 'PRIVATE_KEY_HERE'

uri = URI.parse("https://api.btcturk.com/api/v1/users/transactions/trade")
timestamp = Time.now.to_i*1000
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri)

data = public_key + timestamp.to_s
private_key = Base64.decode64(private_key).strip
digest = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), private_key, data)
sign = Base64.encode64(digest).strip

request['Content-type'] = 'application/json'
request['X-PCK'] = public_key
request['X-Stamp'] = timestamp.to_s
request['X-Signature'] = sign

response = http.request(request)
puts response.read_body
Authentication V1