You need reliable, machine-readable access to the Kenya 10-year government bond yield for analytics, dashboards, and trading/risk workflows. By the end of this article you will be able to query the Kenya (KE) 10Y yield, retrieve historical and intraday data, compute spreads, and build a full Kenya yield curve using the Bonds API over simple GET requests, with clear guidance on units, dates, caching, and update cadence.
Why track Kenya’s 10-year sovereign yield via API
Sovereign bond yields encode market expectations for growth, inflation, policy rates, and country risk. The 10-year tenor is a widely used benchmark for discount rates, macro models, and asset allocation. Programmatic access matters when you need to: (a) update models on schedule, (b) calculate spreads vs. benchmarks like US Treasuries, and (c) monitor intraday shifts that affect pricing and risk.
With bonds-api.com, you can query current levels, point-in-time history, time series windows, intraday snapshots, curve shapes, and fluctuations using a consistent REST interface. All endpoints use GET, the base URL is https://bonds-api.com/api/v1/, and authentication uses an X-API-Key header. You can explore the API in the MCP and obtain an API key here: Register.
Important: official sample response block
The following official sample cURL and JSON output are provided verbatim for reference:
curl -s "https://bonds-api.com/api/v1/latest?countries=US&maturities=10Y&api_key=YOUR_API_KEY"
{
"success": true,
"date": "2026-11-18",
"rates": {
"US_10Y": 5.129
},
"dates": {
"US_10Y": "2026-11-18"
},
"currencies": {
"US_10Y": "USD"
},
"meta": {
"request_id": "00373073-3c98-438e-a38c-b01b1672383f",
"timestamp": "2026-11-18T00:06:58+00:00"
}
}
Data model, units, dates, and update cadence
Across the Kenya endpoints below, yields are expressed in percent (for example 4.52 means 4.52%). Spreads are expressed in basis points (bps; 1 bp = 0.01%). Dates are ISO 8601 calendar dates (Y-m-d), and timestamps are in UTC when present (for example fetched_at in intraday snapshots). The API focuses on business days; if a given Kenya market holiday occurs, the latest/historical endpoints will reflect the latest available date with data or return a 404 for unavailable combinations. Intraday snapshots are UTC-stamped.
Practical caching: cache by key tuples such as (country, maturity, date) for historical/intraday and by (country, maturity) for latest. For time series or curve responses, include the date range or curve date in the cache key. Respect 429 rate limits and implement exponential backoff. Always check the success flag and handle documented error shapes.
Developer docs and product overview: bonds-api.com.
Current yields: GET /api/v1/latest (Kenya 10Y)
Use this endpoint to fetch the latest available Kenya yields by maturity. You can request a specific set of maturities or omit the parameter to get all available tenors. Yields are in percent; date is the market date for that observation.
cURL
JSON response
How to read this:
- success: boolean request status.
- data.KE.10Y.yield: latest Kenya 10-year yield in percent.
- data.KE.10Y.date: observation date (Y-m-d).
- source: origin of the data (“official” or “market”).
Python (requests)
import requests
resp = requests.get(
"https://bonds-api.com/api/v1/latest",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"countries": "KE", "maturities": "2Y,10Y"}
)
data = resp.json()
ke_10y = data["data"]["KE"]["10Y"]["yield"]
ke_10y_date = data["data"]["KE"]["10Y"]["date"]
print("KE 10Y:", ke_10y, "on", ke_10y_date)
JavaScript (fetch)
const url = new URL("https://bonds-api.com/api/v1/latest");
url.searchParams.set("countries", "KE");
url.searchParams.set("maturities", "2Y,10Y");
fetch(url.toString(), {
method: "GET",
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(j => {
const y = j.data.KE["10Y"].yield; // percent
const d = j.data.KE["10Y"].date; // YYYY-MM-DD
console.log("Kenya 10Y", y, "date", d);
});
PHP (file_get_contents)
<?php
$context = stream_context_create([
'http' => [
'method' => 'GET',
'header' => "X-API-Key: YOUR_API_KEY\r\n"
]
]);
$url = "https://bonds-api.com/api/v1/latest?countries=KE&maturities=2Y,10Y";
$json = file_get_contents($url, false, $context);
$data = json_decode($json, true);
$yield = $data["data"]["KE"]["10Y"]["yield"];
$date = $data["data"]["KE"]["10Y"]["date"];
echo "KE 10Y $yield on $date\n";
Point-in-time historical: GET /api/v1/historical
Fetch the Kenya 10Y yield for a specific calendar date. If the date is a non-business day without an observation, the API may return a 404 for that combination.
cURL
JSON response
Fields:
- yield: percent.
- date: target day in Y-m-d.
- source: where the figure was obtained.
Python
import requests
params = {"country": "KE", "maturity": "10Y", "date": "2025-06-15"}
r = requests.get("https://bonds-api.com/api/v1/historical",
headers={"X-API-Key": "YOUR_API_KEY"}, params=params)
h = r.json()
print(h["country"], h["maturity"], h["date"], h["yield"])
JavaScript
const hUrl = new URL("https://bonds-api.com/api/v1/historical");
hUrl.searchParams.set("country", "KE");
hUrl.searchParams.set("maturity", "10Y");
hUrl.searchParams.set("date", "2025-06-15");
fetch(hUrl.toString(), { headers: { "X-API-Key": "YOUR_API_KEY" }})
.then(r => r.json())
.then(j => {
console.log(`${j.country} ${j.maturity} on ${j.date}: ${j.yield}%`);
});
PHP (Guzzle)
<?php
require 'vendor/autoload.php';
$client = new \GuzzleHttp\Client(['base_uri' => 'https://bonds-api.com/api/v1/']);
$res = $client->get('historical', [
'headers' => ['X-API-Key' => 'YOUR_API_KEY'],
'query' => ['country' => 'KE', 'maturity' => '10Y', 'date' => '2025-06-15']
]);
echo $res->getBody();
Time series window: GET /api/v1/timeseries
Retrieve a daily series for Kenya 10Y between two dates (inclusive). Useful for plotting, moving averages, and backtests. Missing non-business days are simply not included.
cURL
JSON response
Interpretation:
- series: array ordered by date; yields in percent.
- Each element has date (Y-m-d) and yield.
Python
import requests, pandas as pd
params = {
"country": "KE", "maturity": "10Y",
"start": "2025-11-18", "end": "2026-11-18"
}
r = requests.get("https://bonds-api.com/api/v1/timeseries",
headers={"X-API-Key": "YOUR_API_KEY"}, params=params)
ts = r.json()["series"]
df = pd.DataFrame(ts) # columns: date, yield
print(df.head())
JavaScript
const tsUrl = new URL("https://bonds-api.com/api/v1/timeseries");
Object.entries({
country: "KE", maturity: "10Y", start: "2025-11-18", end: "2026-11-18"
}).forEach(([k,v]) => tsUrl.searchParams.set(k, v));
const res = await fetch(tsUrl.toString(), { headers: { "X-API-Key": "YOUR_API_KEY" }});
const body = await res.json();
for (const row of body.series) {
console.log(row.date, row.yield);
}
PHP (file_get_contents)
<?php
$q = http_build_query([
'country' => 'KE', 'maturity' => '10Y',
'start' => '2025-11-18', 'end' => '2026-11-18'
]);
$ctx = stream_context_create(['http' => ['method' => 'GET', 'header' => "X-API-Key: YOUR_API_KEY\r\n"]]);
$json = file_get_contents("https://bonds-api.com/api/v1/timeseries?$q", false, $ctx);
echo $json;
Spread vs. benchmark: GET /api/v1/spread
Compute the Kenya 10Y spread versus a benchmark country (for example the US 10Y), returned in basis points along with each side’s yield.
cURL
JSON response
Fields:
- spread_bps: Kenya minus benchmark in basis points.
- country_yield, benchmark_yield: both in percent.
Python
import requests
p = {"country": "KE", "benchmark": "US", "maturity": "10Y"}
r = requests.get("https://bonds-api.com/api/v1/spread",
headers={"X-API-Key": "YOUR_API_KEY"}, params=p)
s = r.json()
print("Spread (bps):", s["spread_bps"])
JavaScript
const spUrl = new URL("https://bonds-api.com/api/v1/spread");
spUrl.searchParams.set("country", "KE");
spUrl.searchParams.set("benchmark", "US");
spUrl.searchParams.set("maturity", "10Y");
const sres = await fetch(spUrl.toString(), { headers: { "X-API-Key": "YOUR_API_KEY" }});
const sobj = await sres.json();
console.log(`KE 10Y - US 10Y = ${sobj.spread_bps} bps`);
PHP (Guzzle)
<?php
$g = new \GuzzleHttp\Client(['base_uri' => 'https://bonds-api.com/api/v1/']);
$res = $g->get('spread', [
'headers' => ['X-API-Key' => 'YOUR_API_KEY'],
'query' => ['country' => 'KE', 'benchmark' => 'US', 'maturity' => '10Y']
]);
echo $res->getBody();
Yield curve: GET /api/v1/curve
Fetch the Kenya yield curve on the latest available date (or a specified date). Use this to build discount curves, compute interpolated tenors, or visualize curve shape and inversion. The inversion flag helps detect downward-sloping segments.
cURL
JSON response
Notes:
- curve: tenor-to-yield map in percent. Tenors that are not issued may be interpolated or omitted depending on data availability.
- inverted: boolean; true when shorter maturities yield more than longer ones overall.
Python
import requests
r = requests.get("https://bonds-api.com/api/v1/curve",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"country": "KE"})
c = r.json()
tenors = ["1M","3M","6M","1Y","2Y","5Y","10Y","30Y"]
curve_pts = [(t, c["curve"].get(t)) for t in tenors if t in c["curve"]]
print("Curve date:", c["date"], "inverted:", c["inverted"])
print(curve_pts)
JavaScript
const cvUrl = new URL("https://bonds-api.com/api/v1/curve");
cvUrl.searchParams.set("country", "KE");
const cvr = await fetch(cvUrl.toString(), { headers: { "X-API-Key": "YOUR_API_KEY" }});
const cv = await cvr.json();
console.log("Curve date:", cv.date, "KE 10Y:", cv.curve["10Y"]);
PHP (file_get_contents)
<?php
$ctx = stream_context_create(['http' => ['header' => "X-API-Key: YOUR_API_KEY\r\n"]]);
$body = file_get_contents("https://bonds-api.com/api/v1/curve?country=KE", false, $ctx);
echo $body;
Intraday snapshots: GET /api/v1/intraday
Retrieve Kenya 10Y snapshots during a single UTC day. Timestamps are ISO 8601 with a Z suffix (UTC). Use this to track within-day moves or construct OHLC approximations.
cURL
JSON response
Fields:
- snapshots: array of yield observations; yield in percent.
- fetched_at: UTC timestamp for when the snapshot was observed.
- count: number of snapshots returned.
Python
import requests, statistics
p = {"country": "KE", "maturity": "10Y", "date": "2026-11-18"}
r = requests.get("https://bonds-api.com/api/v1/intraday",
headers={"X-API-Key": "YOUR_API_KEY"}, params=p)
j = r.json()
levels = [s["yield"] for s in j["snapshots"]]
print("Intraday min/max:", min(levels), max(levels), "n=", j["count"])
JavaScript
const idUrl = new URL("https://bonds-api.com/api/v1/intraday");
Object.entries({ country: "KE", maturity: "10Y", date: "2026-11-18" })
.forEach(([k,v]) => idUrl.searchParams.set(k, v));
const ir = await fetch(idUrl.toString(), { headers: { "X-API-Key": "YOUR_API_KEY" }});
const ij = await ir.json();
console.log("First snapshot:", ij.snapshots[0]);
PHP (Guzzle)
<?php
$g = new \GuzzleHttp\Client(['base_uri' => 'https://bonds-api.com/api/v1/']);
$res = $g->get('intraday', [
'headers' => ['X-API-Key' => 'YOUR_API_KEY'],
'query' => ['country' => 'KE', 'maturity' => '10Y', 'date' => '2026-11-18']
]);
echo $res->getBody();
Fluctuation over a period: GET /api/v1/fluctuation
Summarize the change, min, and max for Kenya 10Y over a date window. This is efficient for dashboards where you need end-to-end change and extremes without transferring the full series.
cURL
JSON response
Fields:
- start_yield, end_yield: percent at window ends.
- change: end minus start (in percent points).
- min, max: extrema within the window (percent).
Python
import requests
p = {"countries": "KE", "maturity": "10Y", "start": "2025-11-18", "end": "2026-11-18"}
r = requests.get("https://bonds-api.com/api/v1/fluctuation",
headers={"X-API-Key": "YOUR_API_KEY"}, params=p)
f = r.json()
ke = f["data"]["KE"]
print("Δ (pp):", ke["change"], "Range:", ke["min"], "to", ke["max"])
JavaScript
const flUrl = new URL("https://bonds-api.com/api/v1/fluctuation");
Object.entries({ countries: "KE", maturity: "10Y", start: "2025-11-18", end: "2026-11-18"})
.forEach(([k,v]) => flUrl.searchParams.set(k, v));
const fr = await fetch(flUrl.toString(), { headers: { "X-API-Key": "YOUR_API_KEY" }});
const fj = await fr.json();
console.log(fj.data.KE);
PHP (file_get_contents)
<?php
$q = http_build_query([
'countries' => 'KE', 'maturity' => '10Y',
'start' => '2025-11-18', 'end' => '2026-11-18'
]);
$ctx = stream_context_create(['http' => ['header' => "X-API-Key: YOUR_API_KEY\r\n"]]);
echo file_get_contents("https://bonds-api.com/api/v1/fluctuation?$q", false, $ctx);
How to build a Kenya yield curve and spreads from multiple symbols
- Full curve: Prefer GET /api/v1/curve for a single call that returns multiple tenors. If you need more granular tenors, combine the curve output with GET /api/v1/latest using a maturities list to reconcile missing points.
- Stitching: Use the curve date field to ensure consistency; if you mix endpoints, align on a single market date and, if necessary, fall back to historical for that date.
- Spreads: Use GET /api/v1/spread to compute KE vs US at 10Y in basis points. For other tenors, pass the maturity parameter (e.g., 2Y, 5Y) if supported by both countries.
- Caching: Cache the curve keyed by (country=KE, date). For intra-day displays, refresh curve less frequently than intraday 10Y snapshots to reduce load.
Error handling, business days, and caching strategies
Errors follow a common shape with success=false and an error message. Handle:
- 401: Missing or invalid X-API-Key. Ensure you send the header.
- 403: Quota exceeded. Backoff and alert.
- 404: No data for the requested combination (e.g., non-trading day without observation).
- 422: Invalid parameter (date format must be Y-m-d; ISO2 must be KE).
- 429: Rate limit exceeded. Implement retry with jitter.
- 500: Server error. Retry with exponential backoff.
Business days and holidays: Latest data generally aligns with business days in Kenya; when building daily charts, do not assume contiguous dates. For time series, only present returned dates to avoid gaps. For alerting, set thresholds on change over 1D/1W from /fluctuation to avoid polling intraday unnecessarily.
Recommended caching TTLs:
- latest: intraday to daily cadence depending on your UX; 1–15 minutes for dashboards, end-of-day for batch risk.
- historical/time series: immutable for past dates; cache indefinitely.
- curve: refresh once per business day, or intraday if your use case needs it.
- intraday: small TTL (e.g., 1–5 minutes) on the current day; archive snapshots for replay.
Use cases for developers and analysts
- Financial dashboards: show KE 10Y, day change from /fluctuation, and a mini chart from /timeseries; color-code if spread vs US exceeds a threshold using /spread.
- Portfolio risk: compute DV01 approximations using the curve from /curve and stress scenarios; refresh latest KE 10Y to update discount factors intraday.
- Economic research: regress macro variables on the KE 10Y series from /timeseries; track curve inversion flag as a lead indicator.
- Alerts: trigger notifications when /fluctuation change exceeds X bps over the week; use /intraday for near-real-time moves on event days.
Putting it all together: minimal integration plan
1) Obtain an API key and store it securely; all requests use GET and the X-API-Key header. 2) Build a KE 10Y card using /latest. 3) Add a sparkline sourced from /timeseries. 4) Show spread vs US from /spread in bps. 5) Optionally add a curve tab driven by /curve. 6) On event days, fetch /intraday snapshots and compute min/max to annotate charts. Explore interactively in the MCP and get your key at Register. Product home: bonds-api.com.
FAQ
How are yields expressed in the responses?
All yields are in percent (e.g., 4.52 means 4.52%). For spreads, spread_bps is in basis points (1 bp = 0.01%).
What time zone are dates and timestamps?
Date fields are Y-m-d without time. Timestamps such as intraday fetched_at are in UTC (Z). The intraday meta.timezone also states "UTC".
How often should I refresh the Kenya 10Y?
For end-of-day analytics, once daily is sufficient. For dashboards, refresh /latest every few minutes. Use /intraday for within-day changes on active sessions.
How do I handle non-business days and holidays?
Do not assume contiguous dates. When you need a specific day, use /historical and handle 404 for unavailable dates, or align to the latest available business day using /latest.
What errors should my client handle?
Handle 401, 403, 404, 422, 429, and 500, all returning success=false with an error message. Implement retries for 429/500 with backoff and cache immutable historical data.
If you’re ready to add Kenya 10-year bond yields to your analytics or product, get your key and start querying with a few lines of code: Register. Explore endpoints interactively in the MCP and see more at bonds-api.com.