Yahoo Finance Historical Data Scraper avatar

Yahoo Finance Historical Data Scraper

Pricing

$0.60 / 1,000 results

Go to Apify Store
Yahoo Finance Historical Data Scraper

Yahoo Finance Historical Data Scraper

Get detailed historical price and volume data from Yahoo Finance for multiple stocks and custom year ranges

Pricing

$0.60 / 1,000 results

Rating

0.0

(0)

Developer

Eray Diler

Eray Diler

Maintained by Community

Actor stats

1

Bookmarked

32

Total users

7

Monthly active users

an hour ago

Last modified

Categories

Share

This Apify actor scrapes historical stock data from Yahoo Finance for one or more specified ticker symbols and a defined period.

Features

  • Fetches historical daily stock data including Open, High, Low, Close, Adjusted Close, and Volume.
  • Extracts dividend and stock split events from the same Yahoo Finance history table.
  • Supports multiple ticker symbols in a single run.
  • Allows specifying the time period (e.g., 5 days, 1 month, 5 years) of historical data to retrieve.
  • Outputs typed items in a structured JSON format to the Apify dataset.
  • Includes the ticker symbol in each data record for easy identification.

Input

The actor uses an input schema to define the parameters you can set when running it. You can provide these inputs via the Apify Console, API, or a local INPUT.json file.

Input Schema Fields:

  • symbols (Array of strings)

    • Title: Stock Ticker Symbols
    • Description: Enter one or more stock ticker symbols.
    • Example: ["AAPL", "TSLA"]
    • Default Value: ["AAPL"]
    • Required: Yes
  • dateRange (String)

    • Title: Date Range
    • Description: The time period for the historical data (e.g., 1d, 5d, 1mo, 1y, 5y, max).
    • Example: "5d"
    • Default Value: "1y"
    • Required: Yes
  • includeDividends (Boolean)

    • Description: Include dividend events from the history table.
    • Default Value: true
  • includeSplits (Boolean)

    • Description: Include stock split events from the history table.
    • Default Value: true
  • generateUnifiedOutput (Boolean)

    • Description: If enabled, creates an additional UNIFIED_OUTPUT.json in the Key-Value store grouping all events by symbol.
    • Default Value: true

Example INPUT.json:

{
"symbols": ["MSFT", "GOOG"],
"dateRange": "1y",
"includeDividends": true,
"includeSplits": false,
"generateUnifiedOutput": true
}

Output

The actor stores its results in two ways:

  1. Flat Dataset (Default): The default Apify Dataset. Items are typed and may represent either historical OHLCV rows or corporate action events.
  2. Unified Output (Key-Value Store): If generateUnifiedOutput is true (default), a single JSON array is saved as UNIFIED_OUTPUT.json in the Key-Value store, grouping all events by symbol.

1. Flat Dataset Examples

Example History Item (JSON):

{
"type": "history",
"date": "May 30, 2025",
"open": 170.50,
"high": 172.30,
"low": 170.10,
"close": 171.95,
"adjClose": 171.95,
"volume": 25000000,
"symbol": "AAPL"
}

Example Dividend Item (JSON):

{
"type": "dividend",
"date": "May 10, 2025",
"amount": 0.25,
"symbol": "AAPL"
}

Example Split Item (JSON):

{
"type": "split",
"date": "Aug 31, 2020",
"ratio": "4:1",
"symbol": "AAPL"
}

2. Unified Output Example (UNIFIED_OUTPUT.json)

[
{
"symbol": "AAPL",
"history": [
{ "date": "May 30, 2025", "open": 170.50, "high": 172.30, "low": 170.10, "close": 171.95, "adjClose": 171.95, "volume": 25000000 }
],
"dividends": [
{ "date": "May 10, 2025", "amount": 0.25 }
],
"splits": [
{ "date": "Aug 31, 2020", "ratio": "4:1" }
]
}
]

Usage

Running Locally

  1. Ensure you have Node.js and npm installed.
  2. Clone this project (or your Apify actor project).
  3. Install dependencies: npm install
  4. If you want to provide custom input, create a file at apify_storage/key_value_stores/default/INPUT.json with your desired input parameters (see example above).
  5. Run the actor: npx apify run (or npx apify run --purge to clear previous storage).

Running on the Apify Platform

  1. Push this actor to your Apify account: npx apify push
  2. On the Apify platform, find your actor and click "Run".
  3. Provide your input parameters in the "Input" tab or as a JSON object.
  4. Click "Start" to run the actor.
  5. Once the run is finished, you can find the results in the "Dataset" tab of the run. You can download the data in various formats (JSON, CSV, Excel, etc.).

Limitations

  • The scraper relies on Yahoo Finance's website structure. Significant changes to the Yahoo Finance website may break the actor.
  • Fetching very long periods (e.g., 30+ years) for multiple tickers might lead to long run times and increased resource consumption.
  • The actor does not currently handle pagination for extremely long historical data requests if Yahoo Finance were to implement it differently (currently, it loads all requested data on one page via URL parameters).
  • Cookie consent pop-ups are handled based on common selectors; if Yahoo changes its consent mechanism drastically, it might require an update.

TODO / Roadmap

  • Add earnings data and earnings calendar details.
  • Expand quote output with richer company and market stats.
  • Add company profile data such as sector, industry, and summary.
  • Add financial statements: income statement, balance sheet, and cash flow.
  • Add analyst recommendations and ratings.
  • Add institutional holders and ownership data.
  • Add options chain data with expiration dates.
  • Offer a unified per-symbol output format in addition to typed dataset items.
  • Improve output schema and README examples to document all returned fields.

📦 About

Created by Eray Diler for StrategyLab.