Please follow the steps to get access to our API's
API Keys
You have received API Keys through email. If these have not been received, please contact the support team [email protected] and these will be re-sent as soon as possible.
After receiving the API Keys, follow the steps below:
-
You have received two things, an API key, and an API Secret.
-
Using the API Secret, you are required to generate a signature to send in the headers.
-
The headers should contain the following mandatory fields:
- apikey - API key received in the email.
- signature - Need to calculate for each requests.
- timestamp - Needs to be in milliseconds (Eg : 1688465741197).
Signature Calculation
const crypto = require("crypto");
const axios = require("axios");
var secret = "YOUR SECRET KEY";
var timestamp = new Date().getTime().toString();
var signature = crypto
.createHash("sha256")
.update(timestamp)
.update(secret)
.digest("hex");
console.log(signature);
console.log(timestamp);<?php
$secret = 'YOUR SECRET KEY';
$timestamp = floor(microtime(true)*1000);
$signature = hash('sha256',$timestamp.$secret);
echo $signature
?>import hashlib
import time
api_secret = "BITOLO_API_SECRET"
api_key = "BITOLO_API_KEY"
def get_authentication_headers():
try:
timestamp = str(int(time.time() * 1000))
sign = hashlib.sha256(timestamp.encode("utf-8"))
if not api_secret or not api_key:
print("ERROR GENERATING HEADER, CREDENTIALS NOT FOUND")
return {
"status": False,
"message": "Error getting authentication headers, Credentials not found",
}
sign.update(api_secret.encode("utf-8"))
signature = sign.hexdigest()
except Exception as error:
print(f"ERROR GENERATING AUTHENTICATION HEADERS. ERROR - {error}")
return {"status": False, "message": "Error getting authentication headers"}
return {
"result": {
"apikey": api_key,
"signature": signature,
"timestamp": timestamp,
},
}
print(get_authentication_headers())using System;
using System.Text;
using System.Security.Cryptography;
using System.Net.Http;
using System.Threading.Tasks;
namespace ConsoleApp
{
class Program
{
public static string ToHexString(byte[] array)
{
return BitConverter.ToString(array).Replace("-", "").ToLower() ;
}
public static async Task<string> getResponseAsync(String timestamp, String APIKEY , String signature)
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("timestamp", timestamp);
client.DefaultRequestHeaders.Add("apikey", APIKEY);
client.DefaultRequestHeaders.Add("signature", signature);
HttpResponseMessage response = await client.GetAsync("API URL");
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
public string sha256(string timestamp, string secret)
{
var crypt = new SHA256Managed();
string hash = String.Empty;
byte[] _timestamp = Encoding.ASCII.GetBytes(timestamp);
byte[] _secret = Encoding.ASCII.GetBytes(secret);
byte[] comb = Combine(_timestamp, _secret);
byte[] crypto = crypt.ComputeHash(comb);
return ToHexString(crypto);
}
public static byte[] Combine(byte[] first, byte[] second)
{
byte[] ret = new byte[first.Length + second.Length];
Buffer.BlockCopy(first, 0, ret, 0, first.Length);
Buffer.BlockCopy(second, 0, ret, first.Length, second.Length);
return ret;
}
static async Task Main(string[] args)
{
Program h = new Program();
string apikey = "YOUR API KEY";
string secret = "YOU SECRET KEY";
string unixTimestamp = Math.Round((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds).ToString();
string signature = h.sha256( unixTimestamp , secret);
Console.WriteLine(await getResponseAsync(unixTimestamp, apikey, signature));
}
}
}Fields should be included in headers
Requests should be sent with the following headers:
npm install axios
const axios = require('axios');
let config = {
method: 'post',
url: 'https://staging-api.bitolo.tech/deposit',
headers: {
'apikey': '$2a$10$3anMtNa5KuEBxTC/y97YKu7d8JJNVBHxntRakLF79O2yxP4QBINa.',
'signature': 'b196a629ebbeb7bb1bed30852904891dce0d0016aaeefdcb259087ac7f107cef',
'timestamp': '1688465741197',
'Content-Type': 'application/json'
},
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://staging-api.bitolo.tech/deposit")
.method("POST", body)
.addHeader("apikey", "$2a$10$3anMtNa5KuEBxTC/y97YKu7d8JJNVBHxntRakLF79O2yxP4QBINa.")
.addHeader("signature", "b196a629ebbeb7bb1bed30852904891dce0d0016aaeefdcb259087ac7f107cef")
.addHeader("timestamp", "1688465741197")
.build();
Response response = client.newCall(request).execute();import http.client
conn = http.client.HTTPSConnection("staging-api.bitolo.tech")
payload = ''
headers = {
'apikey': '$2a$10$3anMtNa5KuEBxTC/y97YKu7d8JJNVBHxntRakLF79O2yxP4QBINa.',
'signature': 'b196a629ebbeb7bb1bed30852904891dce0d0016aaeefdcb259087ac7f107cef',
'timestamp': '1688465741197'
}
conn.request("POST", "/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))Possible Errors
- Please check whether you have added these there parameters in the header section correctly. If you have received this error.
{"error": {"statusCode": 401,"name": "UnauthorizedError","message": "Authorization header does not contain valid parameters"}}
- Please check whether you have calculated the signature correctly as per mentioned above in the docs. And timestamp should be in milliseconds.
{"error": {"statusCode": 401,"name": "UnauthorizedError","message": "Error verifying api credentials : Invalid Authorization header"}}
- IP error - Only in production. Please provide your Production IP's to whitelist in our Production. In staging Whitelisting is disabled.
{"error":{"statusCode":401,"name":"UnauthorizedError","message":"IP not whitelisted"}}
- Move to next section deposit / withdraw. You have passed the Authentication.
{"error":{"statusCode":400,"name":"BadRequestError","message":"Request body is required","code":"MISSING_REQUIRED_PARAMETER"}}