# Yahoo Finance Scraper — Quotes, History & Ticker Search (`axery/yahoo-finance-scraper`) Actor

Scrape live stock quotes, historical OHLCV price data, and ticker symbol search from Yahoo Finance. No login, no API key.

- **URL**: https://apify.com/axery/yahoo-finance-scraper.md
- **Developed by:** [Axery](https://apify.com/axery) (community)
- **Categories:** Business, Developer tools, News
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Yahoo Finance Quotes & History Scraper

Scrapes live stock quotes, historical OHLCV price data, and ticker symbol search from Yahoo Finance — price, market cap, valuation ratios, analyst targets, and full price history. No login, no API key.

Useful for portfolio tracking, market research, building a price-history archive, and screening on fundamentals across a watchlist.

### Three modes

- **Live quote** — a current snapshot per symbol: price, day range, volume, market cap, P/E, 52-week range, and optionally sector/industry/analyst targets.
- **Price history** — OHLCV candles over a chosen range and interval, one row per candle.
- **Symbol search** — look up tickers by company name or keyword.

### What makes this different

**The crumb requirement is handled for you.** Two of Yahoo's own endpoints — the live quote and the fundamentals — return `HTTP 401 Invalid Crumb` without one, and the fix isn't in Yahoo's docs: fetch a crumb from the *same session* that first visited `fc.yahoo.com`, using a plain request with no `Accept: application/json` header (the crumb endpoint answers 406 if you send one — the one endpoint on this API that wants to be asked differently from every other). Skip either step and the crumb comes back invalid even though the request itself returns 200. This Actor handles both, transparently, and refreshes the crumb automatically if it goes stale mid-run.

**Every epoch timestamp is converted.** Yahoo mixes Unix-seconds and Unix-milliseconds fields in the same quote response (`regularMarketTime`, `dividendDate`, `firstTradeDateMilliseconds`, ...) with no field-name hint as to which is which. All of them come out as proper ISO-8601 here.

**Nothing is silently dropped.** A live quote has roughly 90 fields; the ~40 most useful are broken out into named columns, and every other field Yahoo returns is still there in `extra_fields` rather than discarded.

**A bad symbol doesn't break the batch.** An unmatched ticker is logged and simply produces no row for that symbol — the rest of your list still comes back.

### Input

| Field | Type | Notes |
|---|---|---|
| `mode` | enum | `quote`, `history`, or `search`. |
| `targets` | array | Ticker symbols (quote/history) or search queries (search). |
| `includeFundamentals` | boolean | Sector, industry, analyst targets. Quote mode, one extra request per symbol. |
| `range` | enum | How far back. History mode. |
| `interval` | enum | Candle size. History mode. Intraday intervals only cover short ranges. |
| `proxyConfiguration` | object | Not normally needed. |

### Output

```json
{
  "record_type": "quote",
  "symbol": "AAPL",
  "longName": "Apple Inc.",
  "regularMarketPrice": 309.35,
  "regularMarketChangePercent": -0.6264,
  "marketCap": 4514709504000,
  "trailingPE": 35.475918,
  "fiftyTwoWeekHigh": 344.57,
  "sector": "Technology",
  "target_mean_price": 324.45282,
  "recommendation_key": "buy"
}
```

`record_type` tells rows from different modes apart if you ever mix runs into one dataset. Each run also writes a `RUN_COVERAGE` record to the key-value store with what was requested, what came back, and any failure.

### Local development

```bash
pip install -r requirements.txt
python test_local.py quote AAPL MSFT --fundamentals
python test_local.py history AAPL --range 1y --interval 1wk --out sample_output.json
python test_local.py search apple
```

`sample_output.json` is real output from a live history run.

# Actor input Schema

## `mode` (type: `string`):

`Live quote` returns a current snapshot per symbol. `Price history` returns OHLCV candles over a date range. `Symbol search` looks up tickers by company name or keyword.

## `targets` (type: `array`):

In `quote`/`history` mode: ticker symbols (e.g. `AAPL`, `BTC-USD`). In `search` mode: company names or keywords.

## `includeFundamentals` (type: `boolean`):

Add sector, industry, business summary and analyst price targets - one extra request per symbol. Quote mode only.

## `range` (type: `string`):

How far back the price history goes. History mode only.

## `interval` (type: `string`):

Candle size. Intraday intervals (5m/15m/30m/1h) only return data for short ranges - use a range of a few days for those. History mode only.

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

Not normally needed - this is the same public API Yahoo Finance's own frontend calls.

## Actor input object example

```json
{
  "mode": "quote",
  "targets": [
    "AAPL"
  ],
  "includeFundamentals": false,
  "range": "1mo",
  "interval": "1d",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `data` (type: `string`):

Quotes, price history, or search matches depending on the mode selected.

# 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 = {
    "targets": [
        "AAPL",
        "MSFT"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("axery/yahoo-finance-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 = { "targets": [
        "AAPL",
        "MSFT",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("axery/yahoo-finance-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 '{
  "targets": [
    "AAPL",
    "MSFT"
  ]
}' |
apify call axery/yahoo-finance-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,axery/yahoo-finance-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/k7oKcDHffQyvgcAze/builds/DR4cmfgtNeOLz9zjr/openapi.json
