This document provides practical examples for using the EODHD Financial Data API.
- Getting Started
- Authentication
- End-of-Day Data
- Real-time & Intraday Data
- Calendar Events
- Fundamentals
- Exchange Information
- Options Data
- News & Sentiment
- Technical Analysis
- Screening & Search
- Error Handling
All examples assume you have an API token. Replace YOUR_API_TOKEN with your actual token.
Base URLs:
- Primary:
https://eodhd.com/api - Alternative:
https://eodhistoricaldata.com/api
All requests require an api_token query parameter:
curl "https://eodhd.com/api/exchanges-list?api_token=YOUR_API_TOKEN"Get historical daily prices for Apple stock:
curl "https://eodhd.com/api/eod/AAPL.US?api_token=YOUR_API_TOKEN&from=2024-01-01&to=2024-12-31&fmt=json"Response:
[
{
"date": "2024-01-02",
"open": 187.15,
"high": 188.44,
"low": 183.89,
"close": 185.64,
"adjusted_close": 185.64,
"volume": 82488300
},
{
"date": "2024-01-03",
"open": 184.22,
"high": 185.88,
"low": 183.43,
"close": 184.25,
"adjusted_close": 184.25,
"volume": 58414400
}
]Get all latest prices for NASDAQ:
curl "https://eodhd.com/api/eod-bulk-last-day/US?api_token=YOUR_API_TOKEN&fmt=json"Last 30 days only:
curl "https://eodhd.com/api/eod/MSFT.US?api_token=YOUR_API_TOKEN&period=d&order=d"curl "https://eodhd.com/api/eod/GOOGL.US?api_token=YOUR_API_TOKEN&fmt=csv"curl "https://eodhd.com/api/real-time/TSLA.US?api_token=YOUR_API_TOKEN&fmt=json"Response:
{
"code": "TSLA.US",
"timestamp": 1704398400,
"gmtoffset": -18000,
"open": 238.45,
"high": 245.32,
"low": 237.12,
"close": 243.84,
"volume": 145632100,
"previousClose": 237.93,
"change": 5.91,
"change_p": 2.48
}5-minute intervals:
curl "https://eodhd.com/api/intraday/AAPL.US?api_token=YOUR_API_TOKEN&interval=5m&from=1704067200&to=1704153600&fmt=json"1-hour intervals:
curl "https://eodhd.com/api/intraday/MSFT.US?api_token=YOUR_API_TOKEN&interval=1h&fmt=json"Next 7 days:
curl "https://eodhd.com/api/calendar/earnings?api_token=YOUR_API_TOKEN&fmt=json"Specific date range:
curl "https://eodhd.com/api/calendar/earnings?api_token=YOUR_API_TOKEN&from=2024-03-01&to=2024-03-31&fmt=json"Response:
{
"type": "Earnings",
"description": "Historical and upcoming Earnings",
"from": "2024-03-01",
"to": "2024-03-31",
"earnings": [
{
"code": "AAPL.US",
"report_date": "2024-03-15",
"date": "2024-03-15",
"before_after_market": "AfterMarket",
"currency": "USD",
"actual": 1.52,
"estimate": 1.48,
"difference": 0.04,
"percent": 2.7
}
]
}Specific symbols only:
curl "https://eodhd.com/api/calendar/earnings?api_token=YOUR_API_TOKEN&symbols=AAPL.US,MSFT.US,GOOGL.US&fmt=json"curl "https://eodhd.com/api/calendar/ipos?api_token=YOUR_API_TOKEN&from=2024-01-01&to=2024-12-31&fmt=json"curl "https://eodhd.com/api/calendar/splits?api_token=YOUR_API_TOKEN&from=2024-01-01&to=2024-12-31&fmt=json"curl "https://eodhd.com/api/calendar/trends?api_token=YOUR_API_TOKEN&fmt=json"curl "https://eodhd.com/api/fundamentals/AAPL.US?api_token=YOUR_API_TOKEN"Response includes:
- General company information
- Highlights (market cap, P/E ratio, etc.)
- Valuation metrics
- Share statistics
- Technicals
- Splits and dividends history
- Financials (Income Statement, Balance Sheet, Cash Flow)
- Earnings history and estimates
- Analyst ratings
Get only highlights:
curl "https://eodhd.com/api/fundamentals/AAPL.US?api_token=YOUR_API_TOKEN&filter=Highlights::*"Get only financials:
curl "https://eodhd.com/api/fundamentals/AAPL.US?api_token=YOUR_API_TOKEN&filter=Financials::*"curl "https://eodhd.com/api/div/AAPL.US?api_token=YOUR_API_TOKEN&from=2020-01-01&fmt=json"curl "https://eodhd.com/api/splits/TSLA.US?api_token=YOUR_API_TOKEN&from=2020-01-01&fmt=json"curl "https://eodhd.com/api/historical-market-cap/AAPL.US?api_token=YOUR_API_TOKEN&from=2023-01-01&to=2023-12-31"curl "https://eodhd.com/api/exchanges-list?api_token=YOUR_API_TOKEN&fmt=json"Response:
[
{
"Name": "New York Stock Exchange",
"Code": "US",
"OperatingMIC": "XNYS",
"Country": "USA",
"Currency": "USD",
"CountryISO2": "US",
"CountryISO3": "USA"
},
{
"Name": "NASDAQ",
"Code": "NASDAQ",
"OperatingMIC": "XNAS",
"Country": "USA",
"Currency": "USD",
"CountryISO2": "US",
"CountryISO3": "USA"
}
]curl "https://eodhd.com/api/exchange-details/US?api_token=YOUR_API_TOKEN&fmt=json"All NASDAQ symbols:
curl "https://eodhd.com/api/exchange-symbol-list/NASDAQ?api_token=YOUR_API_TOKEN&fmt=json"curl "https://eodhd.com/api/mp/unicornbay/options/contracts?api_token=YOUR_API_TOKEN&symbol=AAPL.US&fmt=json"curl "https://eodhd.com/api/mp/unicornbay/options/eod?api_token=YOUR_API_TOKEN&symbol=AAPL.US&date=2024-01-15&fmt=json"curl "https://eodhd.com/api/mp/unicornbay/options/underlying-symbols?api_token=YOUR_API_TOKEN&fmt=json"All news:
curl "https://eodhd.com/api/news?api_token=YOUR_API_TOKEN&fmt=json"Response:
[
{
"date": "2024-01-15T14:30:00Z",
"title": "Apple Announces New Product Line",
"content": "Apple Inc. today announced...",
"link": "https://example.com/article",
"symbols": ["AAPL.US"],
"tags": ["Technology", "Consumer Electronics"],
"sentiment": {
"polarity": 0.75,
"sentiment": "positive"
}
}
]Filter by symbol:
curl "https://eodhd.com/api/news?api_token=YOUR_API_TOKEN&s=AAPL.US&fmt=json"Filter by date range:
curl "https://eodhd.com/api/news?api_token=YOUR_API_TOKEN&from=2024-01-01&to=2024-01-31&fmt=json"Limit results:
curl "https://eodhd.com/api/news?api_token=YOUR_API_TOKEN&limit=10&offset=0&fmt=json"curl "https://eodhd.com/api/sentiments?api_token=YOUR_API_TOKEN&s=AAPL.US&from=2024-01-01&to=2024-01-31&fmt=json"curl "https://eodhd.com/api/news-word-weights?api_token=YOUR_API_TOKEN&s=AAPL.US&fmt=json"curl "https://eodhd.com/api/technical/AAPL.US?api_token=YOUR_API_TOKEN&function=sma&period=50&fmt=json"Available functions:
sma- Simple Moving Averageema- Exponential Moving Averagewma- Weighted Moving Averagersi- Relative Strength Indexmacd- Moving Average Convergence Divergencebbands- Bollinger Bandsstoch- Stochastic Oscillatoradx- Average Directional Index
Multiple indicators:
curl "https://eodhd.com/api/technical/AAPL.US?api_token=YOUR_API_TOKEN&function=sma&period=50&from=2024-01-01&to=2024-12-31&fmt=json"Search by name or ticker:
curl "https://eodhd.com/api/search/Tesla?api_token=YOUR_API_TOKEN&fmt=json"Response:
[
{
"Code": "TSLA",
"Exchange": "US",
"Name": "Tesla Inc",
"Type": "Common Stock",
"Country": "USA",
"Currency": "USD",
"ISIN": "US88160R1014"
}
]Screen by criteria:
curl "https://eodhd.com/api/screener?api_token=YOUR_API_TOKEN&filters=[[%22market_capitalization%22,%22%3E%22,1000000000],[%22pe_ratio%22,%22%3C%22,30]]&fmt=json"Parameters:
- Market cap > $1B
- P/E ratio < 30
curl "https://eodhd.com/api/economic-events?api_token=YOUR_API_TOKEN&from=2024-01-01&to=2024-01-31&fmt=json"US GDP:
curl "https://eodhd.com/api/macro-indicator/USA?api_token=YOUR_API_TOKEN&indicator=gdp_current_usd&fmt=json"Available indicators include:
gdp_current_usd- GDPinflation_consumer_prices_annual- Inflation rateunemployment_total- Unemployment rate- And many more...
curl "https://eodhd.com/api/symbol-change-history?api_token=YOUR_API_TOKEN&from=2024-01-01&to=2024-12-31&fmt=json"curl "https://eodhd.com/api/insider-transactions?api_token=YOUR_API_TOKEN&code=AAPL.US&limit=100&fmt=json"curl "https://eodhd.com/api/logo/AAPL.US?api_token=YOUR_API_TOKEN" > apple_logo.pngReturns 200x200 PNG with transparent background.
curl "https://eodhd.com/api/internal-user?api_token=YOUR_API_TOKEN"When rate limited, response includes:
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 0
Retry-After: 60{
"status": 401,
"error": "Unauthorized",
"message": "Invalid API token"
}200- Success400- Bad Request (invalid parameters)401- Unauthorized (invalid token)403- Forbidden (subscription doesn't include this endpoint)404- Not Found (symbol or resource doesn't exist)429- Too Many Requests (rate limit exceeded)500- Internal Server Error
Always specify date ranges to get relevant data:
# Good
curl "https://eodhd.com/api/eod/AAPL.US?api_token=YOUR_API_TOKEN&from=2024-01-01&to=2024-12-31"
# Less efficient
curl "https://eodhd.com/api/eod/AAPL.US?api_token=YOUR_API_TOKEN"Use JSON for programmatic access, CSV for analysis:
# JSON for apps
&fmt=json
# CSV for spreadsheets
&fmt=csvFor multiple symbols, use bulk endpoints when available:
# Efficient - bulk endpoint
curl "https://eodhd.com/api/eod-bulk-last-day/US?api_token=YOUR_API_TOKEN"
# Less efficient - multiple individual requests
curl "https://eodhd.com/api/eod/AAPL.US?api_token=YOUR_API_TOKEN"
curl "https://eodhd.com/api/eod/MSFT.US?api_token=YOUR_API_TOKEN"Cache EOD data since it doesn't change after market close:
import requests
from datetime import datetime
def get_eod_cached(symbol, date):
cache_key = f"{symbol}_{date}"
# Check cache first
if cache_key in cache:
return cache[cache_key]
# Fetch from API
response = requests.get(
f"https://eodhd.com/api/eod/{symbol}",
params={"api_token": "YOUR_TOKEN", "from": date, "to": date}
)
# Cache the result
cache[cache_key] = response.json()
return cache[cache_key]Implement exponential backoff:
import time
import requests
def fetch_with_retry(url, max_retries=3):
for attempt in range(max_retries):
response = requests.get(url)
if response.status_code == 200:
return response.json()
if response.status_code == 429:
retry_after = int(response.headers.get('Retry-After', 60))
time.sleep(retry_after)
continue
response.raise_for_status()
raise Exception("Max retries exceeded")import requests
class EODHDClient:
def __init__(self, api_token):
self.api_token = api_token
self.base_url = "https://eodhd.com/api"
def get_eod(self, symbol, from_date=None, to_date=None):
params = {"api_token": self.api_token, "fmt": "json"}
if from_date:
params["from"] = from_date
if to_date:
params["to"] = to_date
response = requests.get(f"{self.base_url}/eod/{symbol}", params=params)
response.raise_for_status()
return response.json()
def get_real_time(self, symbol):
params = {"api_token": self.api_token, "fmt": "json"}
response = requests.get(f"{self.base_url}/real-time/{symbol}", params=params)
response.raise_for_status()
return response.json()
# Usage
client = EODHDClient("YOUR_API_TOKEN")
prices = client.get_eod("AAPL.US", "2024-01-01", "2024-12-31")
quote = client.get_real_time("AAPL.US")const axios = require('axios');
class EODHDClient {
constructor(apiToken) {
this.apiToken = apiToken;
this.baseUrl = 'https://eodhd.com/api';
}
async getEOD(symbol, fromDate, toDate) {
const params = { api_token: this.apiToken, fmt: 'json' };
if (fromDate) params.from = fromDate;
if (toDate) params.to = toDate;
const response = await axios.get(`${this.baseUrl}/eod/${symbol}`, { params });
return response.data;
}
async getRealTime(symbol) {
const params = { api_token: this.apiToken, fmt: 'json' };
const response = await axios.get(`${this.baseUrl}/real-time/${symbol}`, { params });
return response.data;
}
}
// Usage
const client = new EODHDClient('YOUR_API_TOKEN');
const prices = await client.getEOD('AAPL.US', '2024-01-01', '2024-12-31');
const quote = await client.getRealTime('AAPL.US');