# Yahoo Finance Historical Data Scraper (`eraydiler/yahoo-finance-historical-data-scraper`) Actor

Get detailed historical price, volume data, company profiles, dividends, splits and events from Yahoo Finance for multiple stocks and custom date ranges.

- **URL**: https://apify.com/eraydiler/yahoo-finance-historical-data-scraper.md
- **Developed by:** [Eray Diler](https://apify.com/eraydiler) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 45 total users, 2 monthly users, 95.7% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.60 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Yahoo Finance Historical Data Scraper

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.
- Extracts company profile data including Sector, Industry, and Business Summary.
- Retrieves upcoming events (like earnings dates) and recent events (like SEC filings and dividend dates).
- 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. Supports days (`d`), weeks (`w`), months (`m`), years (`y`), and `max` for all available data.
  - **Example:** `"5d"`, `"2w"`, `"1m"`, `"1y"`, `"max"`
  - **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`

- **`includeProfile`** (Boolean)
  - **Description:** Include company profile data (Sector, Industry, Summary, Recent Events).
  - **Default Value:** `true`

- **`includeEvents`** (Boolean)
  - **Description:** Scrape paginated recent events from the profile page.
  - **Default Value:** `false`

- **`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`:**

```json
{
    "symbols": ["MSFT", "GOOG"],
    "dateRange": "1m",
    "includeDividends": true,
    "includeSplits": false,
    "includeProfile": true,
    "includeEvents": false,
    "generateUnifiedOutput": true
}
```

### Output

The actor stores its results in two ways:

1. **Flat Dataset (Default):** The default Apify [Dataset](https://docs.apify.com/platform/storage/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):**

```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):**

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

**Example Split Item (JSON):**

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

**Example Profile Item (JSON):**

```json
{
    "type": "profile",
    "symbol": "AAPL",
    "sector": "Technology",
    "industry": "Consumer Electronics",
    "summary": "Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories worldwide...",
    "upcomingEvents": [
        {
            "date": "July 30, 2026 at 11:00 PM GMT+3",
            "name": "Apple Inc. Earnings Date"
        }
    ],
    "recentEvents": [
        {
            "date": "May 28, 2026 at 3:00 AM GMT+3",
            "name": "SD: Specialized Disclosure Report filed pursuant to Section 1502..."
        }
    ]
}
```

#### 2. Unified Output Example (`UNIFIED_OUTPUT.json`)

```json
[
  {
    "symbol": "AAPL",
    "profile": {
      "sector": "Technology",
      "industry": "Consumer Electronics",
      "summary": "Apple Inc. designs..."
    },
    "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

To use this scraper, simply provide your input parameters in the Apify Console and click "Start".
You can integrate this actor into your own workflows using the Apify API or Apify Client libraries.

#### Providing Input

1. Navigate to the Actor's page on the Apify Store.
2. Fill in the "Input" tab or switch to the "JSON" view to provide your parameters.
3. Click "Start" to run the actor.
4. 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

- \[x] Add earnings data and earnings calendar details.
- \[ ] Expand quote output with richer company and market stats.
- \[x] 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.
- \[x] Offer a unified per-symbol output format in addition to typed dataset items.
- \[x] Improve output schema and README examples to document all returned fields.

### 📦 About

Created by **Eray Diler** for **StrategyLab**.

# Changelog

This Actor's version history is a separate document: https://apify.com/eraydiler/yahoo-finance-historical-data-scraper/changelog.md

# Actor input Schema

## `symbols` (type: `array`):

List of stock symbols to process.

## `dateRange` (type: `string`):

The time period for the historical data (e.g., 1d, 5d, 1mo, 1y, 5y, max).

## `includeDividends` (type: `boolean`):

Include dividend events from the Yahoo Finance history table.

## `includeSplits` (type: `boolean`):

Include stock split events from the Yahoo Finance history table.

## `includeProfile` (type: `boolean`):

Scrape company profile data (Sector, Industry, Summary).

## `includeEvents` (type: `boolean`):

Scrape upcoming and recent events from the profile page. Warning: This may increase execution time.

## `proxyConfiguration` (type: `object`):

Select proxies to be used by the scraper. Using Apify Proxy or Residential proxies is recommended to prevent blocking.

## `generateUnifiedOutput` (type: `boolean`):

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

## Actor input object example

```json
{
  "symbols": [
    "AAPL",
    "MSFT",
    "GOOGL"
  ],
  "dateRange": "1y",
  "includeDividends": true,
  "includeSplits": true,
  "includeProfile": true,
  "includeEvents": false,
  "proxyConfiguration": {
    "useApifyProxy": true
  },
  "generateUnifiedOutput": true
}
```

# Actor output Schema

## `historicalData` (type: `string`):

No description

## `unifiedOutput` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("eraydiler/yahoo-finance-historical-data-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("eraydiler/yahoo-finance-historical-data-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call eraydiler/yahoo-finance-historical-data-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eraydiler/yahoo-finance-historical-data-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/dmPLBbkVfhlbkO3uM/builds/qRLVAfWIOWa2McodT/openapi.json
