Skip to content
Last updated

WebSocket API Overview

The Collective2 API provides a WebSocket endpoint for receiving real-time trading signals and position updates as they are published. Use WebSocket when you need low-latency push updates — instead of polling the REST API on a schedule such as GetStrategyActiveOrders, GetStrategyHistoricalOrders or GetStrategyHistoricalClosedTrades.

When to Use WebSocket

Use the WebSocket API when you need signals & positions delivered to your application as soon as they are published. For historical data, use the REST endpoints.

Base URL

wss://api4-general.collective2.com/ws

Authentication

Pass your API key as a Bearer token in the Authorization header during the HTTP upgrade handshake:

Authorization: Bearer YOUR_API_KEY

Authentication happens at connection time. If your API key is invalid or missing, the server returns HTTP 401 before the WebSocket upgrade completes.

Available Channels

ChannelDescription
strategy.signalReal-time trading signals for a strategy
strategy.positionsReal-time position updates for a strategy

See Subscribing to Channels for details on how to use channels.

Limits

LimitValue
Connections per API key10
Channel subscriptions per connection100

Message Envelope

Every message — sent or received — uses the same JSON envelope:

{
  "msg_type": "string",
  "id": "msg_a1b2c3d4e5f64a2b8c3d4e5f6a7b8",
  "seq_id": 98765,
  "request_id": "my-req-1",
  "timestamp": "2024-01-01T12:00:00Z",
  "v": 4,
  "payload": {}
}
FieldTypeDescription
msg_typestringMessage type identifier
idstringUnique message ID assigned by the server
seq_idintegerMonotonically increasing sequence number for ordered streams. null or absent on non-stream messages (heartbeats, acks).
request_idstringOptional. Echoes the client's request_id for correlating requests to responses. Max 50 characters.
timestampstringUTC timestamp in ISO 8601 format
vstringProtocol version
payloadobjectMessage-specific data

Client Message Types

Your application may only send two message types to the server:

msg_typePurpose
subscription.requestSubscribe or unsubscribe from a channel
heartbeat.ackAcknowledge a server heartbeat

All other message types are server-only. Sending an unknown type returns an error.