Python Stock API Example

It’s easy to download our JSON API with Python scripts, please do not forget to change the API token to yours, which you can get on the settings page after the free registration.

We also recommend Python Financial APIs SDK. This Python SDK is provided by our clients for our REST API. It’s intended to be used for data extraction for financial valuations, macroeconomic analyses, sentiment analysis, option strategies, technical analysis, development of machine learning models, and more!

import urllib, json

url = ""

response = urllib.urlopen(url)

data = json.loads(

print data

There is also a simple Python example that was written for us by Femto Trader. There is a small example, for more information you can find on GitHub, check python-eodhistoricaldata.

import requests

import pandas as pd

from io import StringIO

def get_eod_data(symbol=”AAPL.US”, api_token=”xxxx”, session=None):

if session is None:

session = requests.Session()

url = ‘’ % symbol

params = {“api_token”: api_token}

r = session.get(url, params=params)

if r.status_code ==

df = pd.read_csv(StringIO(r.text), skipfooter=1, parse_dates=[0], index_col=0, engine=’python’)

return df

else:raise Exception(r.status_code, r.reason, url)

You can download data simply using

df = get_eod_data(“AAPL.US”)

And if you want to avoid too much data consumption, you can use a cache mechanism

import datetime

import requests_cache

expire_after = datetime.timedelta(days=1)

session = requests_cache.CachedSession(cache_name=’cache’, backend=’sqlite’, expire_after=expire_after)

df = get_eod_data(“AAPL.US“, session=session)

Register & Get Data

Great thanks to Femto Trader (Github) and don’t forget about the full python example python-eodhistoricaldata.