Purpose
cnn-fear-and-greed-parse is a Go package for retrieving CNN's US stock market Fear & Greed Index, which is a 0–100 measure of market sentiment. It can return the current score and rating, the previous close, last week, last month, and last year values, roughly one year of daily history, and data for the seven component indicators.
Main capabilities
- Returns the current score and rating.
- Returns the previous close, last week, last month, and last year values.
- Returns roughly one year of daily historical data.
- Returns the seven component indicators: market momentum, stock price strength, stock price breadth, put/call options, market volatility, junk bond demand, safe haven demand. Each indicator has its own score, rating, and raw value history.
- Indicator's History stores the raw underlying series (S&P 500 levels for momentum, VIX levels for volatility, and ratios and spreads for the rest); Score is CNN's 0–100 normalized value.
- Supports replacing cnnfag.HTTPClient to use a custom http.Client (timeout, proxy).
Usage
Command-line tool (CLI)
Suitable for cron jobs and shell pipelines, with no need to write Go code:
-jsonPrints the full result, including daily history.-timeoutChanges the request timeout (default 15 seconds).
MCP server
cnnfag mcp Runs a Model Context Protocol server over stdio, allowing AI assistants to query the index. It exposes one tool get_fear_and_greed, with one optional parameter include_history. When configuring an MCP client, the client must be able to find the binary: if the MCP client does not inherit the shell's PATH, use the full path (usually ~/go/bin/cnnfag). As with the rest of the module, the server is built only on the standard library. The server has been published to the MCP Registry under the identifier io.github.wildsurfer/cnnfag, and provides the container image ghcr.io/wildsurfer/cnnfag for clients that prefer Docker.
Data source
CNN does not provide a documented public API. This package requests the JSON endpoint used by the Fear & Greed page itself. That endpoint rejects requests that do not look like they come from a browser, so the package sends browser-like User-Agent and Referer headers. This is the same data source used by known wrappers in other languages. A scheduled CI job runs the test suite against the real endpoint weekly, so changes on CNN's side can be detected within days.
Migrating from v1
v2 is a complete rewrite: CNN removed the HTML page that v1 parsed, causing v1 to stop working, and its data model no longer matches what CNN publishes. First update the import path, then adjust the calls: scores changed from rounded integers to the exact floating-point numbers provided by CNN, so 44 in v1 corresponds to about 43.71 in v2. If the old style is needed, use %.0f or math.Round Rounding.
Project History
v1 (2021) used goquery to parse the HTML of money.cnn.com/data/fear-and-greed, and could also download the index pointer image. CNN removed that page, which broke the parsing, and the image no longer exists. v2 (2026) is a rewrite based on a JSON endpoint, with a smaller API, includes historical data, and has zero dependencies. The last v1 version is tagged v1.2.0.
Limitations and Disclaimer
- This package is not affiliated with CNN, nor endorsed by CNN.
- The Fear & Greed Index and its values belong to CNN (Warner Bros. Discovery).
- The MIT license covers only the code in this repository and does not grant any rights to CNN's data.
- CNN's terms of use permit personal use of the website content and restrict commercial exploitation. If you use this data in a product, compliance is the user's responsibility, and the endpoint may change or disappear at any time.