Get Yahoo Finance data in Python via API

Extract Yahoo Finance data via API with a few lines of Python. Get stock quotes, historical prices, price targets, earnings dates, analyst recommendations, dividends, fund data, and more as structured JSON. This is an unofficial tool built and run on Apify. It is not affiliated with, endorsed by, or sponsored by Yahoo. Start free, no credit card required.

POWERING THE WORLD'S TOP DATA-DRIVEN TEAMS

Integrate Yahoo Finance data in Python

The Apify API client for Python is the official library that allows you to get Yahoo Finance data via API in Python, providing convenience functions and automatic retries on errors. Get started with simple pip installation and robust error handling built-in.

Python

Python

1from apify_client import ApifyClient
2
3# Initialize the ApifyClient with your Apify API token
4# Replace '<YOUR_API_TOKEN>' with your token.
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7# Prepare the Actor input
8run_input = {
9 "tickers": [
10 "MSFT",
11 "AMZN",
12 ],
13 "proxy": { "useApifyProxy": True },
14}
15
16# Run the Actor and wait for it to finish
17run = client.actor("canadesk/yahoo-finance").call(run_input=run_input)
18
19# Fetch and print Actor results from the run's dataset (if there are any)
20print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
21for item in client.dataset(run["defaultDatasetId"]).iterate_items():
22 print(item)
23
24# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

Get Yahoo Finance data with Apify API Python client

Use our Python API client to extract Yahoo Finance data by providing ticker symbols with your configured filters and parameters. The API returns structured data, including stock quotes, historical prices, price targets, earnings dates, analyst recommendations, dividends, fund data, and more, which is perfect for pandas DataFrames, data analysis, and Python applications.

Input

{
"delay": 3,
"proxy": {
"useApifyProxy": true
},
"period": "1y",
"process": "gh",
"tickers": [
"MSFT"
],
"interval": "1d",
"rounding": "max",
"storecsv": "no"
}

Output

[
{
"data": [
{
"low": "312.55394893846466",
"Date": "2023-10-05",
"high": "317.59611925564633",
"open": "316.7127353294032",
"close": "316.980712890625",
"volume": "16965600"
}
],
"type": "history",
"ticker": "MSFT"
}
]

How to use our Python API to get Yahoo Finance data

Sign up for Apify account

Creating an account is quick and free. No credit card required. Your account gives you access to more than 97,000+ tools and APIs.

Get started for free
Install Apify Python client

Install the Apify Python client using pip: pip install apify-client. This package provides a simple interface to get Yahoo Finance data from your Python applications.

Get your Apify API token

Go to settings in the Apify console and navigate to the “API & Integrations” tab. There, create a new token and save it for later.

Open the Actor's API panel

Go to the Actor page and click the API dropdown in the top right corner. There you'll find API clients, endpoints, and more. Copy the Python code example to start getting Yahoo Finance data in your application.

Open Yahoo Finance Python API
Get Yahoo Finance data via API

The Actor API returns structured Yahoo Finance JSON data that works perfectly with pandas, NumPy, and other Python data analysis libraries.

Why use Apify?

Never get blocked

Every plan (free included) comes with Apify Proxy, which is great for avoiding blocking and giving you access to geo-specific content.

Customers love us

We truly care about the satisfaction of our users, and it shows. Apify is the no.1 data extraction tool on G2.

Monitor your runs

With our latest monitoring features, you always have immediate access to valuable insights on the status of your Actor runs.

Export to various formats

Your datasets can be exported to any format that suits your data workflow, including Excel, CSV, JSON, XML, HTML table, JSONL, and RSS.

Integrate Apify to your workflow

You can integrate your Apify runs with platforms such as Zapier, Make, Keboola, Google Drive, or GitHub. Connect with practically any cloud service or web app.

Large developer community

Apify is built by developers, so you'll be in good hands if you have any technical questions. Our Discord server is always here to help!

Frequently asked questions

Yahoo doesn't offer an official public API for Yahoo Finance data. This Actor is an unofficial alternative. It extracts publicly available data from Yahoo Finance pages and returns it as structured JSON you can use in your Python projects.

No. This tool is built by a developer in the Apify community and runs on the Apify platform. It is not affiliated with, endorsed by, or sponsored by Yahoo.

Yes. Create an Apify account and you get $5 of free monthly usage. No credit card required. Get your API token, install the Apify client with pip, and start making requests.

Stock quotes with open, high, low, and close prices; historical data with custom periods and intervals; company profiles; analyst recommendations and price targets; earnings dates; fund and ETF data; dividends; financial news; and trading volume.

Create a free Apify account, get your API token, and install the Apify client with pip install apify-client. Then copy the Python example from the Actor's API panel and run it. You can also call the Actor from JavaScript, CLI, cURL, OpenAPI, or MCP.

Get Yahoo Finance data in Python today

Get your first Yahoo Finance data in Python in less than 5 minutes. No credit card required. No commitment. Cancel anytime.