Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.4casters.io/llms.txt

Use this file to discover all available pages before exploring further.

The 4casters Orders API supports real-time order placement, cancellation, and session management over a raw WebSocket connection.

Endpoints

  • Orders API: wss://orders-api.4casters.io/orders/ws

Auth

The connection authenticates with a 4Casters token. Send the token in the Authorization header on the WebSocket handshake. The server derives the user from the token — no username in the URL.

Get a token

Log in with your 4Casters username and password by calling the /user/login endpoint of the 4Casters REST API. The response includes a token you can use here. See POST /user/login in the 4Casters REST API docs.

Connect

const WebSocket = require('ws');
const token = process.env.FOURCASTERS_TOKEN;
const ws = new WebSocket('wss://orders-api.4casters.io/orders/ws', {
  headers: { Authorization: token },
});

Message format

Every client request is a 2-tuple [messageType, payload]. Every payload should include a requestID that you generate; the server echoes it back so you can correlate responses.
[
  "messageType",
  {
    "requestID": "YOUR_REQUEST_ID",
    "...": "..."
  }
]
Server responses are JSON objects with requestID plus either data (success) or error (failure):
{
  "requestID": "YOUR_REQUEST_ID",
  "data": { "...": "..." }
}