Make a Request
Now that authentication is covered, this page shows you how to put it into practice with actual API calls.
Making API Requests
Section titled “Making API Requests”Request Anatomy
Section titled “Request Anatomy”Every authenticated API request consists of four components:
HTTP Method + Full URL + Headers + BodyExample:
POST https://trade-uk.sandbox.zodiamarkets.com/api/3/accountHeaders: Rest-Key, Rest-Sign, Content-TypeBody: {"tonce": 1737552000000000}Quick Reference
Section titled “Quick Reference”Header Requirements
Section titled “Header Requirements”| Header | Value | Required |
|---|---|---|
Rest-Key |
Your API key | ✅ Always |
Rest-Sign |
Generated signature | ✅ Always |
Content-Type |
application/json |
✅ Always |
Body Requirements
Section titled “Body Requirements”All request bodies must include:
{ "tonce": 1737552000000000, // ... other parameters}The tonce is automatically added when you use the signature generation functions from the authentication page.
Common API Calls
Section titled “Common API Calls”Get Account Balance Information
Section titled “Get Account Balance Information”Retrieve your account details and balances.
# Using the make_api_request function from the Authentication pageaccount = make_api_request('POST', 'api/3/account', {})print(f"Account UUID: {account['accountGroupUuid']}")print(f"User: {account['userUuid']}")makeApiRequest('POST', 'api/3/account', {}) .then(account => { console.log(`Account UUID: ${account.accountGroupUuid}`); console.log(`User: ${account.UserUuid}`); });Get WebSocket Authentication Token
Section titled “Get WebSocket Authentication Token”Required before connecting to WebSocket API for price streaming.
token_response = make_api_request('POST', 'api/3/zm/rest/auth/token', {})ws_token = token_response['token']print(f"WebSocket Token: {ws_token}")makeApiRequest('POST', 'api/3/zm/rest/auth/token', {}) .then(response => { const wsToken = response.token; console.log(`WebSocket Token: ${wsToken}`); });Get Transaction List
Section titled “Get Transaction List”Query your transaction history with filtering.
transactions = make_api_request('POST', 'api/3/transaction/list', { 'transactionClass': 'RFSTRADE', 'accountGroupUuid': 'afe6280e-163a-4652-a795-34e963063b06', 'limit': 50})
for tx in transactions['transactions']: print(f"{tx['timestampMillis']}: {tx['amount']} {tx['ccy']}")makeApiRequest('POST', 'api/3/transaction/list', { transactionClass: 'RFSTRADE', accountGroupUuid: 'afe6280e-163a-4652-a795-34e963063b06', limit: 50}).then(response => { response.transactions.forEach(tx => { console.log(`${tx.timestampMillis}: ${tx.amount} ${tx.ccy}`); });});import requests
def safe_api_request(method, path, body=None): """Make API request with error handling""" try: response = make_api_request(method, path, body) return {'success': True, 'data': response} except requests.exceptions.HTTPError as e: error_data = e.response.json() if e.response.text else {} return { 'success': False, 'error': error_data.get('error', 'UNKNOWN_ERROR'), 'message': error_data.get('message', str(e)), 'status_code': e.response.status_code } except Exception as e: return { 'success': False, 'error': 'REQUEST_FAILED', 'message': str(e) }
# Usageresult = safe_api_request('POST', 'api/3/account', {})if result['success']: print(f"Account: {result['data']['accountGroup']}")else: print(f"Error {result['status_code']}: {result['message']}")async function safeApiRequest(method, path, body = null) { try { const response = await makeApiRequest(method, path, body); return { success: true, data: response }; } catch (error) { if (error.response) { const errorData = error.response.data || {}; return { success: false, error: errorData.error || 'UNKNOWN_ERROR', message: errorData.message || error.message, statusCode: error.response.status }; } return { success: false, error: 'REQUEST_FAILED', message: error.message }; }}
// Usageconst result = await safeApiRequest('POST', 'api/3/account', {});if (result.success) { console.log(`Account: ${result.data.accountGroup}`);} else { console.error(`Error ${result.statusCode}: ${result.message}`);}