Use Newhedge with AI agents

Copy-paste prompts and code snippets for Cursor, Claude Code, ChatGPT Code Interpreter, plain Claude.ai, and MCP clients.

The fastest way to teach an LLM what Newhedge offers is to point it at the free machine catalog at https://newhedge.io/api/v2/catalog. One HTTP call, no token, returns every chart, every metric, sample values, units, update frequency, and the full request URL template — enough context for the agent to answer most questions on its own.

Drop-in system prompt

Teach any agent the API in < 30 seconds

System prompt
You can answer questions about Bitcoin on-chain, market, mining, and macro
metrics by calling the Newhedge API.

Discovery (free, no auth):
  GET https://newhedge.io/api/v2/catalog

The catalog returns every available chart and metric, with `slug`, `name`,
`shape`, `units`, `update_frequency`, a `sample`, and a
`request_url_template`. Use it to pick the right metric before issuing any
data call.

Auth: every data call needs `?api_token=YOUR_TOKEN` (24-character
alphanumeric, premium-only). Header auth is not supported.

Endpoints:
  GET https://newhedge.io/api/v2/metrics/{chart_slug}/{metric_name}?api_token=YOUR_TOKEN
  GET https://newhedge.io/api/v2/news/{query_type}?api_token=YOUR_TOKEN
  GET https://newhedge.io/api/v2/price/historical?api_token=YOUR_TOKEN
  GET https://newhedge.io/api/v2/price/live?api_token=YOUR_TOKEN

Quota: 10000 calls/month per token. Cache catalog responses; metric data
updates daily for most series.
Cursor / Claude Code

Project-level rule

Save the prompt above as .cursor/rules/newhedge-api.mdc or a Claude Code memory note. Then ask in chat:

Example chat
Show me the Mayer Multiple over the last 90 days as a chart, and tell me
whether the current value is above or below its long-term average.

The agent should fetch /api/v2/catalog, find the mayer-multiple slug, call /api/v2/metrics/mayer-multiple/{metric_name}, and plot the last 90 entries. If your editor supports OpenAPI tool imports, point it at https://newhedge.io/api/v2/openapi.json for typed parameter hints.

ChatGPT Code Interpreter

Catalog-driven Python snippet

requests and matplotlib are pre-installed, so this runs as-is.

Python
import os
import requests
import matplotlib.pyplot as plt
from datetime import datetime

API_TOKEN = os.environ["NEWHEDGE_API_TOKEN"]

# 1. Discover (no token required).
catalog = requests.get("https://newhedge.io/api/v2/catalog", timeout=15).json()

# 2. Find the chart you want.
mayer = next(
    chart
    for group in catalog["groups"]
    for chart in group["charts"]
    if chart["slug"] == "mayer-multiple"
)
metric = mayer["metrics"][0]
url = metric["request_url_template"].replace("{token}", API_TOKEN)

# 3. Fetch and plot.
series = requests.get(url, timeout=15).json()
xs = [datetime.utcfromtimestamp(p[0] / 1000) for p in series[-180:]]
ys = [p[1] for p in series[-180:]]
plt.plot(xs, ys)
plt.title(f"{mayer['extended_name']} - last 180 days")
plt.show()
Plain Claude.ai (no tools)

Paste the index, then chat

When tool use isn't available, paste the contents of https://docs.newhedge.io/llms.txt (a few KB) at the top of the conversation and tell Claude:

Prompt to paste after llms.txt
The above is the index for the Newhedge API. When I ask you about Bitcoin
on-chain or market metrics, identify the right metric from the catalog,
show me the request URL with `YOUR_TOKEN` placeholder, and explain how to
interpret the response shape. Don't hallucinate data — only describe what
the API returns.

For longer sessions paste llms-full.txt instead (everything inlined, larger). Both files are regenerated whenever a chart or metric changes.

MCP

Model Context Protocol (hosted)

Connect an MCP-aware client to the Newhedge v2 API with JSON-RPC POST and your existing api_token query parameter (same auth model as REST). Use https:// in production.

Endpoint: POST https://newhedge.io/api/v2/mcp?api_token=YOUR_TOKEN. Tools: list_metrics, search_metrics, get_metric, get_latest_value, compare_metrics, get_api_docs. Discovery and docs tools cost no monthly quota; each data fetch counts like one REST metrics call (compare_metrics counts one per spec).

Claude Code / Desktop

Claude Desktop: add the block below to claude_desktop_config.json. Claude Code uses the same server URL; see Claude Code’s MCP docs for the exact config file path on your OS.

claude_desktop_config.json
{
  "mcpServers": {
    "newhedge": {
      "url": "https://newhedge.io/api/v2/mcp?api_token=YOUR_TOKEN"
    }
  }
}

Cursor

.cursor/mcp.json
{
  "mcpServers": {
    "newhedge": {
      "url": "https://newhedge.io/api/v2/mcp?api_token=YOUR_TOKEN"
    }
  }
}

Continue

~/.continue/config.json (excerpt)
{
  "mcpServers": [
    {
      "name": "newhedge",
      "url": "https://newhedge.io/api/v2/mcp?api_token=YOUR_TOKEN"
    }
  ]
}
Troubleshooting

Common errors

401 — Token is required

No api_token query param. Append ?api_token=....

401 — Invalid token

Token is wrong, not 24 chars, or user is not on the Advanced plan. Regenerate at your API settings.

401 — Monthly limit reached

Token has hit the 10000 calls/month cap. Wait until next month or contact sales.

404 — Chart / metric not found

Wrong slug or metric name. Re-fetch the catalog and pick a valid (chart_slug, metric_name) pair from x-newhedge-allowed-pairs in the OpenAPI spec.

404 — Currency not found

Use a code from the currencies array in the catalog.