You need the current US 5-year Treasury yield inside your own code, without screen-scraping or manual downloads. By the end of this guide you will call the Bonds-API latest endpoint for the US_5Y tenor, parse the JSON, understand units and timestamps, and ship a small helper that caches results safely for your app or model.
What “US_5Y” is and when to use it
US_5Y is the Bonds-API key for the on-the-run 5-year US Treasury yield—one tenor, not the full curve. It’s the number most fixed-income dashboards plot when they need the intermediate point of the US Treasury curve. Common uses include duration targeting, regression features for macro strategies, spread monitors (e.g., 2s5s, 5s10s), and alerting.
Bonds-API returns this as JSON over REST, with API key authentication via a query parameter. If you also need the entire US curve, you can request the curve endpoint separately; this article stays focused on the single tenor US_5Y and shows where the official curve reference comes from.
To explore the platform and plans, visit bonds-api.com. Full technical docs are at bonds-api.com/docs.
The endpoint you will call
Use GET https://bonds-api.com/api/v1/latest with the following query parameters:
- countries=US
- maturities=5Y
- api_key=YOUR_API_KEY
Example shape: https://bonds-api.com/api/v1/latest?countries=US&maturities=5Y&api_key=YOUR_API_KEY
Important details you will rely on:
- Authentication: pass your API key as the api_key query parameter (no Bearer header).
- Symbol: read the US_5Y field from the JSON payload returned by the latest endpoint.
- Units: yields are expressed in percent (for example, 4.05 means 4.05%). This is not in basis points and it is not a rate like Fed Funds or SOFR.
- Date and time: the payload includes date metadata. Interpret timestamps as standard API timestamps; store and log them consistently in your system clock so you can align with your market day boundaries. When in doubt, prefer the date fields in the payload over client clock time.
Go live in four steps
- Register — Starter is $19/mo (1,000 requests) with a 7-day trial.
- Copy your api_key from your dashboard.
- Call GET /api/v1/latest with countries=US and maturities=5Y.
- Read the US_5Y field from the JSON response.
If you want a quick peak at the platform beyond this guide, you can also browse the MCP.
cURL: request the latest US 5-year yield
Below is a working cURL for the latest US 5-year yield. Replace YOUR_API_KEY with your actual key and run it from your terminal. It requests only the 5Y tenor (US_5Y) for the United States.
Request: latest 5Y
curl "https://bonds-api.com/api/v1/latest?countries=US&maturities=5Y&api_key=YOUR_API_KEY"
Python example: fetch and read US_5Y
This Python snippet sends the same request and shows how to read and validate the US_5Y field. It also includes basic handling for missing fields and a lightweight cache hook you can adapt.
import os
import time
import requests
API_BASE = "https://bonds-api.com/api/v1/latest"
API_KEY = os.environ.get("BONDS_API_KEY", "YOUR_API_KEY")
PARAMS = {
"countries": "US",
"maturities": "5Y",
"api_key": API_KEY
}
# simple in-memory cache for demonstration
_cache = {"ts": 0, "data": None}
CACHE_TTL_SECONDS = 60 # adjust to your tolerance; see caching notes below
def get_us_5y():
now = time.time()
if _cache["data"] and (now - _cache["ts"] < CACHE_TTL_SECONDS):
return _cache["data"]
r = requests.get(API_BASE, params=PARAMS, timeout=10)
r.raise_for_status()
payload = r.json()
# Some responses include a success flag; if present and false, treat as error.
if isinstance(payload, dict) and ("success" in payload) and (payload["success"] is False):
# Optional: parse an error message field if provided by the API
raise RuntimeError("API returned success=false: {}".format(payload))
# The latest endpoint returns tenor keys like US_5Y
if "US_5Y" not in payload:
# Defensively handle missing values
raise KeyError("US_5Y not found in latest response: {}".format(payload.keys()))
us_5y_value = payload["US_5Y"] # expressed in percent, e.g., 4.05 means 4.05%
# Cache and return
_cache["ts"] = now
_cache["data"] = {
"US_5Y": us_5y_value,
# Pass through any date/timestamp fields if present in your payload
"meta": {k: v for k, v in payload.items() if k != "US_5Y"}
}
return _cache["data"]
if __name__ == "__main__":
data = get_us_5y()
print("US_5Y:", data["US_5Y"])
# Optional: print meta fields (e.g., date)
for k, v in data.get("meta", {}).items():
print(k, "=", v)
Understanding the response and field meanings
The latest endpoint returns tenor keys like US_5Y. In addition, you may see date or timestamp fields to identify the valuation day. The yield values are expressed in percent.
For context, Bonds-API also provides an official US Treasury curve response. The published numeric reference below is the US curve for a specific date; we’re showing it so you see the structure that includes the 5Y row. In the latest endpoint you will read US_5Y directly; in the curve response you would read the 5Y entry from the US curve payload.
{
"success": true,
"data": {
"country": "US",
"date": "2026-04-14",
"curve": [
{"maturity": "2Y", "yield": 3.80},
{"maturity": "5Y", "yield": 4.05},
{"maturity": "10Y", "yield": 4.25}
],
"spread_2y_10y": 45.0,
"inverted": false
}
}
How to read this in practice:
- US_5Y: the US 5-year Treasury yield as a percent value (for example, 4.05 means 4.05%).
- Dates/timestamps: use the date fields provided to align your downstream time series. Treat them as authoritative for the market day rather than your local machine time.
- Other fields: when present, status or success flags and messages help with error handling; if a success flag is false, do not trust numeric fields and surface the error to logs.
If the official example you see references the full curve instead of only US_5Y, that’s expected. To get just the US 5-year yield in production, call the latest endpoint with maturities=5Y and read the US_5Y key as shown above.
Operational details that save you time
Business days and market holidays
US Treasury yields update on US trading days. You should expect pauses on US federal market holidays. On non-trading days, the latest value reflects the most recent available print for that market day.
Update frequency and polling
If your application visualizes the US_5Y intraday, choose a reasonable polling cadence and apply a small cache window to avoid redundant fetches. For end-of-day workflows, poll once shortly after your chosen cutover time. If your payload contains a timestamp or date, compare it to your last stored record to detect changes.
Caching and retries
- Client-side caching: cache results for 30–120 seconds for dashboards; longer for batch analytics, depending on requirements.
- Retry policy: implement idempotent retries with exponential backoff for transient network errors. Avoid retrying on validation errors (e.g., missing api_key).
- Response integrity: validate that the US_5Y key is present and is a numeric type before persisting.
Error handling and missing values
- Authentication: if your api_key is missing or invalid, you may receive an error response. Always check HTTP status and, when available, a success flag and message field.
- Missing fields: if US_5Y is not present, treat the response as incomplete and log the payload. Do not compute spreads or ratios on missing data.
Building a yield curve vs. requesting a single tenor
This article centers on US_5Y. If you want an entire US Treasury curve in one call, use the curve endpoint: GET /api/v1/curve with country=US. The official reference shown above is the curve for a specific date. Once you have the curve payload, select the 5Y row to align with US_5Y or use neighboring tenors to compute spreads or bootstrap analytics.
Remember: the latest endpoint returns keys like US_5Y directly in a flat object when you restrict the request to a tenor (maturities=5Y). The curve endpoint aggregates multiple maturities for the United States in one response; use it when you need a full curve snapshot for a trading day.
Production checklist
- Authentication: pass api_key as a query parameter.
- Endpoint: GET /api/v1/latest with countries=US&maturities=5Y to read US_5Y.
- Units: percent, not basis points.
- Dates: store the date/timestamp from the payload for provenance and replays.
- Caching: short TTL for live dashboards; longer TTL for batch or backtests.
- Errors: check HTTP status and any success flag; log and alert on failures.
- Data hygiene: validate US_5Y is present and numeric before use.
For platform overview and examples beyond this tenor, see bonds-api.com or the detailed documentation.
FAQ
Is US_5Y expressed in percent or basis points?
Percent. For example, 4.05 means 4.05%.
Does this cover Fed Funds or SOFR?
No. This is a sovereign bond yield (US Treasuries), not a policy or overnight reference rate.
How do I authenticate?
Include your key as a query parameter: api_key=YOUR_API_KEY. No Bearer token header is required.
What happens on US market holidays?
You should expect no new print on holidays; the latest endpoint returns the most recent available market day’s data.
Can I fetch the full US curve?
Yes, use GET /api/v1/curve?country=US. If you only need the 5Y, call the latest endpoint with maturities=5Y and read US_5Y.
Ready to read the US 5-year Treasury yield in your app? Start your 7-day trial and get an API key: Register. You can browse the platform anytime at bonds-api.com.