Python is one of the most popular programming languages, especially when dealing with vast amounts of financial data. Whether you’re developing a standalone app for finance or applying analytical methods to financial data, Python offers numerous solutions. While tools like Google Sheets and Excel add-ons cater to those less familiar with coding, we’ve made significant efforts to enhance the lives of developers by providing EODHD’s official library for API for Python to pull financial statement data and many more. In this article, we will cover installation, all functions, and provide examples, catering to developers in the finance industry who seek the best solutions for various tasks, including scraping financial data from several sources.

Official EODHD Python Financial Library installation

The library grants access to all the key features to work with stock market API in Python. You can find the library with it’s updates on our Github page.

1. Installing EODHD library. Start with the following command:

python3 -m pip install eodhd -U

See the screenshot:

Wait until library will be installed – it will be shown when [*] will change to [1].

2. Importing Required Libraries. Next, let’s import EODHD library for accessing EODHD API’s functions:

from eodhd import APIClient
import pandas as pd

Python Financial Library is installed now.

3. Accessing the EODHD API – to access the EODHD API, we need to create an instance of the “APIClient” class and pass it our API key. In this example, we will use the demo API key provided by EODHD, but in a real application, you should use your registered API key.

api = APIClient("<Your_API_Key>")

or:

import os

api_key = os.environ.get("<Your_API_Key>")
api = APIClient(api_key)

or via config file:

# config.py

API_KEY = "<Your_API_Key>"

# main.py
import config as cfg
api = APIClient(cfg.API_KEY)

There is also an unofficial, community-built Python library for EODHD’s API by Lautaro Parada. The library and its description can be found on the GitHub page.

Next, we are going to activate EODHD’s API key to get an access to stock data API in Python.

EODHD API access activation: free and payed options

1. You can start with “DEMO” API key to test the data for a few tickers only: AAPL.USTSLA.US VTI.USAMZN.USBTC-USD and EUR-USD. For these tickers, all of our types of data (APIs), including Real-Time Data, are available without limitations.
2. Register for the free plan to receive your API key (limited to 20 API calls per day) with access to End-Of-Day Historical Stock Market Data API for any ticker, but within the past year only. Plus a List of tickers per Exchange is available.
3. We recommend to explore our plansstarting from $19.99, to access the necessary type of data without limitations.

Register & Get Data

The library is now ready for use. Next, we recommend exploring our Academy section and specifically the article “Download EOD, Intraday, and Real-time Prices for Any Cryptocurrency with Python Simply” by Michael Whittle to fully understand what our API offers.

Example: End of the day historical stock market data

Lets retrieve End of the day historical stock market data:

resp = api.get_eod_historical_stock_market_data(symbol = 'AAPL.MX', period='d', from_date = '2023-01-01', to_date = '2023-01-15', order='a')
print(resp)

The function will return the following JSON respond:

All the parameters for this function are listed and described here.

List of the available functions

Function & descriptionCode examples
Live (Delayed) Stock Prices and Macroeconomic Data (doc)
resp = api.get_live_stock_prices(date_from = '2020-01-05', date_to = '2020-02-10', ticker = 'AAPL.US')
print(resp)
Bonds Fundamentals (doc)
bonds = api.get_bonds_fundamentals_data (isin = "US36166NAJ28")
bf = pd.DataFrame(bonds)
print(bf)
Intraday Historical Data (doc)
d_by_datetime = api.get_intraday_historical_data(symbol="BTC-USD.CC", interval="1m", from_unix_time='1637982000', to_unix_time="1637982900")
print(d_by_datetime)
Historical Dividends (doc)
hd_by_datetime = api.get_historical_dividends_data(ticker = "GS", date_from = "2020-12-10", date_to = "2021-04-10")
hd_m = pd.DataFrame(hd_by_datetime)

print(hd_m)
Historical Splits (doc)
sd_by_datetime = api.get_historical_splits_data(ticker = "MS", date_from = "2000-01-01")
sd_m = pd.DataFrame(sd_by_datetime)

print(sd_m)
Bulk API for EOD, Splits and Dividends (doc)
eod_splits_dividends_extended = api.get_eod_splits_dividends_data (type = "dividends", date = "2020-12-10", symbols = "AAPL.US")
esd_m = pd.DataFrame(eod_splits_dividends_extended)
print(esd_m) # for Dividends

eod_splits_dividends_extended = api.get_eod_splits_dividends_data (type = "splits", date = "2020-12-10", symbols = "AAPL.US")
esd_m = pd.DataFrame(eod_splits_dividends_extended)
print(esd_m)# for Splits
Calendar. Upcoming Earnings, Trends, IPOs and Splits (doc)
earnings_trends = api.get_earning_trends_data (symbols = "AAPL.US, MS") 
et = pd.DataFrame(earnings_trends)
print(et) # for Earnings Trends Data


up_earnings_extended = api.get_upcoming_earnings_data (from_date = "2020-12-10", to_date = "2021-04-10", symbols = "AAPL.US")
ue_m = pd.DataFrame (up_earnings_extended)
print(ue_m) # for Upcoming Earnings Data


up_ipos_extended = api.get_upcoming_IPOs_data (from_date = "2020-12-10", to_date = "2021-04-10")
ui_m = pd.DataFrame (up_ipos_extended)
print(ui_m) # for Upcoming IPOs


up_splits_extended = api.get_upcoming_splits_data (from_date = "2020-12-10", to_date = "2021-04-10")
u_split_m = pd.DataFrame (up_splits_extended)
print(u_split_m) # for Upcoming Splits
Economic Events (doc)
events_extended = api.get_economic_events_data (date_from = "2020-12-10", date_to = "2021-04-10", limit = "200", country = "US", comparison = "qoq")
ee_m = pd.DataFrame(events_extended)
print(ee_m)
Stock Market and Financial News (doc)
news_extended = api.financial_news (from_date = "2020-12-10", to_date = "2021-04-10", t = "financial results", offset = "200", limit = "100")
fn_m = pd.DataFrame(news_extended)
print(fn_m)
End of the Day Historical Stock Market Data (doc)
resp = api.get_eod_historical_stock_market_data(symbol = 'AAPL.MX', period='d', from_date = '2023-01-01', to_date = '2023-01-15', order='a')
print(resp)
List of supported Exchanges (doc)
l_e = api.get_list_of_exchanges()
list_exchages = pd.DataFrame(l_e)
print(list_exchages)
Insider Transactions (doc)
insider_extended = api.get_insider_transactions_data(date_from = "2020-12-10", date_to = "2021-04-10", limit = "200")
ie_m = pd.DataFrame(insider_extended)
print(ie_m)
Macro Indicators (doc)
indicator_extended = api.get_macro_indicators_data (country = "USA", indicator = "real_interest_rate")
indicator_m = pd.DataFrame(indicator_extended)
print(indicator_m)
Exchanges API. Trading Hours, Stock Market Holidays, Symbols Change History (doc)
exchange_extended = api.get_details_trading_hours_stock_market_holidays (code = "US", from_date = "2023-10-15", to_date = "2023-11-15")
e_m = pd.DataFrame (exchange_extended)
print(e_m) # for Trading hours and Stock market holidays


symbol_extended = api.symbol_change_history(from_date = "2022-07-22", to_date = "2022-08-10")
s_m = pd.DataFrame(symbol_extended)
print(s_m) # for Symbol change history
Stock Market Screener (doc)
screener_extended = api.stock_market_screener (filters = [["market_capitalization",">",1000]], limit = "100", offset = "200")
screener_m = pd.DataFrame(screener_extended)
print(screener_m)
Technical Indicator (doc)
resp = api.get_technical_indicator_data(ticker = 'AAPL.US', function = 'avgvolccy', period = 100, date_from = '2020-01-05', date_to = '2020-02-10',
order = 'a', splitadjusted_only = '0')
print(resp)
Historical Market Capitalization (doc)
resp = api.get_historical_market_capitalization_data(ticker = 'AAPL.US', from_date = '2023-01-01', to_date = '2023-01-15')
print(resp)
Fundamental Data: Stocks, ETFs, Mutual Funds, Indices and Cryptocurrencies (doc)
resp = api.get_fundamentals_data(ticker = "AAPL")
fundamental = pd.DataFrame(resp)
print(fundamental)

More on EODHD API

  • Documentation for all types of EODHD API is here
  • Academy section with useful materials on data analysis and trading is here
  • A series of Libraries for PHP, Curl and more here
  • Our Github is here

Register & Get Data