Table of Contents
- Fundamentals
- Basic Flow - Connect, Auth, Subscribe
- JSON Message Format & Examples
- Limitations, Message Volumes
- Examples, Demos, Code Snippets & Client Libraries
- WebSocket Playground
- JSFiddle (JavaScript) Example
Fundamentals
Basic Flow - Connect, Auth, Subscribe
- Connect to
wss://fastforex.wsdx.io(and receive aconnectmessage from the server) - Send an
authmessage with your API key (get a free API key here) - Send a
subscribemessage with the desired FX pairs
JSON Message Format & Examples
Messages are sent and received in JSON format. All messages have anop field, which indicates the operation type.
Messages from the server (“downstream”) will usually contain
- a
statusfield, which indicates the success or failure of the operation. - We follow HTTP status codes for this. e.g.
200= success,401= not authenticated, etc. - a
tspfield which indicates the timestamp of the message in milliseconds since epoch (Unix time).
Upstream (sent to the WebSocket server)
AuthDownstream
Connect (sent by server on connect)Limitations, Message Volumes
Depending on your subscription plan, you may be limited on the number of concurrent WebSocket connections you can make, and to the maximum number of pairs per connect. Our standard offering allows for 2 connections and up to 5 pairs per connection. Contact us for higher limits.Warning - High Message Volume Popular pairs such asEURUSDcan generate a lot of messages at peak times - up to hundreds of messages per second. Your application should be able to handle this. Connections may be closed if you cannot consume at the publish rate. Depending on your application needs, when sending yoursubscribemessage, you can choose to use thefx1sstream, which will produce at most one message per second, per subscribed pair.
Examples, Demos, Code Snippets & Client Libraries
WebSocket Playground
WebSocket King is a great in-browser tool for testing WebSocket connections. You’ll need the following information and example payloads to get started:| Field | Value |
|---|---|
| Server | wss://fastforex.wsdx.io |
| Auth | {"op":"auth", "key":"YOUR-API-KEY-HERE"} |
| Subscribe | {"op":"subscribe", "stream":"fx", "pairs":["EURUSD", "GBPUSD"]} |