NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server →

Treasury Yield API

The Treasury Yield API provides the current and historical U.S. Treasury yield curve: nominal Constant Maturity Treasury (CMT) par yields for 14 maturities (1 month to 30 years), the real (inflation-indexed / TIPS) yield curve, and Treasury bill rates. The par response also includes precomputed spreads (2s10s, 3m10s, 5s30s) and a yield-curve inversion flag.

Data is sourced from the U.S. Department of the Treasury and updated every business day.

Available endpoints:

Treasury yields by maturity:

1 Month1.5 Month2 Month3 Month4 Month6 Month1 Year2 Year3 Year5 Year7 Year10 Year20 Year30 Year

Online
(4.1)

From 4,458 users

2,900+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
344ms376ms387ms753ms998ms

Didn't find what you were looking for? Suggest an improvement

2 endpoints

https://api.api-ninjas.com/v1/treasuryyield

Returns the latest yield curve for the requested type. The current curve is free; a specific historical date and the combined type=all response require a premium subscription.


Parameters

  • type  optional

    Which curve to return. Must be one of the following values (defaults to par):

    ValueDescription
    parNominal Constant Maturity Treasury (CMT) yield curve. Default.
    realReal (inflation-indexed / TIPS) yield curve.
    billTreasury bill rates.
    allAll three curves combined in one response. Premium only.
  • date  optional

    Business day to retrieve (YYYY-MM-DD). Defaults to the latest. Dates beyond the free window are premium.

  • format  optional

    Response format: json (default) or csv.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

The /v1/treasuryyield endpoint returns a JSON object with the following fields:

  • date

    The business day of the curve (YYYY-MM-DD).

  • type

    The curve type returned: par, real, or bill.

  • rates

    An object mapping each maturity to its yield percent. A maturity not published on a given day is null. For bill, each value is an object with coupon_equivalent and discount_rate. The available maturity keys depend on type (these are also the values accepted by the maturity parameter on /v1/treasuryyieldhistorical):

    par: month_1month_1_5month_2month_3month_4month_6year_1year_2year_3year_5year_7year_10year_20year_30

    real: year_5year_7year_10year_20year_30

    bill: week_4week_6week_8week_13week_17week_26week_52

  • spread_2y10y

    10-year minus 2-year yield. Returned for par only.

  • spread_3m10y

    10-year minus 3-month yield. Returned for par only.

  • spread_5y30y

    30-year minus 5-year yield. Returned for par only.

  • curve_inverted

    Whether the 2s10s spread is negative (10-year below 2-year). Returned for par only.

Live Demo

Live demo · no API key required
Query parameters
type
date

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/treasuryyield?type=par
Sample response
{
"date": "2026-08-10",
"type": "par",
"rates": {
"month_1": 3.79,
"month_1_5": 3.8,
"month_2": 3.84,
"month_3": 3.89,
"month_4": 3.91,
"month_6": 4,
"year_1": 4.04,
"year_2": 4.25,
"year_3": 4.31,
"year_5": 4.41,
"year_7": 4.56,
"year_10": 4.72,
"year_20": 5.25,
"year_30": 5.25
},
"spread_2y10y": 0.47,
"spread_3m10y": 0.83,
"spread_5y30y": 0.84,
"curve_inverted": false
}

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/treasuryyield?type=par" \ -H "X-Api-Key: YOUR_API_KEY"

Premium only

https://api.api-ninjas.com/v1/treasuryyieldhistorical

Returns a historical time series for a single maturity. Omit maturity to get the full curve per date. This endpoint requires a premium subscription.

Parameters

  • type  optional

    par (default), real, or bill.

  • maturity  optional

    A single maturity code (e.g. year_10, week_13). Omit for full-curve history (premium).

    Maturity codes

    CodeMaturity
    month_11 Month
    month_1_51.5 Month
    month_22 Month
    month_33 Month
    month_44 Month
    month_66 Month
    year_11 Year
    year_22 Year
    year_33 Year
    year_55 Year
    year_77 Year
    year_1010 Year
    year_2020 Year
    year_3030 Year
  • start_date  optional

    Start of the range (YYYY-MM-DD).

  • end_date  optional

    End of the range (YYYY-MM-DD).

  • format  optional

    json (default) or csv. Premium bulk responses include a next cursor passed back via the page parameter.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

The /v1/treasuryyieldhistorical endpoint returns a JSON object with the following fields:

  • type

    The curve type: par, real, or bill.

  • maturity

    The maturity code returned. Present for a single maturity; omitted in full-curve mode.

  • data

    An array of time-series points, oldest first. For a single maturity each item is { date, rate_pct } (bills also include discount_rate). In full-curve mode each item is { date, rates }, where rates maps each maturity to its yield percent.

  • next

    A pagination cursor for the next page of bulk results, or null. Pass it back as the page parameter.

Live Demo

Live demo
Query parameters
type
maturity
start_date
end_date

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/treasuryyieldhistorical?type=par&maturity=year_10
Sample response
{
"type": "par",
"maturity": "year_10",
"data": [
{
"date": "2026-08-05",
"rate_pct": 4.7
},
{
"date": "2026-08-06",
"rate_pct": 4.69
},
{
"date": "2026-08-07",
"rate_pct": 4.65
},
{
"date": "2026-08-10",
"rate_pct": 4.72
}
]
}

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/treasuryyieldhistorical?type=par&maturity=year_10" \ -H "X-Api-Key: YOUR_API_KEY"

Frequently Asked Questions

  • Yes, but you must have a premium subscription. Commercial use of the Treasury Yield API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.
  • The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.