Skip to content

Get Account Balances

POST https://trade-uk.sandbox.zodiamarkets.com/api/3/account

Retrieve account balances across all account groups (sub-accounts). Returns balances for each currency held within each account group, along with balance buckets.

Balances are read from the Account_Groups array, which breaks them down by account group.

data.Account_Groups[].Accounts is a map keyed by currency code. The generated field reference lists it as a single object, so the shape of each value is documented here.

Each currency within an account group contains the following balance fields:

Field Type Description
Balance Object Total balance including unsettled amounts
Available_Balance Object Balance available for withdrawal
Brokerage_Available_Balance Object Balance available for trading
Unsettled_Sell_Balance Object Pending sell trade amounts awaiting settlement
Unsettled_Buy_Balance Object Pending buy trade amounts awaiting settlement
ccy String Currency code
Owner_Uuid String UUID of the account owner
Uuid String Unique identifier for this account

Each balance field (Balance, Available_Balance, etc.) contains:

Field Type Description
displayShort String Abbreviated formatted balance (e.g., "2.34 BTC")
valueInt String Integer representation of the balance (smallest unit)
currency String Currency code
display String Full precision formatted balance (e.g., "2.33581881 BTC")
value String Decimal string value of the balance
Balance Type Description
Balance Total balance across all states. Includes unsettled amounts.
Available_Balance Funds available for immediate withdrawal.
Brokerage_Available_Balance Funds available for placing new trades.
Unsettled_Sell_Balance Amount pending from sell trades not yet settled.
Unsettled_Buy_Balance Amount pending from buy trades not yet settled.

Note: Balance = settled funds + Unsettled_Buy_Balance - Unsettled_Sell_Balance. Negative balances on unsettled balances indicate unsettled obligations (i.e. trade is unsettled)

Balances are organised by account group (optional). Each account group represents either the primary account or a sub-account. All users will always have a ‘Default’ account group and can optionally request additional sub-accounts to split their balances.

Field Value Meaning
Natural: true Primary (default) account group
Natural: false Sub-account
import json
import hmac
import hashlib
import time
import requests
# Configuration
api_key = "your_api_key"
api_secret = "your_api_secret"
base_url = "https://trade-uk.sandbox.zodiamarkets.com"
# Request body — every signed request must carry a nonce or tonce
tonce = str(int(time.time() * 1000000))
body = {
"tonce": tonce,
"filterZeroBalanceAccounts": True
}
body_json = json.dumps(body)
# Generate signature
path = "api/3/account"
message = f"{path}\0{body_json}"
signature = hmac.new(
api_secret.encode(),
message.encode(),
hashlib.sha512
).hexdigest()
# Make request
headers = {
"Rest-Key": api_key,
"Rest-Sign": signature,
"Content-Type": "application/json"
}
response = requests.post(
f"{base_url}/{path}",
headers=headers,
data=body_json
)
# Process response
if response.status_code == 200:
data = response.json()
for group in data['data']['Account_Groups']:
print(f"\nAccount Group: {group['AccountGroup_Name']} ({'Primary' if group['Natural'] else 'Sub-account'})")
print(f" UUID: {group['AccountGroup_Uuid']}")
for ccy, account in group['Accounts'].items():
print(f" {ccy}:")
print(f" Balance: {account['Balance']['display']}")
print(f" Available for Trading: {account['Brokerage_Available_Balance']['display']}")
print(f" Unsettled Buy: {account['Unsettled_Buy_Balance']['display']}")
print(f" Unsettled Sell: {account['Unsettled_Sell_Balance']['display']}")
else:
print(f"Error: {response.status_code}")
print(response.text)
const crypto = require('crypto');
const axios = require('axios');
// Configuration
const apiKey = 'your_api_key';
const apiSecret = 'your_api_secret';
const baseUrl = 'https://trade-uk.sandbox.zodiamarkets.com';
// Request body — every signed request must carry a nonce or tonce
const tonce = Date.now() * 1000;
const body = {
tonce,
filterZeroBalanceAccounts: true
};
const bodyJson = JSON.stringify(body);
// Generate signature
const path = 'api/3/account';
const message = `${path}\0${bodyJson}`;
const signature = crypto
.createHmac('sha512', apiSecret)
.update(message)
.digest('hex');
// Make request
const headers = {
'Rest-Key': apiKey,
'Rest-Sign': signature,
'Content-Type': 'application/json'
};
axios.post(`${baseUrl}/${path}`, body, { headers })
.then(response => {
response.data.data.Account_Groups.forEach(group => {
const type = group.Natural ? 'Primary' : 'Sub-account';
console.log(`\nAccount Group: ${group.AccountGroup_Name} (${type})`);
console.log(` UUID: ${group.AccountGroup_Uuid}`);
Object.entries(group.Accounts).forEach(([ccy, account]) => {
console.log(` ${ccy}:`);
console.log(` Balance: ${account.Balance.display}`);
console.log(` Available for Trading: ${account.Brokerage_Available_Balance.display}`);
});
});
})
.catch(error => {
console.error('Error:', error.response?.status);
console.error(error.response?.data);
});
Terminal window
curl -X POST https://trade-uk.sandbox.zodiamarkets.com/api/3/account \
-H "Rest-Key: your_api_key" \
-H "Rest-Sign: your_hmac_signature" \
-H "Content-Type: application/json" \
-d '{
"tonce": 1770888183656000,
"filterZeroBalanceAccounts": true
}'
response = make_api_request('POST', 'api/3/account', {
'filterZeroBalanceAccounts': true,
'accountGroupUuid': '2073252c-81ed-41be-bf4d-d51b8f2246b8'
})
for group in response['data']['Account_Groups']:
for ccy, account in group['Accounts'].items():
print(f"{ccy}: {account['Balance']['display']}")
response = make_api_request('POST', 'api/3/account', {
'filterZeroBalanceAccounts': true
})
for group in response['data']['Account_Groups']:
print(f"\n{group['AccountGroup_Name']}:")
for ccy, account in group['Accounts'].items():
brokerage = float(account['Brokerage_Available_Balance']['value'])
if brokerage > 0:
print(f" {ccy}: {account['Brokerage_Available_Balance']['display']} available for trading")
response = make_api_request('POST', 'api/3/account', {
'filterZeroBalanceAccounts': true
})
sub_accounts = [
group for group in response['data']['Account_Groups']
if not group['Natural']
]
for group in sub_accounts:
print(f"\nSub-account: {group['AccountGroup_Name']}")
print(f" UUID: {group['AccountGroup_Uuid']}")
for ccy, account in group['Accounts'].items():
print(f" {ccy}: {account['Balance']['display']}")

Get Total Balance Across All Account Groups

Section titled “Get Total Balance Across All Account Groups”
from collections import defaultdict
response = make_api_request('POST', 'api/3/account', {
'filterZeroBalanceAccounts': true
})
totals = defaultdict(float)
for group in response['data']['Account_Groups']:
for ccy, account in group['Accounts'].items():
totals[ccy] += float(account['Balance']['value'])
for ccy, total in sorted(totals.items()):
print(f"{ccy}: {total}")

Domain: Accounts

POST https://trade-uk.sandbox.zodiamarkets.com/api/3/account
Header Required Description
Rest-Key API key for authentication
Rest-Sign Calculated API Signature
Field Type Required Description
tonce integer (int64) yes The current Unix time in microseconds.
nonce integer (int64) Alternative to tonce. Every request must carry either nonce or tonce, and the value must parse as a whole number; a request with neither is rejected with INVALID_NONCE_OR_TONCE.
filterZeroBalanceAccounts boolean When true, only returns currencies with non-zero balances. Strongly recommended. — Default: false
accountGroupUuid string Filter results to a specific account group (sub-account) UUID
userUuid string Master API keys only: UUID of the user to act on behalf of. Ignored unless the calling key belongs to the owner of a master-API-enabled site.
Field Type Required Description
data object Account data container
data.Created string Account creation date
data.Language string Account language locale
data.Last_Login string Date of the most recent login for this user
data.Login string API user login email
data.Rights array of string List of permissions on the API user: trade, withdraw, get_info
data.Account_Groups array of object Array of account group objects containing balances
data.Account_Groups[].AccountGroup_Uuid string Unique identifier for the account group
data.Account_Groups[].AccountGroup_Name string Account group name (e.g., “Default”, sub-account names)
data.Account_Groups[].Owner_Uuid string UUID of the account owner
data.Account_Groups[].Owner_Name string Owner (Parent) email address
data.Account_Groups[].Owner_Shortcode string Client shortcode identifier
data.Account_Groups[].Natural boolean true for the primary (default) account group, false for sub-accounts
data.Account_Groups[].Accounts object Map of currency codes to account balance objects — see “Account Balance Object” below for the shape of each value
userUuid string Unique identifier for the API user
timestamp string Unix timestamp of the response (milliseconds)
resultCode string Result status (OK on success)
description string Failure reason. Present only on the error path; absent on success.

400 — Malformed body, or a missing/stale nonce/tonce. Note that resultCode is hard-coded to INVALID_PARAMETERS on every failure of this endpoint regardless of cause — only the HTTP status distinguishes them, and description carries the reason text.

Section titled “400 — Malformed body, or a missing/stale nonce/tonce. Note that resultCode is hard-coded to INVALID_PARAMETERS on every failure of this endpoint regardless of cause — only the HTTP status distinguishes them, and description carries the reason text.”
Field Type Required Description
timestamp string Unix timestamp of the response (milliseconds).
resultCode string Always INVALID_PARAMETERS on this endpoint, whatever the real cause.
description string Reason text for the failure.

401 — The key authenticated but is not authorised for this call.

Section titled “401 — The key authenticated but is not authorised for this call.”
Field Type Required Description
timestamp string Unix timestamp of the response (milliseconds).
resultCode string Always INVALID_PARAMETERS on this endpoint, whatever the real cause.
description string Reason text for the failure.

403 — The key could not be authenticated: unknown, deactivated, locked, expired, or wrong site.

Section titled “403 — The key could not be authenticated: unknown, deactivated, locked, expired, or wrong site.”
Field Type Required Description
timestamp string Unix timestamp of the response (milliseconds).
resultCode string Always INVALID_PARAMETERS on this endpoint, whatever the real cause.
description string Reason text for the failure.

429 — The user has exceeded the request rate limit.

Section titled “429 — The user has exceeded the request rate limit.”
Field Type Required Description
timestamp string Unix timestamp of the response (milliseconds).
resultCode string Always INVALID_PARAMETERS on this endpoint, whatever the real cause.
description string Reason text for the failure.

500 — The request could not be validated.

Section titled “500 — The request could not be validated.”
Field Type Required Description
timestamp string Unix timestamp of the response (milliseconds).
resultCode string Always INVALID_PARAMETERS on this endpoint, whatever the real cause.
description string Reason text for the failure.