For people who are interested in trading, investing or financial analysis, having access to Stocks Intraday Historical Data with Python is necessary. It helps to stay informed of the cumulative total volume of orders executed at a given price during daily or monthly intervals. While historical intraday data is not suitable for high-frequency trading or immediate decision-making, it is more than sufficient for conducting various research tasks.

Register & Get Data

Please note: before continue to work with our APIs, make sure that you import and installed all required libraries. More detailed information about functions of Stocks Intraday Historical Data API you can find on our documentation web-page.

Accessing the EODHD API

To access the EODHD API, lets create an instance of the “APIClient” class and pass it our API key. In this example, we will use the demo API key, but in a real application, you should use your registered API key.

api = APIClient("demo")

Also, you can specify the API key in the configuration file or as an environment variable. For more information you can visit the library documentation.

1. Use “DEMO” API key to test our data from a limited set of the tickers without registering:
AAPL.US | TSLA.US VTI.US | AMZN.US | BTC-USD | EUR-USD
Real-Time Data and All of the APIs (except Bulk) are included without limitations on API calls.
2. Register to get your free API key (limitated by 20 API calls per day) with access to:
End-Of-Day Historical Data with only past year for any ticker and List of tickers per Exchange
3. To unlock your API key we recommend to choose subscription which covers your needs

Retrieving Intraday Historical Data on Python

After we’re done with the API client, we can start requesting Intraday Historical Data for a specific stock symbol.

For intraday historical data, it is mandatory to designate the granularity of the data, using the interval parameter.

resp = api.get_historical_data(symbol = "AAPL.US", interval = "5m")

All data in DataFrame will contain information such as: “date time”, “epoch”, “gmt offset”, “symbol”, “interval”, “open”, “high”, “low”, “close” and “volume” for the stock symbol. Which was used when we called the API, “AAPL.US” in this case.

print(resp)

Requesting data historically

To filter data by datetime, we have iso8601_start and iso8601_end parameters. The maximum periods between ‘iso8601_start’ and ‘iso8601_end’ are 120 days for 1-minute intervals, 600 days for 5-minute intervals and 7200 days for 1-hour intervals . Without ‘iso8601_start’ and ‘iso8601_end’ specified, the length of the data obtained is the last 120 days.

Also remember that for US 1-minute interval data, only NYSE and NASDAQ tickers are supported, including pre-market (premarket) and after-hours (afterhours) trading data from 2004. 5-minute and 1-hour intervals for US tickers are available from October 2020. For FOREX, Cryptocurrencies (CC), and MOEX (MCX) tickers, we have 1-minute intervals of trading data from 2009, more than 12 years of data. 5-minute and 1-hour intervals are available from October 2020. For most other tickers from most other exchanges, we have 5-minute and 1-hour intervals from October 2020. Some of these tickers may also have 1-minute interval data from October 2020, but the availability of this data varies between tickers and exchanges. For more information you can visit the Intraday API documentation.

d_by_datetime = api.get_historical_data(symbol = "AAPL.US", iso8601_start = "2020-12-10", iso8601_end = "2021-04-10", interval = "5m")

The API response is a DataFrame containing data for all the requested tickers.

print(d_by_datetime)

Register & Get Data

Conclusion

We have learned how to fetch Intraday Historical Data on Python using the EODHD API`s financial library. Now we know how to install the required library, get access to the EODHD API, retrieve intraday historical data in a specific datetime range and convert the API response to a pandas DataFrame.