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:
- /v1/treasuryyield - Get the current (or a specific day's) yield curve
- /v1/treasuryyieldhistorical - Get historical yield time series
Treasury yields by maturity:
1 Month · 1.5 Month · 2 Month · 3 Month · 4 Month · 6 Month · 1 Year · 2 Year · 3 Year · 5 Year · 7 Year · 10 Year · 20 Year · 30 Year
From 4,458 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 344ms | 376ms | 387ms | 753ms | 998ms |
Similar APIs
Didn't find what you were looking for? Suggest an improvement
/v1/treasuryyield GET
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
typeoptionalWhich curve to return. Must be one of the following values (defaults to
par):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. dateoptionalBusiness day to retrieve (
YYYY-MM-DD). Defaults to the latest. Dates beyond the free window are premium.formatoptionalResponse format:
json(default) orcsv.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON object with the following fields:
dateThe business day of the curve (
YYYY-MM-DD).typeThe curve type returned:
par,real, orbill.ratesAn object mapping each maturity to its yield percent. A maturity not published on a given day is
null. Forbill, each value is an object withcoupon_equivalentanddiscount_rate. The available maturity keys depend ontype(these are also the values accepted by thematurityparameter on /v1/treasuryyieldhistorical):par:
month_1month_1_5month_2month_3month_4month_6year_1year_2year_3year_5year_7year_10year_20year_30real:
year_5year_7year_10year_20year_30bill:
week_4week_6week_8week_13week_17week_26week_52spread_2y10y10-year minus 2-year yield. Returned for
paronly.spread_3m10y10-year minus 3-month yield. Returned for
paronly.spread_5y30y30-year minus 5-year yield. Returned for
paronly.curve_invertedWhether the 2s10s spread is negative (10-year below 2-year). Returned for
paronly.
Sample Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
https://api.api-ninjas.com/v1/treasuryyield?type=parHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/treasuryyield?type=par" \
-H "X-Api-Key: YOUR_API_KEY"/v1/treasuryyieldhistorical GETPremium 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
typeoptionalpar(default),real, orbill.maturityoptionalA single maturity code (e.g.
year_10,week_13). Omit for full-curve history (premium).Maturity codes ▶start_dateoptionalStart of the range (
YYYY-MM-DD).end_dateoptionalEnd of the range (
YYYY-MM-DD).formatoptionaljson(default) orcsv. Premium bulk responses include anextcursor passed back via thepageparameter.
Response
A JSON object with the following fields:
typeThe curve type:
par,real, orbill.maturityThe maturity code returned. Present for a single maturity; omitted in full-curve mode.
dataAn array of time-series points, oldest first. For a single maturity each item is
{ date, rate_pct }(bills also includediscount_rate). In full-curve mode each item is{ date, rates }, whereratesmaps each maturity to its yield percent.nextA pagination cursor for the next page of bulk results, or
null. Pass it back as thepageparameter.
Sample Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
https://api.api-ninjas.com/v1/treasuryyieldhistorical?type=par&maturity=year_10Headers
X-Api-KeyLog in or sign up to get your API KeySample Response
Frequently Asked Questions
Can I use the Treasury Yield API for commercial purposes?
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.How do I get an API key and start using the Treasury Yield API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
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.What happens if a request to the Treasury Yield API fails?
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.