WebSocket API

The Datafye WebSocket API provides real-time streaming access to live market data. This API is designed for scenarios where you run your own algorithmic trading containers and need continuous updates of market data.

Base URL

The WebSocket API base URL depends on your deployment model and where your containers are running:

Local (Standalone) Deployments

ws://localhost:8080/datafye-ws/v1/...

Cloud (Distributed) Deployments

Internal Access (containers running within the deployment):

ws://api.rumi.local/datafye-ws/v1/...

External Access (containers running remotely, if configured):

ws://<user>-<type>-<env>-api.datafye.io/datafye-ws/v1/...

Where:

  • <user> - The unique name assigned to you by Datafye (e.g., acme)

  • <type> - Deployment type: foundry or trading

  • <env> - Environment identifier (omit for production, or use dev, staging, etc.)

Examples: acme-foundry-api.datafye.io, acme-foundry-dev-api.datafye.io

External Access: External URLs are disabled by default and must be explicitly configured. Security is enforced through IP allowlisting (not API keys or credentials). For self-managed deployments, configure IP allowlisting in your cloud provider's infrastructure. For Datafye Managed deployments, contact your administrator. External access may require secure WebSocket connections (wss://). See API URLs and Security Model for complete details.

Connection Lifecycle

1. Connect

Establish a WebSocket connection to the server:

2. Subscribe

Send subscription messages to receive specific data streams:

3. Receive Data

Handle incoming market data messages:

4. Unsubscribe

Stop receiving data for specific subscriptions:

5. Disconnect

Close the WebSocket connection:

Message Formats

Subscription Request

Subscription Response

Market Data Message

Error Message

Available Channels

Channel
Description
Data Type

quotes

Real-time quote updates (bid/ask)

Level 1 market data

trades

Real-time trade executions

Trade ticks

aggregates

Real-time OHLC bars

Aggregated data

Heartbeat and Keep-Alive

The server sends periodic heartbeat messages to maintain the connection:

Clients should respond with a pong message:

If no heartbeat response is received within 30 seconds, the server will close the connection.

Error Handling

Connection Errors

Handle connection failures and implement reconnection logic:

Subscription Errors

Handle invalid subscription requests:

Best Practices

Reconnection Strategy

Implement exponential backoff for reconnections:

Message Buffering

Handle message backpressure during high-volume periods:

Subscription Management

Track active subscriptions for reconnection:

Examples

Basic Quote Subscription

Local deployment:

Cloud deployment (internal access):

Cloud deployment (external access):

Multi-Channel Subscription


Last updated: 2025-10-14

Last updated