This article provides some examples and sample API calls for accessing stock prices through IEX Cloud – both historical and real-time. Example include API calls made to the Quote, Intraday Prices, and Historical Prices endpoint.
If you use your API key with the following calls, they will return real data from the API and use your account’s credits (previously called messages). Be sure to learn about credits and sandbox testing first if you are new to IEX Cloud.
Here are some helpful articles to review before using the API:
- Our basic getting started guide
- An introduction to testing out API calls for free with the sandbox environment
- A detailed breakdown on how to make an API request on IEX Cloud
- An introduction to real-time stock prices on IEX Cloud
- An introduction to historical stock prices on IEX Cloud, including detail on international stock data
Examples for accessing real-time or current intraday stock prices
1) See current stock price details for Exxon Mobil (XOM), using the Quote endpoint. You can use the same API call at the end of the day to see the current trading day’s open, close, high and low after market close.
2) See today's intraday prices by minute for Bank of America (BAC), returning the last 20 minutes only, using the Intraday Prices endpoint.
3) Get Apple’s (AAPL) real-time price, even if you do not have UTP authorization for Nasdaq-listed securities.
While “delayed” fields will be marked as null, other fields like “latestPrice” and “iexRealtimePrice” will provide data from the Investors Exchange. Learn more about UTP authorization here.
4) Stream real-time prices via SSE streaming for the S&P 500 ETF trust. Learn more about streaming here.
curl --header 'Accept: text/event-stream' https://cloud-sse.iexapis.com/stable/stocksUS\?symbols\=spy\&token\=YOUR_TOKEN
Examples for accessing historical end-of-day and minute-by-minute stock prices
1) See Facebook's (FB) historical minute-by-minute prices for a specific date, using the Historical Prices endpoint. Historical minute bar data is currently supported for the last trailing 30-day window from today's date.
2) See the historical end-of-day prices for the last 15 years for Apple (AAPL). Note that up to 15 years of data is included with paid subscriptions, and up to 5 years of data is included with free plans.
3) Get multiple symbols’ current and historical prices by as far back as one year all in one API call, using batching.
You can also see additional examples by logging into the IEX Cloud Console and searching for any symbol in the upper-left-hand corner, as shown below. After clicking into a specific symbol, you will see additional examples under “Popular API Calls.”
Note that real-time prices available via the IEX Cloud API are different from real-time prices available via direct connection from IEX. Learn more here.