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

// Nonce example
const nonce = new Date() * 1000;
// Nonce example
<?php

  $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

HTTP General Error Codes (for POST methods)

Code Description
451 Credentials not found
452 API key is not active
453 Nonce value is not valid
454 This API key has no permission to use the endpoint
455 Forbidden. User tier level is too low

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

Request Parameters

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

Error Codes

Code Description
400 Bad request
404 Ticker {ticker} not found

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 100 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

Request Parameters

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

Error Codes

Code Description
400 Bad request
404 Ticker {ticker} not found

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": [
    {
      "name": "BTCEUR",
      "base": "BTC",
      "quote": "EUR",
      "type": "spot",
      "24h_volume": "6.11834936",
      "24h_high": "7929.14",
      "24h_low": "7622.78",
      "best_bid": "7621.02",
      "best_ask": "7653.62",
      "last": "7653.62"
    },
    {
      "name": "ETHEUR",
      "base": "ETH",
      "quote": "EUR",
      "type": "spot",
      "24h_volume": "92.12407318",
      "24h_high": "175.8",
      "24h_low": "170.58",
      "best_bid": "169.29",
      "best_ask": "170.77",
      "last": "170.77"
    }
  ]
}

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

Request Parameters

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

Error Codes

Code Description
404 Asset {asset} not found

Place Limit 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": "10d486d0-2a61-11eb-8188-7b2c438dd9cf",
  "order": {
    "id": "10d486d0-2a61-11eb-8188-7b2c438dd9cf",
    "ticker": "BTCEUR",
    "type": "buy",
    "price": "11250",
    "quantityInitial": "0.01225",
    "quantityRemaining": "0.01225",
    "status": "A"
  }
}

Place limit order

HTTP Request

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

Request Parameters

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

Error Codes

Code Description
400 Parameter "price" or "quantity" is not a number
403 Parameter "type" must be one of these: "buy", "sell"
404 Ticker {ticker} not found
411 Balance not enough to place and order
412 There are opposite orders of this user, trade with self is forbidden
413 Order values are lower than allowed. Min possible order value is ${min_value} ${asset}
414 Account is locked

Place Market Order

/add_market_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_market_order';
const nonce = new Date() * 1000;
// NOTE: all body parameter types must be strings
const buy_order_body = {
  ticker: "BTCEUR",
  type: "buy",
  amount: "5000",
};
const sell_order_body = {
  ticker: "BTCEUR",
  type: "sell",
  quantity: "1.25",
};
const data = qs.stringify(buy_order_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_market_order';

$buy_order_body = array(
    'ticker' => 'BTCEUR',
    'type' => 'buy',
    'amount' => '4500',
);

$sell_order_body = array(
    'ticker' => 'BTCEUR',
    'type' => 'sell',
    'quantity' => '1.25'
);

$postdata = http_build_query($buy_order_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 market order.
Important:
When "type" = "buy", then "amount" is mandatory, and "quantity" cannot be set.
When "type" = "sell", then "quantity" is mandatory, and "amount" cannot be set.

HTTP Request

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

Request Parameters

Name Location Description Required Schema
ticker body E.g BTCEUR Yes string
type body buy/sell Yes string
amount body Order amount No string
quantity body Order quantity No string

Error Codes

Code Description
400 Parameter "amount" or "quantity" is not a number
401 When "type" = "buy", then "amount" is mandatory
402 When "type" = "sell", then "quantity" is mandatory
403 Parameter "type" must be one of these: "buy", "sell"
404 Ticker {ticker} not found
411 Balance not enough to place and order
412 There are opposite orders of this user, trade with self is forbidden
413 Order values are lower than allowed. Min possible order value is ${min_value} ${asset}
414 Account is locked
415 Market order quantity is too low
416 Not enough orders (liquidity) to fill market order

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",
  "order": {
    "id": "10d486d0-2a61-11eb-8188-7b2c438dd9cf",
    "ticker": "BTCEUR",
    "type": "buy",
    "price": "11250",
    "quantityInitial": "0.01225",
    "quantityRemaining": "0.01225",
    "status": "C"
  }
}

Cancel order

HTTP Request

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

Request Parameters

Name Location Description Required Schema
id body Order id Yes string

Error Codes

Code Description
400 Wrong "id" is given
404 Order not found
409 Open order not found

Cancel All Orders

/cancel_all_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 = '/cancel_all_orders';
const nonce = new Date() * 1000;
const body = {
  ticker: "BTCEUR",
};
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_all_orders';
$body = array(
    'ticker' => "BTCEUR"
);
$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 all orders

HTTP Request

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

Request Parameters

Name Location Description Required Schema
ticker body Ticker name Yes string

Error Codes

Code Description
404 Ticker {ticker} not found

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

Request Parameters

Name Location Description Required Schema
id body Order id Yes string

Error Codes

Code Description
400 Wrong "id" is given
404 Order not found

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

Request Parameters

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

Error Codes

Code Description
404 Ticker {ticker} not found

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

Request Parameters

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

Error Codes

Code Description
400 Bad request
404 Ticker {ticker} not found

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

Request 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' no string

Error Codes

Code Description
400 Bad request
404 Asset {asset} not found