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 messages. Be sure to learn about messages and sandbox testing first if you are new to IEX Cloud.

Here are some helpful articles to review before using the API:

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.

https://cloud.iexapis.com/stable/stock/XOM/quote?token=YOUR_TOKEN_HERE

2) See today's intraday prices by minute for Bank of America (BAC), returning the last 20 minutes only, using the Intraday Prices endpoint.

https://cloud.iexapis.com/stable/stock/BAC/intraday-prices?&chartLast=20&token=YOUR_TOKEN_HERE

3) Get Apple’s (AAPL) real-time price, even if you do not have UTP authorization for Nasdaq-listed securities.

https://cloud.iexapis.com/stable/stock/aapl/quote?token=YOUR_TOKEN_HERE

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.

https://cloud.iexapis.com/stable/stock/FB/chart/date/20191107?token=YOUR_TOKEN_HERE

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.

https://cloud.iexapis.com/stable/stock/aapl/chart/max?token=YOUR_TOKEN_HERE

3) Get multiple symbols’ current and historical prices by as far back as one year all in one API call, using batching.

https://cloud.iexapis.com/stable/stock/market/batch?symbols=aapl,fb,tsla&types=chart,quote&range=1y&token=YOUR_TOKEN_HERE

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.

Did this answer your question?