ECN Documentation
  • Home
  • Quick Start
  • Reference
    • API Reference
      • Connection Test
      • Securities
      • Client
      • Trade
      • Wallet
      • Websocket
        • Portfolio
        • Order Book
      • Security Prices
Powered by GitBook
On this page
  • Get your API keys
  • HTTP Request Header

Quick Start

PreviousHomeNextAPI Reference

Last updated 3 years ago

Good to know: A quick start guide can be good to help folks get up and running with your API in a few steps. Some people prefer diving in with the basics rather than meticulously reading every page of documentation!

Get your API keys

Our API uses for parameters encryption. This means that all API parameters must be encrypted using this algorithm with the keys that has been shared.

All requests body to the web server must be JSON encoded as all responses you will get from the server will also be.

HTTP Request Header

All API calls must have all needed headers set. The headers format is as below:

API-KEY

API Key that is shared

REQUEST-TS

ISO standard timestamps. Format (yyyy-MM-dd’T’HH:mm:ssZ)

HASH-KEY

Request Hash

Generating HASH-KEY

// generating hash_key
var crypto = require('crypto');

const https = require('https')

const API_SECRET = '...'
const API_KEY = '...'

const currentDate = new Date()
const concatenatedString = API_SECRET + currentDate.toISOString() + API_KEY
const hash_string = crypto.createHash('sha256').update(concatenatedString,'utf-8').digest('hex');

const headers = {
    'API-KEY': API_KEY,
    'REQUEST-TS': currentDate,
    'HASH-KEY': hash_string
}

# perform your request here
import hashlib
from django.utils import timezone

API_SECRET = '...'
API_KEY = '...'

current_datetime = timezone.now()
concatenated_string = API_SECRET + str(current_datetime) + API_KEY
hash_string = hashlib.sha256((concatenated_string).encode('utf8')).hexdigest()

request_header = {
    'API-KEY': API_KEY,
    'REQUEST-TS': current_datetime,
    'HASH-KEY': hash_string
}

# perform your request here
<?php
  $API_SECRET = "...";
  $API_KEY = "...";
  
  $date = new DateTime("now", new DateTimeZone('Africa/Lagos') );
  $current_datetime = $date->format('Y-m-d H:i:s.uP');
  // echo $current_datetime;
  $concatenated_string = $API_SECRET.$current_datetime.$API_KEY;
  // echo $concatenated_string;
  $hash_string = hash('sha256', $concatenated_string);
  
  $request_header = array(
    'API-KEY' => $API_KEY,
    'REQUEST-TS' => $current_datetime,
    'HASH-KEY' => $hash_string
  );
  
  var_dump($request_header);
  
  # perform your request here
  
?>
require 'digest'

API_SECRET = "..."
API_KEY = "..."

current_datetime = Time.now.strftime("%Y-%m-%d %H:%M:%S.%L%z")

concatenated_string = API_SECRET + current_datetime + API_KEY
# puts concatenated_string

hash_string = Digest::SHA256.hexdigest(concatenated_string)
# puts hash_string

request_header = {
  'API-KEY': API_KEY,
  'REQUEST-TS': current_datetime,
  'HASH-KEY': hash_string
}

# puts request_header
# perform your request here
import CryptoJS from "crypto-js";
import utf8 from "utf8";
let API_SECRET = "...";
let API_KEY = "...";
let current_datetime = Date.now();
let concatenated_string = API_SECRET + current_datetime.toString() + API_KEY;
let hash_string = CryptoJS.SHA256(utf8.encode(concatenated_string)).toString(
  CryptoJS.enc.Hex
);
let request_header = {
  "API-KEY": API_KEY,
  "REQUEST-TS": current_datetime,
  "HASH-KEY": hash_string
};
// perform your request here
AES 256 Algorithm