Skip to main content

Integration

Authentication

info

Please visit Haqqex's website to generate an API key

REST API Base Endpoints

Haqqex API Keys

The API key generated by the Haqqex system operates with HMAC encryption.

You will be provided with a pair of public and private keys (apiKey and secretKey).

Example of api key response:

{
"apiKey": "88634a56-608a-434d-90f1-3a83d5d68379",
"secretKey": "ioh8xDhjoNK60BE0msPGFbfGA-ECZy26",
"ips": null,
"title": "test api key",
"createdAt": "2023-08-14T09:22:07.332Z",
"expiredAt": "2023-11-14T09:22:07.235Z"
}
caution

The private key will be shown only once after creation

Please treat keys as passwords and keep them safe

Request headers

The following http header keys must be used for authentication:

  • x-api-key - API key (public key)
  • x-api-timestamp - UTC timestamp in milliseconds
  • x-api-sign - a signature derived from the request's parameters

Deposit

To make deposits, follow the next steps:

  1. Create an address for the deposit (Account section)
  2. Make a deposit to the created address
  3. After blockchain process your deposit, your account balance will be increased

Code samples

Utilities

Let's see the following javascript code utilities:

import * as crypto from 'crypto';
import axios from 'axios';

// get keys from .env
const publicKey = process.env.HAQQEX_PUBLIC_KEY;
const privateKey = process.env.HAQQEX_PRIVATE_KEY;

function generateSign(secret: string, timestamp: string, params: string): string {
return crypto.createHmac('sha256', secret).update(`${timestamp}.${params}`).digest('hex');
}

async function request(url: string, method = 'GET', data: object = {}) {
const timestamp = Date.now().toString();
const sign = generateSign(privateKey, timestamp, JSON.stringify(data));

const config = {
method,
url,
headers: {
'x-api-sign': sign,
'x-api-key': publicKey,
'x-api-timestamp': timestamp,
'Content-Type': 'application/json',
},
data,
};

await axios(config)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error);
});
}

GET request

request(`https://backend.prod.haqqex.tech/trading/api/v1/trades/my`);

POST request

request(`https://backend.prod.haqqex.tech/trading/api/v1/order`, 'POST', {
pair: 'BTC-USDC',
type: 'limit',
side: 'buy',
quantity: '2',
price: '24321.00',
});