Building a Spain yield curve requires more than plotting a few rates: your application must align maturities and observation dates, distinguish percentage yields from basis-point spreads, and handle days when no new market data is available. This guide shows how to retrieve and interpret Spanish sovereign yields, construct a curve, and integrate the seven Bonds API endpoints into fixed-income tools.
How to interpret the Spanish sovereign curve
Spanish government bonds are debt securities issued by the sovereign. Their yields summarize the return implied by market prices and provide a starting point for analyzing borrowing costs, portfolio sensitivity, and changes in expectations across maturities.
A yield curve plots yield against maturity. Short maturities reflect a different part of the market from longer-dated bonds, so a movement in one point does not necessarily represent a parallel shift in the entire curve. The API represents Spain with the ISO2 country code ES and maturities with labels such as 1M, 2Y, 10Y, and 30Y.
Yield values are percentages: 4.52 means 4.52%, not a decimal rate of 4.52. One percentage point equals 100 basis points. To express a difference between two percentage yields in basis points, subtract the yields and multiply by 100.
For an illustration, the difference between the supplied Spain 10Y and 2Y observations is (4.52 - 4.25) * 100 basis points. This is a maturity spread within Spain’s curve; it is different from a spread against another country’s yield.
Retrieve the latest Spain yields
The latest endpoint accepts a comma-separated countries parameter. Use the optional maturities parameter to request selected curve points, or omit it to request all available maturities. The Spain reference request uses the X-API-Key header:
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/latest?countries=ES&maturities=2Y,10Y"
A reference response for that request is:
{
"success": true,
"data": {
"ES": {
"2Y": { "yield": 4.25, "date": "2026-12-03", "source": "official" },
"10Y": { "yield": 4.52, "date": "2026-12-03", "source": "official" }
}
}
}
success indicates whether the request succeeded. Within data, the country and maturity keys identify each observation; yield is the percentage yield, date is its observation date, and source identifies the source category. Check the dates before treating multiple points as a single curve snapshot.
The following published live reference illustrates a different latest response shape for a US observation. It uses a query-string key and returns rates rather than the Spain reference’s data mapping. Treat it as a separate reference, not as a Spain response; use the header-authenticated Spain request above for the Spain integration.
curl -s "https://bonds-api.com/api/v1/latest?countries=US&maturities=10Y&api_key=YOUR_API_KEY"
{
"success": true,
"date": "2026-12-03",
"rates": {
"US_10Y": 5.083
},
"dates": {
"US_10Y": "2026-12-03"
},
"currencies": {
"US_10Y": "USD"
},
"sources": {
"US_10Y": "worldgovbonds"
},
"updated_at": {
"US_10Y": "2026-12-03T00:01:13+00:00"
},
"changes": {
"US_10Y": {
"previous_close": 5.065,
"daily": {
"date": "2026-12-02",
"bps": 1.8,
"pct": 0.36
},
"weekly": {
"date": "2026-11-25",
"bps": 23.3,
"pct": 4.8
},
"monthly": {
"date": "2026-11-03",
"bps": 13.3,
"pct": 2.69
},
"annual": {
"date": "2025-12-03",
"bps": 102.3,
"pct": 25.2
}
}
},
"meta": {
"request_id": "3dc47354-05ef-4c7c-8470-6d03c50a9df1",
"timestamp": "2026-12-03T00:04:05+00:00"
}
}
In that live response, rates contains the yield, while dates, currencies, sources, and updated_at describe the keyed observation. The changes object reports comparisons with previous observations, including basis-point and percentage changes. meta.timestamp is a timestamp with an explicit UTC offset; it is not the same thing as the date associated with the yield.
Request the full curve and benchmark spreads
Full Spain curve
Use curve when the application needs the available maturity points for a country. It requires country; 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=ES"
{
"success": true,
"country": "ES",
"date": "2026-12-03",
"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
}
}
curve maps maturity labels to percentage yields, and date identifies the curve’s observation day. inverted is the returned inversion indicator. The reference does not define its calculation, so applications that require a specific inversion test should calculate their chosen maturity spread explicitly rather than assume the flag uses that test.
For charting, order maturities by tenor rather than alphabetically and plot the yields as supplied. A dashboard can use the full curve for display and the multi-maturity latest request for a smaller set of monitored points. Do not silently fill a missing maturity or interpolate it as though it were an observed yield.
Spread against a benchmark
The spread endpoint compares Spain with a benchmark country at a selected maturity. It requires country and benchmark; maturity is optional and defaults to 10Y.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/spread?country=ES&benchmark=US&maturity=10Y"
{
"success": true,
"country": "ES",
"benchmark": "US",
"maturity": "10Y",
"spread_bps": 215,
"country_yield": 4.52,
"benchmark_yield": 2.37
}
country_yield and benchmark_yield are percentage yields. spread_bps expresses the difference in basis points, with the country yield minus the benchmark yield in this example. This cross-country comparison is not interchangeable with the Spain 10Y minus 2Y slope.
Analyze dates, series, and intraday moves
Historical value for a date
Use historical for a specified country, maturity, and date in Y-m-d format. The returned date is a calendar date, not a timestamp.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/historical?country=ES&maturity=10Y&date=2025-06-15"
{
"success": true,
"country": "ES",
"maturity": "10Y",
"date": "2025-06-15",
"yield": 4.38,
"source": "official"
}
The identifying fields establish which observation was returned; yield and source provide its value and source category. A request for a weekend or market holiday may not have an observation. Handle a no-data response explicitly rather than assuming the service will carry forward a previous business day.
Time series for one maturity
Use timeseries with country, maturity, start, and end to retrieve a dated series. The end date must be on or after the start date.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/timeseries?country=ES&maturity=10Y&start=2025-12-03&end=2026-12-03"
{
"success": true,
"country": "ES",
"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 item contains an observation date and a percentage yield. The reference response’s dates precede the start date in the accompanying request, so do not treat these two examples as a validated request-response pair. In an application, check returned dates against the requested interval before calculating changes or joining the series to other data.
Intraday snapshots
Use intraday when a daily observation is not enough. The endpoint requires a country, maturity, and date.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/intraday?country=ES&maturity=10Y&date=2026-12-03"
{
"success": true,
"country": "ES",
"maturity": "10Y",
"date": "2026-12-03",
"snapshots": [
{ "yield": 4.51, "fetched_at": "2026-12-03T09:30:00Z", "source": "market" },
{ "yield": 4.53, "fetched_at": "2026-12-03T12:00:00Z", "source": "market" },
{ "yield": 4.52, "fetched_at": "2026-12-03T15:30:00Z", "source": "market" }
],
"count": 3,
"meta": { "timezone": "UTC" }
}
Each snapshot has a percentage yield, a source, and a fetched_at timestamp. The Z suffix means UTC, consistent with meta.timezone; count is the number of snapshots. The examples show multiple snapshots, but they do not establish a guaranteed update interval.
Change, minimum, and maximum
Use fluctuation for a period summary. It requires comma-separated countries, one maturity, and the start and end dates.
curl -H "X-API-Key: YOUR_API_KEY" \
"https://bonds-api.com/api/v1/fluctuation?countries=ES&maturity=10Y&start=2025-12-03&end=2026-12-03"
{
"success": true,
"maturity": "10Y",
"start": "2025-12-03",
"end": "2026-12-03",
"data": {
"ES": {
"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 the difference in percentage points; multiply it by 100 to express that difference in basis points. Use the series endpoint when the dates of individual moves matter, rather than relying only on a period summary.
Implement the requests in application code
The following Python example uses the same Spain latest endpoint as the first request and reads the maturity values needed for a curve spread. Replace YOUR_API_KEY with a key supplied securely to your application.
import requests
base = "https://bonds-api.com/api/v1/"
headers = {"X-API-Key": "YOUR_API_KEY"}
def get_data(endpoint, params):
response = requests.get(base + endpoint, headers=headers, params=params, timeout=30)
response.raise_for_status()
payload = response.json()
if not payload.get("success"):
raise RuntimeError(payload.get("error", "Request failed"))
return payload
latest = get_data("latest", {"countries": "ES", "maturities": "2Y,10Y"})
points = latest["data"]["ES"]
two_year = points["2Y"]
ten_year = points["10Y"]
if two_year["date"] != ten_year["date"]:
raise ValueError("Curve points have different observation dates")
print("Date:", ten_year["date"])
print("2Y and 10Y yields:", two_year["yield"], ten_year["yield"])
print("10Y minus 2Y, basis points:",
(ten_year["yield"] - two_year["yield"]) * 100)
historical = get_data("historical", {"country": "ES", "maturity": "10Y", "date": "2025-06-15"})
series = get_data("timeseries", {"country": "ES", "maturity": "10Y", "start": "2025-12-03", "end": "2026-12-03"})
spread = get_data("spread", {"country": "ES", "benchmark": "US", "maturity": "10Y"})
curve = get_data("curve", {"country": "ES"})
intraday = get_data("intraday", {"country": "ES", "maturity": "10Y", "date": "2026-12-03"})
fluctuation = get_data("fluctuation", {"countries": "ES", "maturity": "10Y", "start": "2025-12-03", "end": "2026-12-03"})
The same endpoint parameters can be used with JavaScript fetch. This example checks both the HTTP status and the API’s success field before returning data to the caller.
const base = "https://bonds-api.com/api/v1/";
const key = "YOUR_API_KEY";
async function getData(endpoint, params) {
const url = new URL(base + endpoint);
url.search = new URLSearchParams(params).toString();
const response = await fetch(url, { headers: { "X-API-Key": key } });
const data = await response.json();
if (!response.ok || !data.success) {
throw new Error(data.error || `HTTP ${response.status}`);
}
return data;
}
async function run() {
const latest = await getData("latest", { countries: "ES", maturities: "2Y,10Y" });
console.log(latest.data.ES["10Y"].yield, latest.data.ES["10Y"].date);
await getData("historical", { country: "ES", maturity: "10Y", date: "2025-06-15" });
await getData("timeseries", { country: "ES", maturity: "10Y", start: "2025-12-03", end: "2026-12-03" });
await getData("spread", { country: "ES", benchmark: "US", maturity: "10Y" });
await getData("curve", { country: "ES" });
await getData("intraday", { country: "ES", maturity: "10Y", date: "2026-12-03" });
await getData("fluctuation", { countries: "ES", maturity: "10Y", start: "2025-12-03", end: "2026-12-03" });
}
run().catch(console.error);
A PHP client can use the same GET requests. Run this on a trusted server so the key is not exposed to browser users.
<?php
function getData($endpoint, $params) {
$base = 'https://bonds-api.com/api/v1/';
$context = stream_context_create([
'http' => [
'method' => 'GET',
'header' => "X-API-Key: YOUR_API_KEY\r\n"
]
]);
$body = file_get_contents($base . $endpoint . '?' . http_build_query($params), false, $context);
if ($body === false) {
throw new RuntimeException('Request failed');
}
$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
if (empty($data['success'])) {
throw new RuntimeException($data['error'] ?? 'Request failed');
}
return $data;
}
$latest = getData('latest', ['countries' => 'ES', 'maturities' => '2Y,10Y']);
echo $latest['data']['ES']['10Y']['yield'];
getData('historical', ['country' => 'ES', 'maturity' => '10Y', 'date' => '2025-06-15']);
getData('timeseries', ['country' => 'ES', 'maturity' => '10Y', 'start' => '2025-12-03', 'end' => '2026-12-03']);
getData('spread', ['country' => 'ES', 'benchmark' => 'US', 'maturity' => '10Y']);
getData('curve', ['country' => 'ES']);
getData('intraday', ['country' => 'ES', 'maturity' => '10Y', 'date' => '2026-12-03']);
getData('fluctuation', ['countries' => 'ES', 'maturity' => '10Y', 'start' => '2025-12-03', 'end' => '2026-12-03']);
Operate the integration reliably
Cache results according to their use. A historical response can be keyed by country, maturity, and requested date; a current curve should have a shorter application-defined freshness window and retain its returned observation date. Intraday consumers should preserve each fetched_at value rather than presenting a cached snapshot as a new market observation.
No fixed update frequency is specified in the reference. Choose a refresh schedule appropriate to the tool, inspect returned dates and timestamps, and show users when the underlying observation was recorded. On weekends and market holidays, the latest available curve can be older than the current calendar date.
For portfolio risk tools, retain the maturity and date alongside every yield used in a calculation. For economic research, distinguish missing observations from zero yields and document any carry-forward or interpolation performed locally. For dashboards, show the curve date and identify whether a number is a yield, a percentage-point change, or a basis-point spread.
The documented error response has success set to false and an error message. Handle 401 for an invalid or missing key, 403 for account quota exhaustion, 404 for unavailable data, 422 for invalid parameters, 429 for rate limiting, and 500 for a server error. Retry transient failures carefully; correct the request or credentials rather than repeatedly retrying a validation or authentication failure.
The reference does not specify pagination for these endpoints. Do not assume that a response contains a particular page structure; validate the fields actually returned before persisting or analyzing the data. For an additional integration interface, see MCP.
FAQ
How do I build a Spain curve from several maturities?
Request selected maturities together with latest, or use curve for the available full curve. Verify the observation dates, order the points by maturity, and keep missing points distinct from measured yields.
Why can the latest curve have an earlier date?
The curve defaults to the latest available day with data. Weekends, market holidays, and the timing of updates can leave the newest observation on an earlier calendar date.
Is a yield change the same as a basis-point change?
Not directly. A difference between percentage yields is in percentage points; multiply it by 100 for basis points. The spread_bps field is already expressed in basis points.
How should I handle missing historical observations?
Handle a documented no-data response as missing data. If your research method carries forward a previous value, apply and label that rule in your own application rather than presenting the carried value as an observation for the requested date.
To start testing the Spain endpoints with your own application, Register for an API key.