Welcome to the integration guide. This document will help you authenticate, access market data, manage orders, and monitor your account using our API.
Get your api key and secret from kalqix app [user > settings > api keys].
https://testnet.kalqix.com
https://testnet-api.kalqix.com/v1/
const headers = {
'x-api-key': 'your-api-key',
'x-api-signature': 'hmac-signature',
'x-api-timestamp': 'timestamp-in-ms',
'Content-Type': 'application/json'
};We use HMAC so the server can verify that a request was created by someone who holds your API secret without ever sending the secret over the network.
const crypto = require('crypto');
function signRequest(method, path, body, timestamp, apiSecret) {
let payload = '';
if (body && Object.keys(body).length > 0) {
payload = JSON.stringify(body);
}
const canonical = `${method}|${path}|${payload}|${timestamp}`;
return crypto.createHmac('sha256', apiSecret).update(canonical).digest('hex');
}
// Example usage
const method = 'POST';
const path = '/orders';
const body = { ticker: 'BTC_USDT', price: '100000', ... };
const timestamp = Date.now();
const signature = signRequest(method, path, body, timestamp, apiSecret);For order placement, you also need to sign a message with your wallet. This signature goes in the request body, not headers
const { ethers } = require('ethers');
async function signOrderMessage(order, walletSeed) {
// Create wallet from seed phrase
const wallet = ethers.Wallet.fromPhrase(walletSeed);
// Optional: Connect to a provider if you need to interact with the blockchain
// const provider = new ethers.JsonRpcProvider('YOUR_RPC_URL');
// const connectedWallet = wallet.connect(provider);
const price = order.order_type === 'LIMIT'
? order.price
: 'MARKET';
const message = `${order.side} ${order.quantity} ${order.ticker} @PRICE: ${price}`;
const signature = await wallet.signMessage(message);
const address = wallet.address;
return { message, signature, walletAddress: address };
}
// Example usage
const order = {
ticker: 'BTC_USDT',
price: '100000',
quantity: '0.1',
side: 'BUY',
order_type: 'LIMIT'
};
// Your wallet seed phrase (12, 15, 18, 21, or 24 words)
const walletSeed = 'your twelve word seed phrase here for wallet creation';
const { message, signature, walletAddress } = await signOrderMessage(order, walletSeed);You can also create wallets using other methods:
// From private key
const privateKey = '0x...'; // Your private key
const wallet = new ethers.Wallet(privateKey);
// From mnemonic (same as seed phrase)
const mnemonic = 'your twelve word mnemonic here';
const wallet = ethers.Wallet.fromPhrase(mnemonic);
// Generate a new random wallet
const randomWallet = ethers.Wallet.createRandom();// 1. Generate Ethereum message signature (for request body)
const { message, signature, walletAddress } = await signOrderMessage(order, walletSeed);
// 2. Prepare request body with Ethereum signature
const requestBody = {
ticker: 'BTC_USDT',
price: '100000',
quantity: '0.1',
side: 'BUY',
order_type: 'LIMIT',
message: message,
signature: signature
};
// 3. Generate HMAC signature (for headers)
const method = 'POST';
const path = '/orders';
const timestamp = Date.now();
const hmacSignature = signRequest(method, path, requestBody, timestamp, apiSecret);
// 4. Send request with both signatures
fetch('https://testnet-api.kalqix.com/v1/orders', {
method: 'POST',
headers: {
'x-api-key': apiKey,
'x-api-signature': hmacSignature, // HMAC for API auth
'x-api-timestamp': timestamp.toString(),
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody) // Contains Ethereum signature
});For programmatic access, use API key authentication with HMAC signatures.
- Dashboard: Visit Kalqix Settings > API Keys dashboard to create your first API keys
- Self-Service: Once you have API keys, you can use the
PUT /api-keysendpoint to create additional keys
GET /markets— List all marketsGET /markets/:ticker— Market detailsGET /markets/:ticker/order-book— Orderbook snapshotGET /markets/:ticker/price— Current priceGET /markets/:ticker/market-price— Market order priceGET /markets/:ticker/orders— All orders for a marketGET /markets/:ticker/trades— Recent tradesGET /markets/:ticker/line-chart— Line chart dataGET /markets/:ticker/candles— OHLCV candlesGET /markets/:ticker/24hr— 24hr statsGET /markets/:ticker/volume— Market volume
Example:
GET /markets/BTC_USDT/order-bookPOST /orders— Place a new orderGET /orders— List your ordersGET /orders/:id— Order status/detailsDELETE /orders/:id— Cancel an orderDELETE /orders/:id/all— Cancel all orders
📖 For comprehensive order management documentation, see ORDER_MANAGEMENT_API.md
GET /portfolios— Get balancesGET /positions— All positionsGET /positions/:asset— Position for a specific assetPOST /positions/:asset/withdraw— Withdraw from a position
GET /users/me— User profileGET /users/:user/transaction-history— Transaction historyGET /users/:user/trades— Trade history
- Default: 200 requests/sec per IP
- Headers:
X-RateLimit-LimitX-RateLimit-RemainingX-RateLimit-ResetRetry-After(on 429)
- On exceeding: HTTP 429 with
Retry-After
- Standard HTTP status codes
- Error responses in JSON:
{ "error": "description" }
- Never send your API secret in requests - only use it to generate signatures
- Keep your API secret secure - it's only shown once when created
- Use HTTPS for all API requests
- Timestamp validation - requests are rejected if timestamp is more than 5 minutes old
- Rotate API keys regularly for enhanced security
- Wallet Seed Security - Store your wallet seed phrase securely and never expose it in client-side code or logs
- Hardware Wallets - Consider using hardware wallets for enhanced security.
For integration help, contact us on x (twitter) @kalqix
- Get initial API keys via dashboard
- Implement HMAC signature generation
- Fetch market/orderbook/trade data
- Place/cancel orders and check order status
- Fetch balances and positions
- Handle rate limits and errors gracefully
- Test with different market pairs
For further technical details, please contact support or see the next steps in this onboarding series.