Skip to content

About

Yahoo Finance Scraper: Scrape Yahoo Finance for stocks, ETFs, indexes, crypto and currencies: quotes and key statistics (price, market cap, P/E, dividend, earnings date), price history with adjusted close and dividends,... Python, Node.js and curl examples (runs on Apify)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yahoo Finance Scraper: export to CSV or JSON with Python, Node.js or curl

Scrape Yahoo Finance for stocks, ETFs, indexes, crypto and currencies: quotes and key statistics (price, market cap, P/E, dividend, earnings date), price history with adjusted close and dividends, or options chains with bid, ask, open interest, implied volatility, greeks and max pain.

This repository has ready scripts for the Yahoo Finance Scraper: Options Chain, History, Stock Quotes Actor on Apify. The Actor does the fetching, paging and cleaning; the scripts here run it with your input and save the results as a CSV or JSON file.

Quick start

  1. Create an Apify account and copy your API token from Console > Settings > Integrations.
  2. Install the client and run the script with the example input:
pip install "apify-client>=2"
export APIFY_TOKEN=your_token
python run.py input.json -o results.csv --max-items 50

Edit input.json for your own run. You can also run the Actor in the browser on its Apify page, schedule it there, and connect its output to Google Sheets, Slack, Zapier or Make.

Input

The example input (input.json):

{
  "tickers": [
    "AAPL",
    "MSFT",
    "NVDA",
    "AMZN",
    "GOOGL",
    "META",
    "TSLA",
    "SPY",
    "QQQ",
    "^GSPC",
    "BTC-USD",
    "EURUSD=X"
  ],
  "maxItems": 20
}
Field Type What it does
tickers array Yahoo Finance symbols, one per entry: stocks such as AAPL or BRK-B, ETFs such as SPY, indexes such as ^GSPC, crypto such as BTC-USD, currency pairs such as E...
dataType string quotes: one row per ticker with price, change, volume and key statistics.
startDate string First day of the price history as YYYY-MM-DD, for example 2020-01-01.
endDate string Last day of the price history as YYYY-MM-DD.
interval string One row per trading day, week or month.
optionType string Which contracts to return.
expirations integer How many expiration dates to read per ticker, starting from the nearest one.
expirationDates array Read these expiration dates instead of the nearest ones, as YYYY-MM-DD, for example 2026-12-18.
minStrike integer Skip contracts with a lower strike price.
maxStrike integer Skip contracts with a higher strike price.
minOpenInterest integer Skip contracts with less open interest.
minVolume integer Skip contracts that traded fewer contracts today.
riskFreeRate number Yearly interest rate in percent, such as a Treasury bill yield, used for the greeks, for example 4.25.
maxItems integer The run stops after this many result rows.

Output

One row per result. A real row from a run of the example input (more in examples/sample-output.json):

{
  "symbol": "AAPL",
  "name": "Apple Inc.",
  "quoteType": "EQUITY",
  "exchange": "NasdaqGS",
  "currency": "USD",
  "marketState": "OVERNIGHT",
  "price": 350.69,
  "change": 8.32001,
  "changePercent": 2.43012,
  "previousClose": 342.37,
  "open": 344.935,
  "dayLow": 344.78,
  "dayHigh": 352.28,
  "fiftyTwoWeekLow": 243.42,
  "fiftyTwoWeekHigh": 355.38,
  "volume": 47499490,
  "averageVolume": 42880493,
  "marketCap": 5096291172352,
  "trailingPE": 39.05234,
  "forwardPE": 33.235027,
  "epsTrailing": 8.98,
  "dividendRate": 1.08,
  "dividendYield": 0.32,
  "exDividendDate": "2026-11-12",
  "beta": 1.089,
  "earningsDate": "2027-01-28",
  "targetMeanPrice": 340.4655,
  "recommendation": "buy",
  "sector": "Technology",
  "industry": "Consumer Electronics",
  "regularMarketTime": "2026-11-09T21:00:01Z",
  "url": "https://finance.yahoo.com/quote/AAPL/",
  "scrapedAt": "2026-11-10T02:40:31Z"
}

Fields: symbol, name, quoteType, exchange, currency, marketState, price, change, changePercent, previousClose, open, dayLow, dayHigh, fiftyTwoWeekLow, fiftyTwoWeekHigh, volume, averageVolume, marketCap, trailingPE, forwardPE, epsTrailing, dividendRate, dividendYield, exDividendDate, beta, earningsDate, targetMeanPrice, recommendation, sector, industry, regularMarketTime, url, scrapedAt.

Node.js

import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('v0iddo/yahoo-finance-scraper').call({"tickers": ["AAPL", "MSFT", "NVDA", "AMZN", "GOOGL", "META", "TSLA", "SPY", "QQQ", "^GSPC", "BTC-USD", "EURUSD=X"], "maxItems": 20});
const { items } = await client.dataset(run.defaultDatasetId).listItems();

Full example: examples/node/run.mjs.

Any language: one HTTP request

curl -X POST "https://api.apify.com/v2/acts/v0iddo~yahoo-finance-scraper/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" -H 'Content-Type: application/json' \
  -d '{"tickers": ["AAPL", "MSFT", "NVDA", "AMZN", "GOOGL", "META", "TSLA", "SPY", "QQQ", "^GSPC", "BTC-USD", "EURUSD=X"], "maxItems": 20}'

The response is the JSON array of results.

Cost

The Actor is paid per result: $0.50 per 1,000 results, nothing per run. maxItems caps the rows, and so the cost, of one run. A new Apify account gets $5 of platform credit every month.

License

MIT for the code in this repository. Made by vøiddo.

About

Yahoo Finance Scraper: Scrape Yahoo Finance for stocks, ETFs, indexes, crypto and currencies: quotes and key statistics (price, market cap, P/E, dividend, earnings date), price history with adjusted close and dividends,... Python, Node.js and curl examples (runs on Apify)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages