Building a United States Treasury yield curve means collecting comparable yields across maturities, preserving their observation dates, and handling days when no market data is available. This guide shows how to request yields from Bonds API, calculate spreads, and integrate curve, historical, and intraday data into an application.
Understanding Treasury yields and maturities
U.S. Treasury securities are sovereign debt instruments. Their yields express the return implied by their market prices and associated cash flows; analysts use them as reference points for interest rates, valuation, and portfolio risk.
A yield curve plots yields against maturity. Shorter maturities are commonly expressed in months, such as 1M and 6M, while longer maturities use years, such as 2Y, 10Y, and 30Y. The maturity labels represent curve points, not individual Treasury security identifiers.
Yields in the examples are percentages, not decimal fractions: a yield of 4.52 means 4.52%. A basis point is one hundredth of a percentage point. To calculate the spread between two percentage yields, subtract the first yield from the second and multiply by 100.
For example, the reference yields of 4.52% for 10Y and 4.25% for 2Y produce a 10Y-minus-2Y spread of 27 basis points. A negative value for a selected longer-minus-shorter pair indicates that pair is inverted; it does not necessarily describe every part of the curve.
Request the latest 10-year yield
The following live sample uses GET /api/v1/latest with countries=US and maturities=10Y. Replace YOUR_API_KEY with your key before running it. Because the key is in the URL in this sample, take care not to expose the command in shared shell history or request logs.
curl -s "https://bonds-api.com/api/v1/latest?countries=US&maturities=10Y&api_key=YOUR_API_KEY"
The official response has the following structure and example values:
{
"success": true,
"date": "2026-12-02",
"rates": {
"US_10Y": 5.067
},
"dates": {
"US_10Y": "2026-12-02"
},
"currencies": {
"US_10Y": "USD"
},
"sources": {
"US_10Y": "worldgovbonds"
},
"updated_at": {
"US_10Y": "2026-12-02T00:01:34+00:00"
},
"changes": {
"US_10Y": {
"previous_close": 5.069,
"daily": {
"date": "2026-12-01",
"bps": -0.2,
"pct": -0.04
},
"weekly": {
"date": "2026-11-25",
"bps": 21.7,
"pct": 4.47
},
"monthly": {
"date": "2026-11-02",
"bps": 15.7,
"pct": 3.2
},
"annual": {
"date": "2025-12-02",
"bps": 97.7,
"pct": 23.89
}
}
},
"meta": {
"request_id": "84cf4fe5-7c6b-4286-bf6d-d42107b46335",
"timestamp": "2026-12-02T00:04:05+00:00"
}
}
rates.US_10Y is the yield in percent; currencies.US_10Y identifies the underlying currency as USD, not a price denomination for the yield. The top-level date is the response date, while dates.US_10Y is the date associated with that rate. Retain the per-rate date when storing or comparing observations.
updated_at.US_10Y is the rate’s update timestamp. Its +00:00 offset denotes UTC; meta.timestamp is a separate response timestamp, and meta.request_id identifies the request. The sources entry records provenance.
changes.US_10Y contains the previous close and daily, weekly, monthly, and annual comparisons. Each comparison includes its reference date, a change in basis points under bps, and a percentage change under pct. A percentage change is not the same unit as a percentage-point change.
Read the same response in Python
This example calls the same URL and checks both the HTTP status and the API’s success field before reading the rate. Install the Python requests library in your environment and substitute your key in the URL.
import requests
url = (
"https://bonds-api.com/api/v1/latest"
"?countries=US&maturities=10Y&api_key=YOUR_API_KEY"
)
response = requests.get(url, timeout=30)
response.raise_for_status()
payload = response.json()
if not payload.get("success"):
raise RuntimeError(payload.get("error", "Request failed"))
symbol = "US_10Y"
print("Yield (%):", payload["rates"][symbol])
print("Observation date:", payload["dates"][symbol])
print("Updated:", payload["updated_at"][symbol])
print("Daily change (bps):", payload["changes"][symbol]["daily"]["bps"])
In production, keep the key out of source control and redact it from logs. The remaining endpoint examples use the documented X-API-Key request header. Each example is illustrative; yields and dates can differ between responses and should not be treated as a single synchronized dataset.
Retrieve historical observations and time series
Use GET /api/v1/historical for a single country, maturity, and date. Dates use Y-m-d format. A date with no available observation can return a 404, so an application should not assume that every calendar date has a yield.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/historical?country=US&maturity=10Y&date=2025-06-15"
{
"success": true,
"country": "US",
"maturity": "10Y",
"date": "2025-06-15",
"yield": 4.38,
"source": "official"
}
Here, country and maturity identify the requested series, date identifies the observation, and yield is a percentage. Preserve source with the result if your research workflow needs provenance. The response is an example rather than a guarantee that a particular date will have data.
For a range, use GET /api/v1/timeseries with country, maturity, start, and end; the end must not precede the start.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/timeseries?country=US&maturity=10Y&start=2025-12-02&end=2026-12-02"
The reference’s separate series illustration below shows the response fields. Its dates are outside the range in the request above, so it should not be interpreted as that request’s actual result.
{
"success": true,
"country": "US",
"maturity": "10Y",
"series": [
{ "date": "2025-01-02", "yield": 4.21 },
{ "date": "2025-01-03", "yield": 4.19 },
{ "date": "2025-01-06", "yield": 4.23 }
]
}
Each series entry pairs an observation date with a percentage yield. For charting or research, sort by date and distinguish an absent observation from a zero yield. Weekends, market holidays, and availability can produce gaps; only fill or carry forward values if your analytical method explicitly calls for it.
Build a curve and calculate spreads
GET /api/v1/curve returns the available maturity points for one country. Supply country=US; an optional date selects a day, while omitting it requests the latest available day with data.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/curve?country=US"
{
"success": true,
"country": "US",
"date": "2026-12-02",
"inverted": false,
"curve": {
"1M": 5.31, "3M": 5.27, "6M": 5.18,
"1Y": 4.98, "2Y": 4.25, "5Y": 4.39,
"10Y": 4.52, "30Y": 4.71
}
}
The curve object maps maturity labels to percentage yields, and date identifies the curve’s observation day. inverted is an API-provided flag. For a defined analytical measure, calculate the spread for your chosen maturity pair as well: the example has inverted: false, but its 10Y yield is below its 1M yield.
Sort maturities by actual term, not alphabetically, before drawing a curve. Check that each required point is present, and keep the curve date with the plotted values. Do not silently interpolate missing maturities unless your application documents the interpolation method.
The latest endpoint also supports a comma-separated maturities parameter, such as 2Y,10Y; omitting it requests all available maturities. This is useful when a dashboard needs selected points in one request rather than a full curve. Validate the returned dates before calculating cross-maturity spreads, and do not assume that a missing point has a zero yield.
For a benchmark comparison, GET /api/v1/spread accepts country and benchmark, with an optional maturity that defaults to 10Y. The following reference request compares the U.S. 10-year yield with the specified benchmark:
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/spread?country=US&benchmark=DE&maturity=10Y"
{
"success": true,
"country": "US",
"benchmark": "DE",
"maturity": "10Y",
"spread_bps": 215,
"country_yield": 4.52,
"benchmark_yield": 2.37
}
country_yield and benchmark_yield are percentages; spread_bps is their difference in basis points. In this example, subtracting 2.37 from 4.52 and multiplying by 100 gives 215. The response does not include an observation date, so do not infer one from the request or join it to a dated curve without independently establishing alignment.
Use intraday snapshots and period changes
GET /api/v1/intraday requests snapshots for one country, maturity, and date. It is useful for a dashboard that needs to show how a U.S. yield moved during a day, rather than just a daily observation.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/intraday?country=US&maturity=10Y&date=2026-12-02"
{
"success": true,
"country": "US",
"maturity": "10Y",
"date": "2026-12-02",
"snapshots": [
{ "yield": 4.51, "fetched_at": "2026-12-02T09:30:00Z", "source": "market" },
{ "yield": 4.53, "fetched_at": "2026-12-02T12:00:00Z", "source": "market" },
{ "yield": 4.52, "fetched_at": "2026-12-02T15:30:00Z", "source": "market" }
],
"count": 3,
"meta": { "timezone": "UTC" }
}
Each snapshot has a percentage yield, a fetched_at timestamp, and a source. The trailing Z means UTC, consistent with meta.timezone; convert timestamps for display without losing the original UTC value. count describes the number of snapshots in the response, not a promised update frequency.
For a period summary, GET /api/v1/fluctuation takes comma-separated countries, one maturity, and a start and end date. The end must be on or after the start.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/fluctuation?countries=US&maturity=10Y&start=2025-12-02&end=2026-12-02"
{
"success": true,
"maturity": "10Y",
"start": "2025-12-02",
"end": "2026-12-02",
"data": {
"US": {
"start_yield": 4.21,
"end_yield": 4.52,
"change": 0.31,
"min": 3.87,
"max": 4.76
}
}
}
start_yield, end_yield, min, and max are percentage yields. In this example, change is 0.31 percentage points, equivalent to 31 basis points. Use the time-series endpoint instead when a risk calculation needs the individual observations rather than the summary.
Operational considerations
For financial dashboards, cache the latest response briefly enough to meet your freshness requirements and show the observation date and update timestamp alongside the yield. The reference does not specify a fixed refresh cadence, so use returned timestamps to assess age rather than assuming every request contains a new market observation.
Historical results can be cached by endpoint and request parameters, but retain their dates and sources. Set a revalidation policy appropriate to your workflow rather than assuming a historical value can never be revised. Keep intraday snapshots separate from daily observations so that a portfolio-risk calculation does not accidentally mix their time bases.
Handle success=false and the error message as well as HTTP status codes. A 401 indicates a missing or invalid key; 403 indicates account quota exceeded; 404 indicates no data for the requested combination; 422 indicates invalid parameters; 429 indicates rate limiting; and 500 indicates a server error. Correct credentials or parameters before retrying those failures, and use bounded backoff for rate-limit or transient server failures.
The supplied endpoint reference does not describe pagination. For large research jobs, design ingestion around the documented date ranges and check actual responses rather than assuming pagination fields or a particular response size. The MCP link provides another Bonds API integration entry point.
FAQ
How do I calculate the 10Y–2Y Treasury spread?
Get both maturities for the same observation date, subtract the 2Y percentage yield from the 10Y percentage yield, and multiply by 100. A negative result means the 10Y point is below the 2Y point.
Why might a requested date have no yield?
Weekends, market holidays, and data availability can leave gaps. Handle a 404 or missing observation explicitly; do not substitute zero or silently move to another date.
How often are yields updated?
The reference does not specify a fixed cadence. Inspect the returned update timestamp or intraday snapshot timestamps, and display the observation date so users can judge freshness.
Can I use the curve flag as my only inversion measure?
The inverted flag is useful as returned, but a strategy should also calculate its explicitly chosen maturity-pair spread. Different pairs can describe different parts of the curve.
Ready to integrate U.S. Treasury yields into a dashboard, research pipeline, or fixed-income risk tool? Register to get a Bonds API key and start testing the requests.