Hercle
WebSocket

Get Balances

Returns information about the user allocated and available balances.

Auth:API Key
Tags:
Funding
Account
Command Name
GetBalances

Command Arguments

ClientId
Required
Type:
string
Description:

Custom client ID for tracking (max 36 characters)

Example: "my-client-123"

Command Invocation

Command Arguments Example:
[
  "my-client-123"
]
Invocation Example:
connection.invoke('GetBalances', 'my-client-123')

Response Event

Event Name
executionEvents
Subject
account.balances.snapshot
FieldTypeDescription
userIdstringUser ID
sequencenumberSequential number for tracking balance updates
assetsarrayArray of asset balance objects
assets[].namestringAsset name/symbol (e.g., BTC, ETH, USDT)
assets[].availablenumberAvailable balance for the asset
assets[].allocatednumberAllocated balance for the asset
assets[].currentExposurenumberCurrent exposure for the asset
assets[].maxExposurenumberMaximum allowed exposure for the asset
baseCurrencystringBase currency for exposure calculations
totalCurrentExposurenumberTotal current exposure across all assets
totalMaxExposurenumberTotal maximum exposure limit
deletedbooleanDeleted flag

Example Response

{
  "data": {
    "userId": "user-123",
    "sequence": 123,
    "assets": [
      {
        "name": "BTC",
        "available": 0.5,
        "allocated": 0,
        "currentExposure": 0,
        "maxExposure": 1500
      },
      {
        "name": "ETH",
        "available": 5,
        "allocated": 0,
        "currentExposure": 0,
        "maxExposure": 1500
      },
      {
        "name": "USDT",
        "available": 1000,
        "allocated": 250,
        "currentExposure": 0,
        "maxExposure": 1500
      }
    ],
    "baseCurrency": "EUR",
    "totalCurrentExposure": 1430,
    "totalMaxExposure": 1500,
    "deleted": false
  }
}

Code Examples

const signalR = require('@microsoft/signalr');

const apiKey = 'YOUR_API_KEY_HERE';
const connection = new signalR.HubConnectionBuilder()
  .withUrl('https://publicapi.sandbox.hercle.financial/ExecutionLiveServer/v1', {
    accessTokenFactory: () => apiKey,
  })
  .build();

connection.start()
  .then(() => {
    console.log('Connected to WebSocket');
    
    // Invoke command
    connection.invoke('GetBalances', "my-client-123")
      .then(() => {
        console.log('Command sent successfully');
      })
      .catch(err => {
        console.error('Command failed:', err);
      });
  })
  .catch(err => {
    console.error('Connection failed:', err);
  });

// Listen for events
connection.on('executionEvents', (data) => {
  console.log('Received event:', data);
});

SignalR API Tester

Test this command in the sandbox environment

Disconnected

Your API key is only used locally and never stored

Event Log

No events yet. Connect and invoke a command to see events.