Skip to main content
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.

Prerequisites

  • Python 3.7+
  • A Financial Datasets API key (sign up here)
  • The requests library (pip install requests)

Step 1: Set Up Authentication

Every API request requires your API key in the X-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 a ticker, interval, start_date, and end_date.

Step 3: Change the Interval

Switch interval 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:
This returns all 27,000+ tickers with historical price data from exchanges like NYSE and NASDAQ, including 3 years of data.

Next Steps