Yahoo Finance! – Fetch Stock & Options Data with n8n


Who’s it for

  • Folks who need live options chains and intraday OHLCV from Yahoo Finance without third-party APIs.
  • Builders creating dashboards, alerts, or research pipelines inside n8n.
  • Anyone who’s been blocked by Yahoo’s cookie + crumb requirement and wants a reliable pattern to fetch data.

How it works / What it does

This workflow mimics what a browser does so Yahoo’s endpoints will respond with data:

  1. Symbol Configuration (Code node) – Sets the ticker (default ^SPX).
  2. Get Yahoo Cookies (HTTP Request) – Grabs initial cookies from https://fc.yahoo.com.
  3. Prepare Cookie Jar (Code node) – Cleans cookies into a usable string and adds a User-Agent.
  4. Get Crumb (HTTP Request) – Retrieves the required “crumb” token from Yahoo.
  5. Fetch Options (HTTP Request) – Gets the options chain for the symbol using UA, Cookie, and Crumb.
  6. Map Calls/Put Options (Code node) – Extracts clean calls and puts arrays.
  7. Fetch Stock Data (HTTP Request) – Gets intraday stock chart data.
  8. Map Stock (Code node) – Outputs OHLCV points (time, open, high, low, close, volume).

Outputs:

  • Calls/Puts (1 item with calls & puts arrays)
  • Stock data (OHLCV items for 1-minute, 1-day range)

How to set up

  1. Import the JSON into n8n (Workflows → Import from File/Clipboard).
  2. Open “Symbol Configuration” and set your ticker (e.g. AAPL, BTC-USD).
  3. Click Execute Workflow.
  4. View results:
    • Map Calls/Put Options” → option chains
    • Map Stock” → OHLCV intraday series

:light_bulb: To run automatically, swap the Manual Trigger for a Cron node.


Requirements

  • n8n (no external credentials needed).
  • Outbound HTTPS access to:
    • https://fc.yahoo.com
    • https://query2.finance.yahoo.com/*

Note: Yahoo may rate-limit or update its API. This workflow ensures cookies, UA, and crumb handling, but adjustments may be needed over time.


How to customize the workflow

  • Change the symbol → Edit the “Symbol Configuration” node.
  • Chart granularity → In “Fetch Stock Data”, update interval (1m, 5m, 1d, etc.) and range (1d, 1mo, 1y, etc.).
  • Options expiries → Modify “Map Calls/Put Options” to select or return multiple expiration dates.
  • Store data → Add a database node (e.g. PostgreSQL, MySQL, SQLite) after “Map Stock” or “Map Options”.
  • Alerts & automation → Connect to Slack, Telegram, Email, or dashboards.
  • Production-ready → Add retries, error handling, or cache crumb/cookies across runs.

:warning: Disclaimer: Data is provided for personal/educational purposes. Review Yahoo Finance’s Terms of Service before redistribution or commercial use.

3 Likes

Really appreciate your work!

good job guy

I love you mate