# Treasury Yields API - US Yield Curve, Daily Rates, History (`martin10291/treasury-yields-api`) Actor

No API key. Official US Treasury yields as clean JSON: daily par yield curve 1M-30Y since 1990, real yields (TIPS), T-bill and long-term rates, 10Y-2Y / 10Y-3M / 30Y-5Y / 2Y-3M spreads with inversion flags, 1-day change in basis points, history by day, week or month, and the inversion periods with s

- **URL**: https://apify.com/martin10291/treasury-yields-api.md
- **Developed by:** [Martin Petrov](https://apify.com/martin10291) (community)
- **Categories:** Developer tools, Automation, Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Treasury Yields API - US Yield Curve, Daily Rates, History

**Problem:** your fintech dashboard, mortgage or loan calculator, bond tool or AI agent needs today's US Treasury yields, the 10Y-2Y spread or the yield curve on a past date. Treasury publishes the numbers as one HTML/CSV page per year with columns that change over time (no 1-month bill before 2001, 4-month since 2022, 1.5-month since 2025), and it is often slow to load.

**This API:** one JSON call, no API key, answers from a maintained copy of the official files.

- **Curves:** nominal par yield curve 1M to 30Y (since 1990), real yield curve / TIPS 5Y-30Y (since 2003), T-bill rates (bank discount and coupon equivalent, since 2002), long-term composite and 20Y CMT (since 2000).
- **Spreads:** 10Y-2Y, 10Y-3M, 30Y-5Y, 2Y-3M in percentage points, plus `inverted10y2y` / `inverted10y3m` flags.
- **Change:** `change1d` = basis-point change of every maturity versus the previous business day.
- **Modes:** `latest`, `date` (a holiday or weekend returns the previous business day and keeps `requestedDate`), `history` (daily, weekly or monthly), `spreads`, and `inversion` = every period when 10Y-2Y or 10Y-3M was below zero, with start, end, length and the deepest point.
- **Source:** U.S. Department of the Treasury daily interest rate data (public domain). Every row carries `source` and `sourceUrl`.

### Example (API)

```bash
curl -X POST "https://api.apify.com/v2/acts/martin10291~treasury-yields-api/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode": "latest"}'
```

Output row (measured 2026-11-13):

```json
{"date": "2026-11-12", "curve": "nominal",
 "yields": {"1M": 4.12, "3M": 4.32, "6M": 4.42, "1Y": 4.65, "2Y": 4.86, "5Y": 4.95, "10Y": 5.1, "20Y": 5.48, "30Y": 5.43},
 "spreads": {"10Y-2Y": 0.24, "10Y-3M": 0.78, "30Y-5Y": 0.48, "2Y-3M": 0.54},
 "inverted10y2y": false, "inverted10y3m": false,
 "change1d": {"2Y": 13, "10Y": 12, "30Y": 8},
 "source": "U.S. Treasury, Daily Treasury Par Yield Curve Rates", "unit": "percent"}
```

Inversion periods 2022-2024 (`{"mode": "inversion", "startDate": "2022-01-01", "endDate": "2024-12-31"}`):

```json
{"spread": "10Y-2Y", "start": "2022-07-06", "end": "2024-08-26", "days": 783, "tradingDays": 537, "minSpread": -1.08, "minSpreadDate": "2023-07-03"}
```

More inputs:

- `{"mode": "date", "date": "2026-11-11"}` -> curve of 2026-11-10 (11-11 was a federal holiday), `requestedDate` kept.
- `{"mode": "history", "startDate": "2020-01-01", "endDate": "2026-11-12", "maturities": ["2Y", "10Y"], "frequency": "monthly"}`
- `{"mode": "latest", "curve": "real"}` -> TIPS real yields.

### Use from agents (MCP)

Add the Apify MCP server (`https://mcp.apify.com?tools=martin10291/treasury-yields-api`) to Claude, Cursor or any MCP client and ask: "What is the 10Y-2Y Treasury spread today and how did it change this month?".

### Schedule it

Set `onlyNew: true` and a `monitorId`, schedule the actor once per business day (after 18:00 New York time): each run returns only the new Treasury business days since the last run.

### Input

| Field | Meaning |
|---|---|
| `mode` | latest (default), date, history, spreads, inversion |
| `curve` | nominal (default), real, bills, longterm |
| `date` | YYYY-MM-DD for mode date |
| `startDate`, `endDate` | range for history / spreads / inversion (default last 30 days, max 40 years) |
| `maturities` | optional filter, e.g. \["3M","2Y","10Y"] |
| `frequency` | daily, weekly (last business day of the week), monthly |
| `limit` | max rows, default 1000 (newest kept) |
| `onlyNew`, `monitorId` | return only new business days per watch |

### Honest limits

- Treasury publishes once per business day (usually 15:30-18:00 New York time); there is no intraday data.
- Values are exactly as published (percent, 2 decimals). Columns that did not exist in a year (e.g. 1M before 2001, 20Y in 1987-1993, 30Y in 2002-2006) are `null`, never invented.
- Spreads and inversions are computed on the nominal curve only.
- A cold history call on Apify may take up to ~20 s per uncached year because the Treasury files load slowly; marketplace calls (RapidAPI, API.market) answer from our cache in milliseconds.

### FAQ

**Is this an official Treasury product?** No. It republishes official U.S. Treasury data, which is public domain; the source page is in every row.
**Do I need a key?** Only your Apify token (or the marketplace key on RapidAPI / API.market).

# Actor input Schema

## `mode` (type: `string`):

latest = the newest yield curve; date = one day (a holiday or weekend returns the previous business day and says so); history = every business day between Start and End date; spreads = spread time series only; inversion = periods when 10Y-2Y or 10Y-3M was negative inside the range. The example input (and an empty Apify run) shows history = the last 30 days; API calls with no mode return latest.

## `curve` (type: `string`):

nominal = daily par yield curve (1M-30Y, since 1990); real = real yield curve / TIPS (5Y-30Y, since 2003); bills = T-bill bank discount and coupon equivalent rates (since 2002); longterm = long-term composite and 20Y CMT (since 2000). Spreads and inversions use the nominal curve.

## `date` (type: `string`):

For mode date: the day you want, YYYY-MM-DD, for example 2024-03-15.

## `startDate` (type: `string`):

For history, spreads and inversion: first day, YYYY-MM-DD. Default 30 days before End date. Max range 40 years.

## `endDate` (type: `string`):

For history, spreads and inversion: last day, YYYY-MM-DD. Default today.

## `maturities` (type: `array`):

Optional filter, for example 2Y, 10Y, 3M, 30Y. Empty = every maturity of the curve.

## `frequency` (type: `string`):

For history and spreads: daily (every business day), weekly (last business day of each week) or monthly (last business day of each month).

## `limit` (type: `integer`):

Maximum rows returned (newest kept when the range is longer). Between 1 and 20000.

## `onlyNew` (type: `boolean`):

Return only business days newer than the last run with this Monitor ID. Schedule it daily to get each new Treasury curve once.

## `monitorId` (type: `string`):

Name of the watch for only-new mode, for example my-dashboard. Each Monitor ID keeps its own last date.

## Actor input object example

```json
{
  "mode": "history",
  "curve": "nominal",
  "frequency": "daily",
  "limit": 1000,
  "onlyNew": false,
  "monitorId": "default"
}
```

# Actor output Schema

## `results` (type: `string`):

One row per business day: date, curve, yields per maturity in percent, spreads in percentage points, inversion flags, 1-day change in basis points, source link. Inversion mode: one row per inversion period.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "history"
};

// Run the Actor and wait for it to finish
const run = await client.actor("martin10291/treasury-yields-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "mode": "history" }

# Run the Actor and wait for it to finish
run = client.actor("martin10291/treasury-yields-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "history"
}' |
apify call martin10291/treasury-yields-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,martin10291/treasury-yields-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/bpu8bmR4YpqPcWDMN/builds/zNCtKz77kUjgeJSfN/openapi.json
