Getting Started with IEX Trading API

IEX Trading API is a RESTful public API that provides financial data such as stock prices, market news, and historical data. In this article, we will be exploring some of the most commonly used API calls and will be providing example code in JavaScript.

Getting a list of available symbols

To get a list of all symbols available on the IEX Trading API, we can use the following API call:

fetch('https://api.iextrading.com/1.0/ref-data/symbols')
    .then(response => response.json())
    .then(data => console.log(data));

This will return an array of objects, where each object represents a stock symbol. The object contains various properties such as the company's name, symbol, and primary exchange.

Getting a company's quote

To get a company's quote, we can use the following API call:

fetch('https://api.iextrading.com/1.0/stock/aapl/quote')
    .then(response => response.json())
    .then(data => console.log(data));

Here, we are passing the company symbol 'aapl' to get the current market data for Apple Inc. The returned object contains various properties such as the company name, symbol, latest price, and market capitalization.

Getting a company's historical data

To get a company's historical data, we can use the following API call:

fetch('https://api.iextrading.com/1.0/stock/aapl/chart/5y')
    .then(response => response.json())
    .then(data => console.log(data));

Here, we are passing the company symbol 'aapl' and a time range of 5 years to get the historical stock prices for Apple Inc. The returned array contains objects where each object represents a single trading day. The object contains various properties such as the opening and closing prices, volume, and date.

Getting market news

To get the latest market news, we can use the following API call:

fetch('https://api.iextrading.com/1.0/stock/market/news/last/5')
    .then(response => response.json())
    .then(data => console.log(data));

Here, we are passing a limit of 5 to get the last 5 market news headlines. The returned array contains objects where each object represents a single news headline. The object contains various properties such as the headline, summary, image URL, and source.

Conclusion

In this article, we explored some of the most commonly used API calls of IEX Trading API and provided example code in JavaScript. The IEX Trading API provides data on a wide range of stocks and market information and can be integrated into your website or application to provide relevant financial data to your users.

Related APIs in Finance