Historical stock price data is essential for backtesting trading strategies, building financial models, and rendering price charts. This guide walks you through fetching OHLCV (open, high, low, close, volume) price data using Python.Documentation Index
Fetch the complete documentation index at: https://docs.financialdatasets.ai/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Python 3.7+
- A Financial Datasets API key (sign up here)
- The
requestslibrary (pip install requests)
Step 1: Set Up Authentication
Every API request requires your API key in theX-API-KEY header.
Step 2: Fetch Daily Stock Prices
Use the Prices API to pull end-of-day prices for any US ticker. You must specify aticker, interval, start_date, and end_date.
Step 3: Change the Interval
Switchinterval to get weekly, monthly, or yearly aggregated prices:
Step 4: Get a Real-Time Price Snapshot
For the latest price, use the Snapshot API:Available Tickers
You can fetch the full list of available tickers:Next Steps
- Stock Prices API Reference — full parameter documentation
- Financial Statements Guide — combine price data with fundamentals
- Quick Start — overview of all available endpoints