Knowledge Base | How to Export Option Chains from Yahoo Finance to CSV

How to Export Option Chains from Yahoo Finance to CSV

Contents

Option Chains at Yahoo Finance

Yahoo Finance publishes US stock option chains.

You can open https://finance.yahoo.com/, search a ticker like YHOO, and click the 'Options' tab.

You can use URLs like https://finance.yahoo.com/quote/AAPL/?p=AAPL to open pages with option chains directly.

Yahoo Finance has no links to download option chains to CSV.

Undocumented URLs to Download Option Chains from Yahoo Finance

Yahoo Finance uses a web service to load option chains into web pages.

The web service returns JSON and has URLs like these:

https://query1.finance.yahoo.com/v7/finance/options/YHOO

https://query1.finance.yahoo.com/v7/finance/options/YHOO?date=1510876800

Specify the expiration date as a Unix timestamp.

You can use specialized download and parser utilities like gsqlcmd to download and convert JSON data to CSV.

For example, to get option chains use the command:

gsqlcmd convert ^
    "https://query1.finance.yahoo.com/v7/finance/options/YHOO" ^
    yhoo.csv /delay=200 /echoOutputFileName /pages=20 /rootPath=*.*.*.calls,*.*.*.puts

gsqlcmd in the webtocsv mode loads web data (JSON, XML, HTML, CSV) and converts the data to CSV.

Specify the /rootPath=*.*.*.calls,*.*.*.puts parser parameter that points to the JSON roots of call and put option chains.

gsqlcmd loads option chains for all expiration dates automatically. Just specify the /page=20 option.

Loading Option Chains from Yahoo Finance with Batch Files

Create a text file like 'task.txt' and place tickers one by line like:

TICKERS.TXT
AAPL
FB
GOOGL
YHOO

Create a batch file like 'load.cmd' with the following commands:

LOAD.CMD
@echo off

@for /F %%i in (tickers.txt) do (
    gsqlcmd convert ^
        "https://query1.finance.yahoo.com/v7/finance/options/%%i" ^
        %%i.JSON %%i.CSV /delay=200 /echoOutputFileName /pages=20 /rootPath=*.*.*.calls,*.*.*.puts
)

Run it. You will see the result:

C:>load.cmd
AAPL.CSV - 1210 rows
FB.CSV - 960 rows
GOOGL.CSV - 1814 rows
YHOO.CSV - 384 rows

Pay attention to the /delay parameter. Use the delay to avoid banning your IP due to frequent multiple automatic requests.

Downloads

Products for Option Traders
gsqlcmd
This tool downloads, converts, and imports data from Yahoo Finance and MSN Money
Version: 6.14 | 05/05/2025 | 14.6MB | www.gsqlcmd.com
Download

Disclaimer

Yahoo Finance is a logo and registered trademark of Yahoo! Inc.

This website is using cookies. By continuing to browse, you give us your consent to our use of cookies as explained in our Cookie Policy.