> ## Content Index
> Fetch the complete content index at: https://serpapi.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Scrape Yahoo Finance Data (Tutorial 2026)
- URL: https://serpapi.com/blog/scrape-yahoo-finance-data/
- Published: 2026-12-04T08:02:10.000Z
- Updated: 2026-12-04T08:02:38.000Z
- Description: Get stock quotes and price history with SerpApi's Yahoo! Finance API. Check stock data with cURL, Python, or JavaScript and export the chart data to CSV.
- Author: Hilman Ramadhan
- Tags: Yahoo, finance

To display a stock on a watchlist, you need its quoted price. To chart how that price has changed, you need a series of prices and timestamps. The [Yahoo! Finance API from SerpApi](https://serpapi.com/yahoo-finance-api) can return both in a single ticker lookup. In this guide, you'll make that request with cURL, read the results in Python or JavaScript, and export the price history to CSV.

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/12/CleanShot-2026-12-03-at-16.15.45.png)

Yahoo Finance API playground

## What data can you retrieve with the Yahoo! Finance API?

For a ticker lookup, start with two top-level fields: `summary` is an object describing the quote; `graph` is a separate array with one entry per chart point.

- **Quote for display or calculation:** `summary.price` is the formatted regular-session price, `summary.extracted_price` is its numeric value, and `summary.currency` tells you the unit.
- **Chart data:** Pair each point's `date` with its `close` to plot a price against a timestamp in the exchange's time zone.
- **Trading activity:** `stats.previous_close.extracted_value` gives you the previous closing price, and `stats.volume.extracted_value` gives you the trading volume as a number.
- **Earnings:** For a stock like Apple, `earnings.quarterly` can include both `actual` and `estimate`, so you can compare reported earnings per share with expectations.
- **Symbol lookup:** A company-name search returns matches in `suggestions`; each match has a `stock` symbol and a `serpapi_link` for looking up its quote with the same API.

The available fields depend on the instrument. See the [API documentation](https://serpapi.com/yahoo-finance-api) for the full list and examples for stocks, ETFs, and cryptocurrencies.

## How to use the Yahoo! Finance API

You can use our API with any AI tools or any programming language.

### Try it in the Playground

Open the [AAPL example in the Playground](https://serpapi.com/playground?engine=yahoo%5Ffinance&q=AAPL&highlight=summary). With `engine=yahoo_finance` and `q=AAPL`, look at `summary.price` and `summary.date` together: that's the quoted price and the time it was reported. Feel free to change the search query to another item you want to check.

### Get your API key

[Create a SerpApi account](https://serpapi.com/users/sign%5Fup), then copy your key from [Manage API Key](https://serpapi.com/manage-api-key). In the terminal where you'll run the examples, replace the placeholder with your own key:

```
export SERPAPI_API_KEY="YOUR_SERPAPI_API_KEY"
```

Keep the key out of source files, screenshots, and shared URLs.

### Make a GET request

Our API is accessible in a simple GET request. JSON is the default. Use this form when your code needs exact fields 

```
https://serpapi.com/search?engine=yahoo_finance&q=AAPL&api_key=YOUR_SERPAPI_API_KEY

```

For a readable version of the same lookup, add `output=md`. [Markdown output](https://serpapi.com/markdown-output) presents a selection of the data rather than every JSON field:

```
https://serpapi.com/search?engine=yahoo_finance&q=AAPL&api_key=YOUR_SERPAPI_API_KEY&output=md

```

### cURL implementation

Here's the equivalent of the request in cURL. `engine` selects Yahoo! Finance, `q` supplies the ticker, and `api_key` authenticates the request.

```curl
curl --get --fail 'https://serpapi.com/search' \
  --data-urlencode 'engine=yahoo_finance' \
  --data-urlencode 'q=AAPL' \
  --data-urlencode "api_key=$SERPAPI_API_KEY"

```

### Python implementation

Install the [SerpApi Python SDK](https://serpapi.com/integrations/python) in your Python environment:

```
pip install serpapi
```

Save this as `main.py`. The SDK returns a dictionary-like result, so you can read the quote and loop over the chart points directly.

```python
import os

import serpapi

symbol = "AAPL"
client = serpapi.Client(api_key=os.environ["SERPAPI_API_KEY"], timeout=60)
result = client.search({"engine": "yahoo_finance", "q": symbol})
if "error" in result:
    raise SystemExit(f"SerpApi returned an error for {symbol}.")

summary = result.get("summary") or {}
print(f"{symbol} regular-session price:", summary.get("price", "not available"))

points = result.get("graph") or []
if not points:
    print("No chart points returned.")
for point in points[:5]:
    print(point.get("date", "n/a"), point.get("close", "n/a"), sep=" | ")

```

Run the code with:

```
python your-file-name.py
```

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/12/CleanShot-2026-12-03-at-16.21.11.png)

sample results of Yahoo finance API

The first line is the price you'd display on the watchlist. The next lines are `timestamp | close`, up to five points in response order. An empty chart gets its own message; a failed lookup stops the script instead.

#### Export the chart to CSV

To keep every point, append this block to `main.py`. It reuses `points` from the same response, so the export doesn't need a second request. Each entry becomes one row with the ticker, the timestamp as returned, and the closing price. Missing values stay blank.

```python
import csv

if points:
    with open("prices.csv", "w", encoding="utf-8", newline="") as file:
        writer = csv.writer(file)
        writer.writerow(["symbol", "date", "close"])
        for point in points:
            writer.writerow([symbol, point.get("date"), point.get("close")])
```

Run `python your-file-name.py` with the block in place. If there are chart points, the script writes `prices.csv` in your current directory, replacing any file of that name.

![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/2026/12/CleanShot-2026-12-03-at-16.22.58.png)

Exported CSV file - yahoo finance scraper

### JavaScript implementation

  
To print the same fields in Node.js, install the [SerpApi JavaScript library](https://github.com/serpapi/serpapi-javascript/):

```
npm install serpapi
```

Save this as `main.js`:

```javascript
async function main() {
  const apiKey = process.env.SERPAPI_API_KEY;
  if (!apiKey) {
    console.error("Set SERPAPI_API_KEY before running main.js.");
    process.exitCode = 1;
    return;
  }

  const { getJson } = await import("serpapi");
  const symbol = "AAPL";
  const result = await getJson({ engine: "yahoo_finance", q: symbol, api_key: apiKey });
  if ("error" in result) {
    console.error(`SerpApi returned an error for ${symbol}.`);
    process.exitCode = 1;
    return;
  }

  console.log(`${symbol} regular-session price:`, result.summary?.price ?? "not available");
  const points = result.graph ?? [];
  if (!points.length) console.log("No chart points returned.");
  for (const point of points.slice(0, 5)) {
    console.log(`${point.date ?? "n/a"} | ${point.close ?? "n/a"}`);
  }
}

main().catch(() => {
  console.error("Could not complete the lookup. Check the SDK installation, API key, and connection.");
  process.exitCode = 1;
});

```

Run it with:

```
node main.js
```

### Other languages and no-code options

Check our integrations page for more programming languages. We also have CLI and MCP available for your AI tools:

[SerpApi: IntegrationsEasy integration. SerpApi provides APIs and integrations for multiple programming languages and AI tools, including Model Context Protocol (MCP).![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/icon/favicon-740da5f4-8c1a-42ea-9bf1-60c17efdf683.png)SerpApi![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/thumbnail/serpapi-social-image-05b336fa-3067-4a6e-b3b2-f247653f2dd6.png)](https://serpapi.com/integrations)

You can also use a tool like Make.com with a custom HTTP request:

[Announcing SerpApi's Make AppWe are pleased to announce the release of our Custom App on Make.com. This makes it easier than ever to integrate SerpApi with other systems without having to write any code.![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/icon/serpapi-favicon-bb8b769b-fd60-4090-8d90-c165ae462193.png)SerpApiAlex Barron![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/thumbnail/Logo-RGB-Color@2x-2b4aa603-54dd-4df6-a386-5eb57db4427d.png)](https://serpapi.com/blog/announcing-serpapis-make-app/#universal-module)

## Customize the chart range and region

- `**window**` sets the time span of the graph. Use `1D` for one day, `YTD` for the year to date, or `1Y` for one year. A one-year chart can also include the open, high, low, and volume for each interval.
- `**yahoo_domain**` selects the regional edition. The default is `finance.yahoo.com`; `de` selects `de.finance.yahoo.com`. This changes number formatting and which tickers appear in the regional market lists. It doesn't convert the quote to euros. Use `summary.extracted_price` for arithmetic rather than parsing a localized price string.

For example, to request a year of Apple chart data, keep the ticker and add `window=1Y`:

```
https://serpapi.com/search?engine=yahoo_finance&q=AAPL&window=1Y&api_key=YOUR_SERPAPI_API_KEY
```

## Conclusion

You now have two pieces for a watchlist row: a regular-session price for the label and timestamped closes for the chart. To see the difference the time range makes, open [the AAPL Playground example](https://serpapi.com/playground?engine=yahoo%5Ffinance&q=AAPL&highlight=summary), set `window` to `1Y`, and compare the dates of the first few chart points with the original response.

We also have a [Google Finance API](https://serpapi.com/google-finance-api) if you want to check the data from the Google Finance page. Here is the full tutorial:  

[Web scraping stock prices in PythonLearn how to scrape stock prices in Python using Google Finance API. Get finance data programmatically!![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/icon/serpapi-favicon-48821696-7641-4984-b985-96cff7a9842f.png)SerpApiHilman Ramadhan![](https://storage.ghost.io/c/a5/00/a5004977-0dd2-4bcd-9292-dd0e05d4c59e/content/images/thumbnail/scrape-stock-price-in-python-004ea5a9-5f41-4423-90e9-588025a072ff.webp)](https://serpapi.com/blog/web-scraping-stock-prices-in-python/)

## Frequently asked questions

**What if I know the company name but not its ticker?**   
We have the [Google Finance Autocomplete API](https://serpapi.com/google-finance-autocomplete-api) to search listings name based on the company name.

**Why are there gaps in the chart?**   
Yahoo! Finance has no price point for an interval without a trade. That can leave several minutes between points, especially outside the regular session. Plot the returned timestamps rather than assuming rows are evenly spaced.

**How fresh is the displayed price?**  
We always perform live scraping on the website. Check `summary.date`, for the time information from Yahoo.  
  
Warning: An identical request can use SerpApi's cache for up to an hour. `no_cache=true` requests a fresh fetch.