Hercle
WebSocket

Get Trades By Client ID

Retrieves a paginated list of trades by client ID.

Auth:API Key
Tags:
Trading
Command Name
GetTradesByClientId

Command Arguments

ClientId
Required
Type:
string
Description:

Custom client ID for tracking (max 36 characters)

Example: "my-order-123"
tradeClientId
Required
Type:
string
Description:

Client ID of the trades to retrieve

Example: "my-trade-123"

Command Invocation

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

Response Event

Event Name
executionEvents
Subject
account.trades.snapshot
FieldTypeDescription
idstringUnique identifier for the transaction
userIdstringIdentifier of the user associated with the transaction
clientIdstringClient ID provided during the request
instrumentstringTrading pair or instrument identifier
sidestring
Trade side
buyBuy
sellSell
pricenumberPrice at which the trade was executed
quantityFillednumberQuantity of the asset that was traded
timestampstringTimestamp of when the trade occurred (ISO 8601 format)
emailstringEmail associated with the user account

Example Response

{
  "data": [
    {
      "id": "trade_123456789",
      "userId": "user_987654321",
      "clientId": "my-client-123",
      "instrument": "BTC-USD",
      "side": "buy",
      "price": 30000.5,
      "quantityFilled": 0.1,
      "timestamp": "2024-04-21T15:30:00Z",
      "email": "user@example.com"
    }
  ]
}

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('GetTradesByClientId', "my-client-123", "my-trade-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.