NAV Navbar
NodeJS PHP

Introduction

Welcome to the Bitlocus API! You can use our API to access public data as well as your personal account.

We have language bindings in JavaScript (NodeJS) and PHP! Every API endpoint has example available on these languages.

Also check our published client libraries:

General usage

All API calls should use the base URL https://api.bitlocus.com

Public data API endpoints use GET method.

Private data API endpoints must use POST and require authentication.

Authentication

Private data API endpoints require authentication.

Authentication is made the same way as in majority other cryptocurrency exchanges. It uses nonce and message signature, which are passed as HTTP headers.

Nonce

const nonce = new Date() * 1000;
$nonce = explode(' ', microtime());
$nonce = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');

A nonce is an arbitrary number used only once in a cryptographic communication. Nonce is used to ensure old communications cannot be reused in replay attacks.

We recommend time-based incremental unsigned 64 bit integer for nonce generation.

Message signature

const crypto = require('crypto');
const qs = require('qs');
const API_SECRET = { YOUR API SECRET }

const path = '/balance';
const nonce = new Date() * 1000;
//  If no body parameters , leave it empty (const body = {})
const body = {
  asset: 'EUR', //Optional
};
const data = qs.stringify(body);
const signature = getSignature(path, data, API_SECRET, nonce);

function getSignature(path, data, secret, nonce) {
  const secret_buffer = new Buffer.from(secret, 'base64');
  const hash = new crypto.createHash('sha256');
  const hmac = new crypto.createHmac('sha512', secret_buffer);
  const hash_digest = hash.update(nonce + data).digest('binary');
  const hmac_digest = hmac
    .update(path + hash_digest, 'binary')
    .digest('base64');
  return hmac_digest;
}
<?php

$API_SECRET = { YOUR API SECRET };

$path = '/balance';
// If no parameters, leave body empty array. $body = []
$body = array(
    'asset' => 'EUR', // Optional
);
$postdata = http_build_query($body, '', '&');

$nonce = explode(' ', microtime());
$nonce = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');

$hash = $path . hash('sha256', $nonce . $postdata, true);
$signature = hash_hmac('sha512', $hash, base64_decode($API_SECRET), true);
$signature = base64_encode($signature);

?>

To generate hash of message signature, HMAC is used. Please check how this is done in different languages.

HTTP headers (for POST methods)

These headers should be added to every POST call which requires authentication.

Name Description Required Schema
api-key Your api key Yes string
api-sign Signature Yes string
nonce Nonce Yes string
Content-Type 'application/x-www-form-urlencoded' Yes string

Public API endpoints

Get last trades

/trade_history/{ticker}

const axios = require('axios');

const API_URL = 'https://api.bitlocus.com'
const ticker = 'BTCEUR';
const query = '?limit=50&offset=0';

const url =
  API_URL + '/trade_history/' + ticker + query

axios
  .get(url)
  .then(response => {
    const result = response.data;
  })
  .catch(e => console.log(e));
<?php
$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';
$ticker = 'BTCEUR';
$query = '&limit=50&offset=0'

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . '/trade_history/' . $ticker . $query
));

$response = curl_exec($curl);

curl_close($curl);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "Trades of BTCEUR ticker",
  "trades": [
    {
      "id": "f46248d9-326f-405d-bfca-508e949116ad",
      "price": "5560.58",
      "quantity": "0.74821107",
      "amount": "4160.48",
      "ticker": "BTCEUR",
      "taker": "B",
      "created_at": "2018-10-06 10:13:57"
    },
    {
      "id": "asdf1554-326f-405d-bfca-508e949116ad",
      "price": "5570.68",
      "quantity": "0.04834522",
      "amount": "269.31",
      "ticker": "BTCEUR",
      "taker": "S",
      "created_at": "2018-10-06 10:13:59"
    }
  ]
}

This endpoint returns last 50 trades in exchange for ticker.

HTTP Request

GET https://api.bitlocus.com/trade_history/:ticker

Parameters

Name Location Description Required Schema
ticker path Ticker e.g. BTCEUR (uppercase) Yes string
limit query Default 50 No integer
offset query Default 0 No integer

Get best bids and asks

/order_book/{ticker}

const axios = require('axios');

const API_URL = 'https://api.bitlocus.com'
const ticker = 'BTCEUR';

const url =
  API_URL + '/order_book/' + ticker;

axios
  .get(url)
  .then(response => {
    const result = response.data;
  })
  .catch(e => console.log(e));
<?php
$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';
$ticker = 'BTCEUR';

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . '/order_book/' . $ticker
));

$resp = curl_exec($curl);

curl_close($curl);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "Success message",
  "data": {
    "bids": [
      {
        "price": "5000",
        "quantity": "0.25"
      },
      {
        "price": "5000",
        "quantity": "0.25"
      },
      {
        "price": "5000",
        "quantity": "0.25"
      }
    ],
    "asks": [
      {
        "price": "7000",
        "quantity": "0.01"
      }
    ]
  }
}

Returns current best 50 bids and asks in exchange for ticker (bids in descending order, asks in ascending order)

HTTP Request

GET https://api.bitlocus.com/order_book/:ticker

Parameters

Name Location Description Required Schema
ticker path Ticker e.g. BTCEUR (uppercase) Yes string

Get available markets

/markets

const axios = require('axios');
const API_URL = 'https://api.bitlocus.com'
axios
  .get(API_URL + '/markets')
  .then(response => {
    const result = response.data;
  })
  .catch(e => console.log(e));
<?php
$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . '/markets'
));

$resp = curl_exec($curl);

curl_close($curl);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "Available tickers",
  "tickers": {
    "BTCEUR": {
      "base": "BTC",
      "quote": "EUR"
    },
    "BTCUSD": {
      "base": "BTC",
      "quote": "USD"
    }
  }
}

Returns available tickers (markets)

HTTP Request

GET https://api.bitlocus.com/markets

Private API endpoints

Get balance

/balance/{asset}

const crypto = require('crypto');
const axios = require('axios');
const qs = require('qs');

const API_URL = 'https://api.bitlocus.com';
const API_KEY = { YOUR API KEY }
const API_SECRET = { YOUR API SECRET }

const path = '/balance';
const nonce = new Date() * 1000;
//  If no body parameters , leave it empty (const body = {})
const body = {
  asset: 'EUR', //Optional
};
const data = qs.stringify(body);
const signature = getSignature(path, data, API_SECRET, nonce);
const options = {
  method: 'post',
  url: API_URL + path,
  data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'api-key': API_KEY,
    'api-sign': signature,
    nonce: nonce,
  },
};
axios(options)
  .then(response => {
    const result = response.data;
  })
  .catch(e => console.log(e.response.data));

function getSignature(path, data, secret, nonce) {
  const secret_buffer = new Buffer.from(secret, 'base64');
  const hash = new crypto.createHash('sha256');
  const hmac = new crypto.createHmac('sha512', secret_buffer);
  const hash_digest = hash.update(nonce + data).digest('binary');
  const hmac_digest = hmac
    .update(path + hash_digest, 'binary')
    .digest('base64');
  return hmac_digest;
}
<?php

$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';
$API_KEY = { YOUR API KEY };
$API_SECRET = { YOUR API SECRET };

$path = '/balance';
// If no parameters, leave body empty array. $body = []
$body = array(
    'asset' => 'EUR', // Optional
);
$postdata = http_build_query($body, '', '&');

$nonce = explode(' ', microtime());
$nonce = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');

$hash = $path . hash('sha256', $nonce . $postdata, true);
$signature = hash_hmac('sha512', $hash, base64_decode($API_SECRET), true);
$signature = base64_encode($signature);

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . $path,
    CURLOPT_POST => 1,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/x-www-form-urlencoded',
      'api-key: ' . $API_KEY,
      'api-sign: ' . $signature,
        'nonce: ' . $nonce
    ),
    CURLOPT_POSTFIELDS => $postdata
));

$response = curl_exec($curl);

curl_close($curl);

print_r($response);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "User Balances",
  "balances": [
    {
      "asset": "EUR",
      "available_balance": "1520.00",
      "total_balance": "1560.00",
      "reserved": "40.00"
    },
    {
      "asset": "BTC",
      "available_balance": "1.00001500",
      "total_balance": "1.50001500",
      "reserved": "0.50000000"
    }
  ]
}

This endpoint returns user account balances for:

HTTP Request

POST https://api.bitlocus.com/balance

Parameters

Name Location Description Required Schema
asset body E.g EUR, BTC, ETH or other (uppercase) No string

Place Order

/add_limit_order

const crypto = require('crypto');
const axios = require('axios');
const qs = require('qs');

const API_URL = 'https://api.bitlocus.com';
const API_KEY = { YOUR API KEY }
const API_SECRET = { YOUR API SECRET }

const path = '/add_limit_order';
const nonce = new Date() * 1000;
// NOTE: all body parameter types must be strings
const body = {
  ticker: "BTCEUR",
  type: "buy",
  price: "5000",
  quantity: "0.25",
};
const data = qs.stringify(body);
const signature = getSignature(path, data, API_SECRET, nonce);
const options = {
  method: 'post',
  url: API_URL + path,
  data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'api-key': API_KEY,
    'api-sign': signature,
    nonce,
  },
};

axios(options)
  .then(response => {
    const result = response.data;
  })
  .catch(e => console.log(e.response.data));

function getSignature(path, data, secret, nonce) {
  const secret_buffer = new Buffer.from(secret, 'base64');
  const hash = new crypto.createHash('sha256');
  const hmac = new crypto.createHmac('sha512', secret_buffer);
  const hash_digest = hash.update(nonce + data).digest('binary');
  const hmac_digest = hmac
    .update(path + hash_digest, 'binary')
    .digest('base64');
  return hmac_digest;
}
<?php

$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';
$API_KEY = { YOUR API KEY };
$API_SECRET = { YOUR API SECRET };

$path = '/add_limit_order';
$body = array(
    'ticker' => 'BTCEUR',
    'type' => 'buy',
    'price' => '4500',
    'quantity' => '0.01'
);
$postdata = http_build_query($body, '', '&');

$nonce = explode(' ', microtime());
$nonce = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');

$hash = $path . hash('sha256', $nonce . $postdata, true);
$signature = hash_hmac('sha512', $hash, base64_decode($API_SECRET), true);
$signature = base64_encode($signature);

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . $path,
    CURLOPT_POST => 1,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/x-www-form-urlencoded',
      'api-key: ' . $API_KEY,
      'api-sign: ' . $signature,
        'nonce: ' . $nonce
    ),
    CURLOPT_POSTFIELDS => $postdata
));

$response = curl_exec($curl);

curl_close($curl);

print_r($response);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "Order placed successfully",
  "id": "f18cde40-3ff1-11e9-9dca-c5201463d22f"
}

Place limit order

HTTP Request

POST https://api.bitlocus.com/add_limit_order

Parameters

Name Location Description Required Schema
ticker body E.g BTCEUR (uppercase) Yes string
type body buy/sell Yes string
price body Order price Yes string
quantity body Order quantity Yes string

Cancel Order

/cancel

const crypto = require('crypto');
const axios = require('axios');
const qs = require('qs');

const API_URL = 'https://api.bitlocus.com';
const API_KEY = { YOUR API KEY }
const API_SECRET = { YOUR API SECRET }

const path = '/cancel';
const nonce = new Date() * 1000;
const body = {
  id: "f18cde40-3ff1-11e9-9dca-c5201463d22f",
};
const data = qs.stringify(body);
const signature = getSignature(path, data, API_SECRET, nonce);
const options = {
  method: 'post',
  url: API_URL + path,
  data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'api-key': API_KEY,
    'api-sign': signature,
    nonce,
  },
};

axios(options)
  .then(response => {
    const result = response.data;

  })
  .catch(e => console.log(e.response.data));

function getSignature(path, data, secret, nonce) {
  const secret_buffer = new Buffer.from(secret, 'base64');
  const hash = new crypto.createHash('sha256');
  const hmac = new crypto.createHmac('sha512', secret_buffer);
  const hash_digest = hash.update(nonce + data).digest('binary');
  const hmac_digest = hmac
    .update(path + hash_digest, 'binary')
    .digest('base64');
  return hmac_digest;
}
<?php

$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';
$API_KEY = { YOUR API KEY };
$API_SECRET = { YOUR API SECRET };

$path = '/cancel';
$body = array(
    'id' => "f18cde40-3ff1-11e9-9dca-c5201463d22f"
);
$postdata = http_build_query($body, '', '&');

$nonce = explode(' ', microtime());
$nonce = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');

$hash = $path . hash('sha256', $nonce . $postdata, true);
$signature = hash_hmac('sha512', $hash, base64_decode($API_SECRET), true);
$signature = base64_encode($signature);

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . $path,
    CURLOPT_POST => 1,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/x-www-form-urlencoded',
      'api-key: ' . $API_KEY,
      'api-sign: ' . $signature,
        'nonce: ' . $nonce
    ),
    CURLOPT_POSTFIELDS => $postdata
));

$response = curl_exec($curl);

curl_close($curl);

print_r($response);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "Success message"
}

Cancel order

HTTP Request

POST https://api.bitlocus.com/cancel

Parameters

Name Location Description Required Schema
id body Order id Yes string

Order info

/order_info

const crypto = require('crypto');
const axios = require('axios');
const qs = require('qs');

const API_URL = 'https://api.bitlocus.com';
const API_KEY = { YOUR API KEY }
const API_SECRET = { YOUR API SECRET }

const path = '/order_info';
const nonce = new Date() * 1000;
const body = {
  id: "f18cde40-3ff1-11e9-9dca-c5201463d22f",
};
const data = qs.stringify(body);
const signature = getSignature(path, data, API_SECRET, nonce);
const options = {
  method: 'post',
  url: API_URL + path,
  data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'api-key': API_KEY,
    'api-sign': signature,
    nonce,
  },
};

axios(options)
  .then(response => {
    const result = response.data;
  })
  .catch(e => console.log(e.response.data));

function getSignature(path, data, secret, nonce) {
  const secret_buffer = new Buffer.from(secret, 'base64');
  const hash = new crypto.createHash('sha256');
  const hmac = new crypto.createHmac('sha512', secret_buffer);
  const hash_digest = hash.update(nonce + data).digest('binary');
  const hmac_digest = hmac
    .update(path + hash_digest, 'binary')
    .digest('base64');
  return hmac_digest;
}
<?php

$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';
$API_KEY = { YOUR API KEY };
$API_SECRET = { YOUR API SECRET };

$path = '/order_info';
$body = array(
    'id' => "f18cde40-3ff1-11e9-9dca-c5201463d22f"
);
$postdata = http_build_query($body, '', '&');

$nonce = explode(' ', microtime());
$nonce = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');

$hash = $path . hash('sha256', $nonce . $postdata, true);
$signature = hash_hmac('sha512', $hash, base64_decode($API_SECRET), true);
$signature = base64_encode($signature);

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . $path,
    CURLOPT_POST => 1,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/x-www-form-urlencoded',
      'api-key: ' . $API_KEY,
      'api-sign: ' . $signature,
        'nonce: ' . $nonce
    ),
    CURLOPT_POSTFIELDS => $postdata
));

$response = curl_exec($curl);

curl_close($curl);

print_r($response);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "Order info",
  "order": {
    "id": "f18cde40-3ff1-11e9-9dca-c5201463d22f",
    "ticker": "BTCEUR",
    "type": "buy",
    "price": "6000",
    "quantityInitial": "2",
    "quantityRemaining": "0",
    "status": "F",
    "trades": [
      {
        "id": "c72ebd70-40dd-11e9-ac0a-f996fd116bda",
        "orderId": "f18cde40-3ff1-11e9-9dca-c5201463d22f",
        "ticker": "BTCEUR",
        "type": "buy",
        "quantity": "0.12512222",
        "price": "5556.54",
        "amount": "695.25",
        "appliedFee": "0.2",
        "chargedFee": "1.39",
        "side": "taker",
        "createdAt": "2018-06-05T05:42:27.980Z"
      },
      {
        "id": "c72ebd70-40dd-11e9-ac0a-f996fd116bda",
        "orderId": "f18cde40-3ff1-11e9-9dca-c5201463d22f",
        "ticker": "BTCEUR",
        "type": "buy",
        "quantity": "0.51244488",
        "price": "5556.54",
        "amount": "2847.42",
        "appliedFee": "0.2",
        "chargedFee": "5.69",
        "side": "taker",
        "createdAt": "2018-06-05T05:45:00.000Z"
      }
    ]
  }
}

Returns data for particular order.

HTTP Request

POST https://api.bitlocus.com/order_info

Parameters

Name Location Description Required Schema
id body Order id Yes string

Open orders

/open_orders

const crypto = require('crypto');
const axios = require('axios');
const qs = require('qs');

const API_URL = 'https://api.bitlocus.com';
const API_KEY = { YOUR API KEY }
const API_SECRET = { YOUR API SECRET }

const path = '/open_orders';
const nonce = new Date() * 1000;
const body = {
  ticker: 'BTCEUR', // Optional
};
const data = qs.stringify(body);
const signature = getSignature(path, data, API_SECRET, nonce);
const options = {
  method: 'post',
  url: API_URL + path,
  data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'api-key': API_KEY,
    'api-sign': signature,
    nonce,
  },
};

axios(options)
  .then(response => {
    const result = response.data;
  })
  .catch(e => console.log(e.response.data));

function getSignature(path, data, secret, nonce) {
  const secret_buffer = new Buffer.from(secret, 'base64');
  const hash = new crypto.createHash('sha256');
  const hmac = new crypto.createHmac('sha512', secret_buffer);
  const hash_digest = hash.update(nonce + data).digest('binary');
  const hmac_digest = hmac
    .update(path + hash_digest, 'binary')
    .digest('base64');
  return hmac_digest;
}
<?php

$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';
$API_KEY = { YOUR API KEY };
$API_SECRET = { YOUR API SECRET };

$path = '/open_orders';
// If no parameters, leave body empty array. $body = []
$body = array(
    'ticker' => 'BTCEUR', // Optional
);
$postdata = http_build_query($body, '', '&');

$nonce = explode(' ', microtime());
$nonce = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');

$hash = $path . hash('sha256', $nonce . $postdata, true);
$signature = hash_hmac('sha512', $hash, base64_decode($API_SECRET), true);
$signature = base64_encode($signature);

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . $path,
    CURLOPT_POST => 1,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/x-www-form-urlencoded',
      'api-key: ' . $API_KEY,
      'api-sign: ' . $signature,
        'nonce: ' . $nonce
    ),
    CURLOPT_POSTFIELDS => $postdata
));

$response = curl_exec($curl);

curl_close($curl);

print_r($response);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "Open orders for user",
  "orders": [
    {
      "ticker": "BTCEUR",
      "type": "buy",
      "price": "1.88",
      "quantityInitial": "0.000005",
      "quantityRemaining": "0.000005",
      "status": "A",
      "trades": [
        {
          "id": "05462cc0-40c9-11e9-a663-790245010812",
          "orderId": "c72ebd70-40dd-11e9-ac0a-f996fd116bda",
          "ticker": "BTCEUR",
          "type": "buy",
          "quantity": "0.12512222",
          "price": "5556.54",
          "amount": "695.25",
          "appliedFee": "0.2",
          "chargedFee": "1.39",
          "side": "taker",
          "createdAt": "2018-06-05T05:42:27.980Z"
        },
        {
          "id": "c72ebd70-40dd-11e9-ac0a-f996fd116bda",
          "orderId": "c72ebd70-40dd-11e9-ac0a-f996fd116bda",
          "ticker": "BTCEUR",
          "type": "buy",
          "quantity": "0.51244488",
          "price": "5556.54",
          "amount": "2847.42",
          "appliedFee": "0.2",
          "chargedFee": "5.69",
          "side": "taker",
          "createdAt": "2018-06-05T05:45:00.000Z"
        }
      ]
    },
    {
      "ticker": "BTCEUR",
      "type": "buy",
      "price": "1.25",
      "quantityInitial": "0.000003",
      "quantityRemaining": "0.000003",
      "status": "A",
      "trades": [
        {
          "id": "f2187c70-3ff1-11e9-9dca-c5201463d22f",
          "orderId": "f1a14610-3ff0-11e9-9dca-c5201463d22f",
          "ticker": "BTCEUR",
          "type": "buy",
          "quantity": "0.12512222",
          "price": "5556.54",
          "amount": "695.25",
          "appliedFee": "0.2",
          "chargedFee": "1.39",
          "side": "taker",
          "createdAt": "2018-06-05T05:42:27.980Z"
        },
        {
          "id": "8c9b0a70-3ff1-11e9-9dca-c5201463d22f",
          "orderId": "f1a14610-3ff0-11e9-9dca-c5201463d22f",
          "ticker": "BTCEUR",
          "type": "buy",
          "quantity": "0.51244488",
          "price": "5556.54",
          "amount": "2847.42",
          "appliedFee": "0.2",
          "chargedFee": "5.69",
          "side": "taker",
          "createdAt": "2018-06-05T05:45:00.000Z"
        }
      ]
    }
  ]
}

Returns open (active) orders for user.

HTTP Request

POST https://api.bitlocus.com/open_orders

Parameters

Name Location Description Required Schema
ticker body E.g. BTCEUR (uppercase) No string

User Trades

/user_trades

const crypto = require('crypto');
const axios = require('axios');
const qs = require('qs');

const API_URL = 'https://api.bitlocus.com';
const API_KEY = { YOUR API KEY }
const API_SECRET = { YOUR API SECRET }

const path = '/user_trades';
const nonce = new Date() * 1000;
//  If no body parameters , leave it empty (const body = {})
const body = {
  ticker: 'BTCEUR', // optional
};
const data = qs.stringify(body);
const signature = getSignature(path, data, API_SECRET, nonce);
// Default limit = 50, offset=0
const query = '?limit=100&offset=0';
const options = {
  method: 'post',
  url: API_URL + path + query,
  data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'api-key': API_KEY,
    'api-sign': signature,
    nonce,
  },
};

axios(options)
  .then(response => {
    const result = response.data;
  })
  .catch(e => console.log(e.response.data));

function getSignature(path, data, secret, nonce) {
  const secret_buffer = new Buffer.from(secret, 'base64');
  const hash = new crypto.createHash('sha256');
  const hmac = new crypto.createHmac('sha512', secret_buffer);
  const hash_digest = hash.update(nonce + data).digest('binary');
  const hmac_digest = hmac
    .update(path + hash_digest, 'binary')
    .digest('base64');
  return hmac_digest;
}
<?php

$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';
$API_KEY = { YOUR API KEY };
$API_SECRET = { YOUR API SECRET };

$path = '/user_trades';
// If no parameters, leave body empty array. $body = []
$body = array(
    'ticker' => 'BTCEUR', // Optional
);
$postdata = http_build_query($body, '', '&');

$nonce = explode(' ', microtime());
$nonce = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');

$hash = $path . hash('sha256', $nonce . $postdata, true);
$signature = hash_hmac('sha512', $hash, base64_decode($API_SECRET), true);
$signature = base64_encode($signature);

$query = '?limit=100&offset=0';

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . $path . $query,
    CURLOPT_POST => 1,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/x-www-form-urlencoded',
      'api-key: ' . $API_KEY,
      'api-sign: ' . $signature,
        'nonce: ' . $nonce
    ),
    CURLOPT_POSTFIELDS => $postdata
));

$response = curl_exec($curl);

curl_close($curl);

print_r($response);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "Last trades",
  "trades": {
    "count": 2,
    "rows": [
      {
        "id": "8c9b0a70-3ff1-11e9-9dca-c5201463d22f",
        "orderId": "556b8670-5aa3-11e9-9cba-61ca657a8df2",
        "ticker": "BTCEUR",
        "type": "sell",
        "quantity": "1",
        "price": "1000",
        "amount": "1000",
        "appliedFee": "0.2",
        "chargedFee": "2",
        "side": "taker",
        "createdAt": "2018-10-25T06:11:31.119Z"
      },
      {
        "id": "8f2b2b30-3ff1-11e9-9dca-c5201463d22f",
        "orderId": "64b09870-5b5a-11e9-ac81-6d5c32031cef",
        "ticker": "BTCEUR",
        "type": "buy",
        "quantity": "0.005",
        "price": "123456",
        "amount": "617.28",
        "appliedFee": "0.1",
        "chargedFee": "0.61",
        "side": "maker",
        "createdAt": "2018-10-25T06:01:49.779Z"
      }
    ]
  }
}

Returns last 50 trades for user.

HTTP Request

POST https://api.bitlocus.com/user_trades

Parameters

Name Location Description Required Schema
limit query Default 50 no integer
offset query Defualt 0 no integer
ticker body Ticker e.g "BTCEUR"(uppercase) no string

User Payments

/payments

const crypto = require('crypto');
const axios = require('axios');
const qs = require('qs');

const API_URL = 'https://api.bitlocus.com';
const API_KEY = { YOUR API KEY }
const API_SECRET = { YOUR API SECRET }

const path = '/payments';
const nonce = new Date() * 1000;
//  If no body parameters , leave it empty (const body = {})
const body = {
  asset: 'BTC', // optional
};
const data = qs.stringify(body);
const signature = getSignature(path, data, API_SECRET, nonce);
const query = '?limit=100&offset=0';
const options = {
  method: 'post',
  url: API_URL + path + query,
  data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'api-key': API_KEY,
    'api-sign': signature,
    nonce,
  },
};

axios(options)
  .then(response => {
    const result = response.data;
  })
  .catch(e => console.log(e.response.data));

function getSignature(path, data, secret, nonce) {
  const secret_buffer = new Buffer.from(secret, 'base64');
  const hash = new crypto.createHash('sha256');
  const hmac = new crypto.createHmac('sha512', secret_buffer);
  const hash_digest = hash.update(nonce + data).digest('binary');
  const hmac_digest = hmac
    .update(path + hash_digest, 'binary')
    .digest('base64');
  return hmac_digest;
}
<?php

$curl = curl_init();

$API_URL = 'https://api.bitlocus.com';
$API_KEY = { YOUR API KEY };
$API_SECRET = { YOUR API SECRET };

$path = '/payments';
// If no parameters, leave body empty array. $body = []
$body = array(
    'asset' => 'EUR', // Optional
);
$postdata = http_build_query($body, '', '&');

$nonce = explode(' ', microtime());
$nonce = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');

$hash = $path . hash('sha256', $nonce . $postdata, true);
$signature = hash_hmac('sha512', $hash, base64_decode($API_SECRET), true);
$signature = base64_encode($signature);

$query = '?limit=100&offset=0';

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $API_URL . $path . $query,
    CURLOPT_POST => 1,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array(
      'Content-Type: application/x-www-form-urlencoded',
      'api-key: ' . $API_KEY,
      'api-sign: ' . $signature,
        'nonce: ' . $nonce
    ),
    CURLOPT_POSTFIELDS => $postdata
));

$response = curl_exec($curl);

curl_close($curl);

print_r($response);
?>

The above command returns JSON structured like this:

{
  "success": true,
  "message": "Last payments",
  "payments": [
    {
      "id": "64b09870-5b5a-11e9-ac81-6d5c32031cef",
      "type": "Deposit",
      "asset": "BTC",
      "amount": "0.12512222",
      "fee": "0",
      "status": "Done",
      "createdAt": "2018-06-05T05:42:27.980Z"
    },
    {
      "id": "75a61bf0-59d4-11e9-be6e-39cc1269b06c",
      "type": "Withdrawal",
      "asset": "EUR",
      "amount": "1005.45",
      "fee": "5",
      "status": "Initiated",
      "createdAt": "2018-06-14T06:55:00.000Z"
    }
  ]
}

Returns user payments

HTTP Request

POST https://api.bitlocus.com/payments

Parameters

Name Location Description Required Schema
limit query Default 50 no integer
offset query Default 0 no integer
asset body Asset e.g 'EUR', 'BTC' (uppercase) no string