Hercle
WebSocket

Get Orders By Client ID

Retrieve all orders associated with a specific client identifier.

Auth:API Key
Tags:
Trading
Command Name
GetOrdersByClientId

Command Arguments

ClientId
Required
Type:
string
Description:

Custom client ID for tracking (max 36 characters)

Example: "my-client-456"
OrderClientId
Required
Type:
string
Description:

Filter by specific order client ID (max 36 characters)

Example: "my-order-client-789"

Command Invocation

Command Arguments Example:
[
  "my-client-456",
  "my-order-client-789"
]
Invocation Example:
connection.invoke('GetOrdersByClientId', 'my-client-456', 'my-order-client-789')

Response Event

Event Name
executionEvents
Subject
account.orders.snapshot
FieldTypeDescription
orderIdstringUnique order identifier
clientIdstringCustom client ID provided during order placement
userIdstringUnique user identifier
instrumentstringTrading pair (e.g., BTCUSDT)
basestringBase asset of the trading pair
quotestringQuote asset of the trading pair
sidestring
Order side
buyBuy
sellSell
orderTypenumber
Type of order
0Market
1Fill or Kill
pricenumberOrder price
executedPricenumberExecuted price of the order
executedTimestampstringTimestamp when the order was executed
quantitynumberTotal quantity of the order
quantityFillednumberQuantity that has been filled
orderStatusnumber
Order status
0Created
1Executed
2Cancelled
3Pending
cancellationReasonstringReason for order cancellation, if applicable
slippagenumberSlippage incurred during order execution
timestampstringTimestamp of the event

Example Response

{
  "data": [
    {
      "orderId": "123e4567-e89b-12d3-a456-426614174000",
      "clientId": "986fgh34-5678-90ab-cdef-123456ghijkl",
      "userId": "qu7890ab-cdef-1234-5678-90abcdef1234",
      "instrument": "BTCUSDT",
      "base": "BTC",
      "quote": "USDT",
      "side": "buy",
      "orderType": 0,
      "price": 30000,
      "executedPrice": 29950,
      "executedTimestamp": "2024-04-21T10:15:30Z",
      "quantity": 0.5,
      "quantityFilled": 0.5,
      "orderStatus": 1,
      "cancellationReason": "",
      "slippage": 0.1,
      "timestamp": "2024-04-21T10:15:31Z"
    }
  ]
}

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('GetOrdersByClientId', "my-client-456", "my-order-client-789")
      .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.