We have real-time data with a delay of less than 50ms via WebSockets for the US market, FOREX, and Cryptocurrencies. For US stocks our real-time data API supports pre-market and post-market hours (from 4 am till 8 pm EST). WebSockets API is available within All World Extended and/or All-In-One packages. With the standard subscription, you can use up to 50 tickers simultaneously. And it’s possible to increase the number of concurrent tickers per request.

WebSocket Connection

There are five different endpoints, an endpoint for each data market and two types of data for US market:

We support trade and quote data for the US market, the data is provided via different WebSocket endpoints:

  • US market trade data: wss://ws.eodhistoricaldata.com/ws/us?api_token=XXX
  • US market quote data: wss://ws.eodhistoricaldata.com/ws/us-quote?api_token=XXX

For US Indices real-time data API you can use the following endpoint. Only the major indices are supported now: IXIC, GSPC, NDX, DJI, and FTSE.

  • US Indices: wss://ws.eodhistoricaldata.com/ws/index?api_token=XXX

For FOREX and Crypto feeds please use the following WebSocket endpoints:

  • FOREX: wss://ws.eodhistoricaldata.com/ws/forex?api_token=XXX
  • Cryptocurrencies: wss://ws.eodhistoricaldata.com/ws/crypto?api_token=XXX

To start using the real-time API via WebSockets you should connect first to the appropriate endpoint, you can do it either via wss:// or via ws:// protocol. And after that, you should subscribe to the tickers you need.

For testing purposes you can use our demo API key: ‘demo‘ which works for AAPL, MSFT, TSLA, EURUSD, ETH-USD and BTC-USD.

Subscribe

To subscribe you should send the following command. If the symbol exists, you will get the data as JSON in real-time. Please use the same ticker codes as provided in Cryptocurrencies and Forex lists. For Crypto, the ticker codes have format ETH-USD, and for Forex, the ticker codes have format EURUSD.

Examples:

{"action": "subscribe", "symbols": "ETH-USD"}
{"action": "subscribe", "symbols": "EURUSD"}

You can create more than one subscription. You can just send another subscription command or use a comma-separated list of tickers.

For US Market

{"action": "subscribe", "symbols": "AMZN, TSLA"}

Response data for US Trade:

  • s: ticker code
  • p: price
  • c: the parameter to construct candles on your side. The procedure is quite complex, please ignore it if you are not aware.
  • dp: is ‘dark pool’ trading now, false or true.
  • t: timestamp in milliseconds

Response data for US Quote:

  • s: ticker code
  • ap: ask price
  • bp: bid price
  • as: ask size
  • bs: bid size
  • t: timestamp in milliseconds

Response data for Indices:

  • s: ticker code
  • p: last price
  • dc: daily change percentage
  • dd: daily difference price
  • ppms: pre and post-market status
  • t: timestamp in milliseconds

FOREX real-time data:

{"action": "subscribe", "symbols": "EURUSD, AUDUSD"} 

Response data for Forex:

  • s: ticker code
  • a: ask price
  • b: bid price
  • dc: daily change percentage
  • dd: daily difference price
  • ppms: pre- and post-market status, always false for Forex data.
  • t: timestamp in milliseconds

Cryptocurrencies real-time data:

{"action": "subscribe", "symbols": "ETH-USD,BTC-USD"}

Response data for cryptocurrencies

  • s: ticker code
  • p: last price
  • q: quantity of the trade
  • dc: daily change percentage
  • dd: daily difference price
  • t: timestamp in milliseconds

Unsubscribe

The following command will remove the ticker from the response

{"action": "unsubscribe", "symbols": "ETH-USD,BTC-USD"}

Recommended Websocket Plugin

We recommend using the Simple WebSocket Client for Chrome for testing purposes. It’s easy to use for quick testing of our real-time data APIs.

Real-time Data API via WebSockets

You can also check our Live (Delayed) Data API.