Available with: All-In-One and EOD+Intraday — All World Extended packages.
Consumption: Does not consume API calls.
EODHD offers one of the best ways for investors, developers, and data analysts to incorporate real-time finance data for the US market, 1100+ Forex pairs, 1000+ Digital Currencies into their decision-making projects with a delay of less than 50ms via WebSockets. For US stocks our real-time data API supports pre-market and post-market hours (from 4 am to 8 pm EST). The subscription provides real-time access to prices for 50 tickers simultaneously via WebSockets. Additionally, the 50-connection limit can be increased through the user dashboard.
Users can retrieve real-time stock data API (as well as Forex and Digital Currencies data) via two plans availible on our pricing page. For global markets and all exchanges around the world we also offer Live (Delayed) data.
Quick jump:
What is WebSocket protocol
WebSockets is a communication protocol that provides full-duplex communication channels over a single TCP connection. It enables real-time communication between a client and a server, allowing them to exchange messages continuously without the overhead of repeatedly establishing new connections. In the case of financial data providers, Websockets API provides real-time stock market information with minimal delay.
Providing clients with the WebSocket protocol for real-time data answers the question: ‘What is the best stock market data API?”. Since websocket technology is quite resource consuming, “free stock API for real-time market data” stays as feature impossible to find. EODHD provides real-time data in paid plans EOD+Intraday and ALL-IN-ONE. Read more about plans here.
WebSocket сonnection endpoints
There are 4 different endpoints covering Forex, alternative currencies, and two endpoints for the US market, including exchanges such as Nasdaq, NYSE, and others. 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 FOREX and Alternative currencies feeds please use the following WebSocket endpoints:
- FOREX: wss://ws.eodhistoricaldata.com/ws/forex?api_token=XXX
- Alternative currencies: wss://ws.eodhistoricaldata.com/ws/crypto?api_token=XXX
To begin using the real-time API via WebSockets, you should first connect to the appropriate endpoint, which can be done either via the wss:// or ws:// protocol. Afterward, you need to subscribe to the tickers you require.
For testing purposes, you can use our demo API key: ‘demo‘ which works only for AAPL, MSFT, TSLA, EURUSD, ETH-USD, and BTC-USD.
Subscribe command
To subscribe to a stream you should send “subscribe” 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 the format ETH-USD, and for Forex, the ticker codes have the format EURUSD.
Examples:
{"action": "subscribe", "symbols": "ETH-USD"}
{"action": "subscribe", "symbols": "EURUSD"}
You can create more than one subscription. You can send another subscription command or use a comma-separated list of tickers.
An example for US Market:
{"action": "subscribe", "symbols": "AMZN, TSLA"}
Response data for US Trade:
- s: ticker code
- p: price
- c: conditions, see trade conditions glossary for more information
- v: volume, representing the number of shares traded at the corresponding time stamp
- dp: dark pool true/false
- ms: market status, indicating the current state of the market for the stock ( “open”, “closed”, “extended hours”)
- 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
FOREX real-time data example:
{"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
Conditions glossary
The US trade feed has the c field in its output. This field passes a numeric value, which can be interpreted as having some meaning related to the particular tick. This is the trade conditions glossary that lists all possible values for this field.
Unsubscribe
The following command will remove the ticker from the response:
{"action": "unsubscribe", "symbols": "ETH-USD,BTC-USD"}
Websocket Plugin for Chrome
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.
Free real-time Chrome plugin by EODHD
We offer you the opportunity to try our Chrome extension plugin for free, providing access to real-time data for stocks, forex, and alternative currencies. It’s a compact and simple toolbar that remains visible in the corner of your browser throughout your working day. Install from here.
Conclusion
EODHD provides one of the best solutions for integrating real-time finance data into decision-making projects, offering stock market data with real‑time streaming and historical data API capabilities across various markets, including the US market, FOREX, and alternative currencies. Explore our pricing plans to leverage these features for your financial projects. We recommend to check also our Live (Delayed) Data API.