Teams building dashboards, risk models, or backtests often struggle to source reliable, machine-readable yields for a specific sovereign benchmark. In this article you will learn how to programmatically fetch, cache, and analyze Egypt’s 10-year government bond yield using the Bonds API, including latest quotes, historical snapshots, time series, spreads, and the full yield curve.
What you get from the Bonds API (and how yields are expressed)
Bonds-API delivers sovereign bond yields as JSON over HTTPS. All endpoints are GET only and require an API key sent in the X-API-Key header. Yields are expressed in percentage points (for example 4.52 represents 4.52%). Where provided, spreads are in basis points (bps), where 1 basis point = 0.01%.
Dates in daily endpoints are formatted as YYYY-MM-DD. Intraday snapshots include an ISO 8601 UTC timestamp: fetched_at such as 2026-10-18T12:00:00Z. Use these fields for time-aware caching and to align series across countries or maturities.
Coverage spans 60+ countries from bills (1M) out to long bonds (30Y–50Y). Egypt is denoted by ISO2 code EG. Explore coverage and production notes at bonds-api.com.
Connectivity check (official sample, verbatim)
The following sample is the official connectivity snippet. It demonstrates a simple GET to retrieve the US 10Y. Copy-paste to verify that your network, firewall, and JSON parser are set up correctly.
curl -s "https://bonds-api.com/api/v1/latest?countries=US&maturities=10Y&api_key=YOUR_API_KEY"
{
"success": true,
"date": "2026-10-16",
"rates": {
"US_10Y": 5.09
},
"dates": {
"US_10Y": "2026-10-16"
},
"currencies": {
"US_10Y": "USD"
},
"meta": {
"request_id": "4a95eda8-845d-49c0-9f03-584bff632690",
"timestamp": "2026-10-18T00:06:37+00:00"
}
}
For production, use the documented authentication header X-API-Key on all requests. The rest of this guide focuses on Egypt (EG) using the Bonds API endpoints and schemas described below.
Latest Egypt yields (focus on 10Y)
Use /api/v1/latest to fetch Egypt’s current yields. You can either request a single tenor (10Y) or retrieve multiple maturities to build a mini-curve on the fly.
Endpoint
GET https://bonds-api.com/api/v1/latest
- Required: countries (ISO2 comma-separated, e.g., EG)
- Optional: maturities (comma-separated; e.g., 10Y or 2Y,10Y)
cURL
Python (requests)
import requests
resp = requests.get(
"https://bonds-api.com/api/v1/latest",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"countries": "EG", "maturities": "2Y,10Y"}
)
data = resp.json()
# Access 10Y yield (percentage) and its date (YYYY-MM-DD)
eg_10y = data["data"]["EG"]["10Y"]["yield"]
eg_10y_date = data["data"]["EG"]["10Y"]["date"]
print("EG 10Y:", eg_10y, "on", eg_10y_date)
JavaScript (fetch)
async function fetchLatestEG() {
const url = new URL("https://bonds-api.com/api/v1/latest");
url.searchParams.set("countries", "EG");
url.searchParams.set("maturities", "2Y,10Y");
const resp = await fetch(url.toString(), {
method: "GET",
headers: {"X-API-Key": "YOUR_API_KEY"}
});
const json = await resp.json();
const eg10 = json.data.EG["10Y"];
console.log("EG 10Y", eg10.yield, "as of", eg10.date);
}
fetchLatestEG();
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=EG&maturities=2Y,10Y";
$json = file_get_contents($url, false, $context);
$data = json_decode($json, true);
$eg10 = $data["data"]["EG"]["10Y"];
echo "EG 10Y {$eg10["yield"]}% on {$eg10["date"]}\n";
Sample JSON response
Field notes: yield is a percentage; date is the valuation date (YYYY-MM-DD). source may be official or market depending on data provenance.
Historical snapshot (Egypt 10Y on a specific date)
Use /api/v1/historical when you need the 10Y yield on a specific Y-m-d date (for example, month-end rolls or event studies).
Endpoint
GET https://bonds-api.com/api/v1/historical
- Required: country (ISO2), maturity (e.g., 10Y), date (YYYY-MM-DD)
cURL
Python (requests)
import requests
params = {"country": "EG", "maturity": "10Y", "date": "2025-06-15"}
resp = requests.get(
"https://bonds-api.com/api/v1/historical",
headers={"X-API-Key": "YOUR_API_KEY"},
params=params
)
hist = resp.json()
print("EG 10Y on", hist["date"], "=", hist["yield"])
JavaScript (fetch)
async function historicalEG10Y(date = "2025-06-15") {
const url = new URL("https://bonds-api.com/api/v1/historical");
url.searchParams.set("country", "EG");
url.searchParams.set("maturity", "10Y");
url.searchParams.set("date", date);
const resp = await fetch(url, { headers: {"X-API-Key": "YOUR_API_KEY"} });
const json = await resp.json();
console.log(`EG 10Y on ${json.date}: ${json.yield}%`);
}
historicalEG10Y();
PHP (Guzzle)
<?php
require 'vendor/autoload.php';
$client = new \GuzzleHttp\Client([
'base_uri' => 'https://bonds-api.com/api/v1/',
'headers' => ['X-API-Key' => 'YOUR_API_KEY']
]);
$response = $client->get('historical', [
'query' => ['country' => 'EG', 'maturity' => '10Y', 'date' => '2025-06-15']
]);
$json = json_decode($response->getBody(), true);
echo "EG 10Y on {$json['date']}: {$json['yield']}%\n";
Sample JSON response
Field notes: yield is a percentage and refers to the requested date. If the requested date is a non-business day with no official fix, a 404 may be returned (see error handling below), so consider requesting the nearest prior business day when appropriate.
Time series (Egypt 10Y across a range)
Use /api/v1/timeseries to pull daily 10Y yields between two dates. This is the building block for regressions, charting, and rolling analytics.
Endpoint
GET https://bonds-api.com/api/v1/timeseries
- Required: country (ISO2), maturity, start (Y-m-d), end (Y-m-d, >= start)
cURL
Python (requests)
import requests
q = {
"country": "EG",
"maturity": "10Y",
"start": "2025-10-18",
"end": "2026-10-18"
}
r = requests.get("https://bonds-api.com/api/v1/timeseries",
headers={"X-API-Key": "YOUR_API_KEY"},
params=q)
ts = r.json()
for point in ts["series"]:
print(point["date"], point["yield"])
JavaScript (fetch)
async function eg10YSeries(start, end) {
const url = new URL("https://bonds-api.com/api/v1/timeseries");
url.searchParams.set("country", "EG");
url.searchParams.set("maturity", "10Y");
url.searchParams.set("start", start);
url.searchParams.set("end", end);
const resp = await fetch(url, { headers: {"X-API-Key": "YOUR_API_KEY"} });
const json = await resp.json();
return json.series; // [{date: 'YYYY-MM-DD', yield: number}, ...]
}
eg10YSeries("2025-10-18", "2026-10-18").then(console.log);
PHP (file_get_contents)
<?php
$ctx = stream_context_create([
"http" => [
"method" => "GET",
"header" => "X-API-Key: YOUR_API_KEY\r\n"
]
]);
$url = "https://bonds-api.com/api/v1/timeseries?country=EG&maturity=10Y&start=2025-10-18&end=2026-10-18";
$json = file_get_contents($url, false, $ctx);
$data = json_decode($json, true);
foreach ($data["series"] as $p) {
echo $p["date"] . " " . $p["yield"] . "\n";
}
Sample JSON response
Field notes: series is a list of daily points with date and yield. Dates are typically business days; public holidays and weekends will have gaps—do not assume daily continuity across the calendar.
Spreads vs a benchmark (Egypt 10Y minus US 10Y)
/api/v1/spread computes country-vs-benchmark yield differentials. For Egypt, a common benchmark is the US 10Y. The response includes the spread in basis points, plus the underlying yields for transparency.
Endpoint
GET https://bonds-api.com/api/v1/spread
- Required: country (ISO2), benchmark (ISO2)
- Optional: maturity (default 10Y)
cURL
Python (requests)
import requests
params = {"country": "EG", "benchmark": "US", "maturity": "10Y"}
res = requests.get("https://bonds-api.com/api/v1/spread",
headers={"X-API-Key": "YOUR_API_KEY"},
params=params).json()
print("Spread (bps):", res["spread_bps"])
print("EG:", res["country_yield"], "US:", res["benchmark_yield"])
JavaScript (fetch)
async function egVsUs10Y() {
const url = new URL("https://bonds-api.com/api/v1/spread");
url.searchParams.set("country", "EG");
url.searchParams.set("benchmark", "US");
url.searchParams.set("maturity", "10Y");
const resp = await fetch(url, { headers: {"X-API-Key": "YOUR_API_KEY"} });
const json = await resp.json();
console.log(`EG-US 10Y spread: ${json.spread_bps} bps`);
}
egVsUs10Y();
PHP (Guzzle)
<?php
$client = new \GuzzleHttp\Client([
'base_uri' => 'https://bonds-api.com/api/v1/',
'headers' => ['X-API-Key' => 'YOUR_API_KEY']
]);
$r = $client->get('spread', ['query' => [
'country' => 'EG', 'benchmark' => 'US', 'maturity' => '10Y'
]]);
$j = json_decode($r->getBody(), true);
echo "Spread: {$j['spread_bps']} bps (EG {$j['country_yield']}% vs US {$j['benchmark_yield']}%)\n";
Sample JSON response
Field notes: spread_bps is in basis points. country_yield and benchmark_yield are percentages for the same maturity.
Full Egypt yield curve
/api/v1/curve returns the cross-maturity term structure (bills to long bonds) for a given country and date. This lets you interpolate spot curves, compute forward rates, and analyze curve shape, including inversion flags.
Endpoint
GET https://bonds-api.com/api/v1/curve
- Required: country (ISO2)
- Optional: date (YYYY-MM-DD; defaults to latest available)
cURL
Python (requests)
import requests
resp = requests.get(
"https://bonds-api.com/api/v1/curve",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"country": "EG"}
)
curve = resp.json()
print("Curve date:", curve["date"], "Inverted:", curve["inverted"])
print("10Y:", curve["curve"]["10Y"])
JavaScript (fetch)
async function egCurve(date) {
const url = new URL("https://bonds-api.com/api/v1/curve");
url.searchParams.set("country", "EG");
if (date) url.searchParams.set("date", date);
const resp = await fetch(url, { headers: {"X-API-Key": "YOUR_API_KEY"} });
const json = await resp.json();
console.log("Curve on", json.date, "inverted:", json.inverted);
return json.curve; // keys like "1M","3M","6M","1Y","2Y","5Y","10Y","30Y"
}
egCurve();
PHP (file_get_contents)
<?php
$ctx = stream_context_create(["http" => [
"method" => "GET",
"header" => "X-API-Key: YOUR_API_KEY\r\n"
]]);
$url = "https://bonds-api.com/api/v1/curve?country=EG";
$body = file_get_contents($url, false, $ctx);
$data = json_decode($body, true);
echo "Date {$data['date']}, inverted? " . ($data['inverted'] ? "yes" : "no") . "\n";
echo "EG 10Y: {$data['curve']['10Y']}%\n";
Sample JSON response
Field notes: inverted is a boolean that flags whether shorter-dated yields exceed longer-dated yields. curve is a mapping of tenor labels to percentage yields on the specified date.
Intraday snapshots (Egypt 10Y)
For high-frequency monitoring, /api/v1/intraday returns multiple yield observations within a single date for a given country and maturity.
Endpoint
GET https://bonds-api.com/api/v1/intraday
- Required: country (ISO2), maturity, date (YYYY-MM-DD)
cURL
Python (requests)
import requests
params = {"country": "EG", "maturity": "10Y", "date": "2026-10-18"}
j = requests.get("https://bonds-api.com/api/v1/intraday",
headers={"X-API-Key": "YOUR_API_KEY"},
params=params).json()
for s in j["snapshots"]:
print(s["fetched_at"], s["yield"], s["source"])
JavaScript (fetch)
async function intradayEG10Y(date = "2026-10-18") {
const url = new URL("https://bonds-api.com/api/v1/intraday");
url.searchParams.set("country", "EG");
url.searchParams.set("maturity", "10Y");
url.searchParams.set("date", date);
const r = await fetch(url, { headers: {"X-API-Key": "YOUR_API_KEY"} });
const j = await r.json();
console.log("count:", j.count, "tz:", j.meta.timezone);
for (const s of j.snapshots) console.log(s.fetched_at, s.yield);
}
intradayEG10Y();
PHP (Guzzle)
<?php
$client = new \GuzzleHttp\Client([
'base_uri' => 'https://bonds-api.com/api/v1/',
'headers' => ['X-API-Key' => 'YOUR_API_KEY']
]);
$res = $client->get('intraday', [
'query' => ['country' => 'EG', 'maturity' => '10Y', 'date' => '2026-10-18']
]);
$j = json_decode($res->getBody(), true);
echo "Snapshots: {$j['count']} (timezone {$j['meta']['timezone']})\n";
Sample JSON response
Field notes: fetched_at is a UTC timestamp. For UI displays, localize timestamps in your client. source may vary (market vs official) depending on timing and availability.
Fluctuation (change, min, max over a period)
/api/v1/fluctuation summarizes start, end, absolute change, and the observed min/max for the specified interval. This is useful for performance summaries and risk reports.
Endpoint
GET https://bonds-api.com/api/v1/fluctuation
- Required: countries (ISO2 comma-separated), maturity, start (Y-m-d), end (Y-m-d)
cURL
Python (requests)
import requests
p = {
"countries": "EG",
"maturity": "10Y",
"start": "2025-10-18",
"end": "2026-10-18"
}
j = requests.get("https://bonds-api.com/api/v1/fluctuation",
headers={"X-API-Key": "YOUR_API_KEY"},
params=p).json()
eg = j["data"]["EG"]
print("Start:", eg["start_yield"], "End:", eg["end_yield"],
"Change:", eg["change"], "Min:", eg["min"], "Max:", eg["max"])
JavaScript (fetch)
async function eg10yFluctuation(start, end) {
const u = new URL("https://bonds-api.com/api/v1/fluctuation");
u.searchParams.set("countries", "EG");
u.searchParams.set("maturity", "10Y");
u.searchParams.set("start", start);
u.searchParams.set("end", end);
const r = await fetch(u, { headers: {"X-API-Key": "YOUR_API_KEY"} });
const j = await r.json();
return j.data.EG; // {start_yield, end_yield, change, min, max}
}
eg10yFluctuation("2025-10-18", "2026-10-18").then(console.log);
PHP (file_get_contents)
<?php
$ctx = stream_context_create(["http" => [
"method" => "GET",
"header" => "X-API-Key: YOUR_API_KEY\r\n"
]]);
$url = "https://bonds-api.com/api/v1/fluctuation?countries=EG&maturity=10Y&start=2025-10-18&end=2026-10-18";
$body = file_get_contents($url, false, $ctx);
$j = json_decode($body, true);
$eg = $j["data"]["EG"];
echo "Δ: {$eg['change']} (Start {$eg['start_yield']} ⇒ End {$eg['end_yield']})\n";
Sample JSON response
Field notes: change is the arithmetic difference (end_yield − start_yield) in percentage points; min and max are the observed extrema within the window.
Business days, holidays, update cadence, and caching
Daily yields reflect business-day availability. Weekends and local market holidays for Egypt will usually not produce new official daily fixes; your integration should accept gaps in calendar days and rely on the date in the payload as the source of truth.
For caching: cache responses keyed by country, maturity, and date. For endpoints returning a single valuation date (latest, historical, curve), cache until you detect a new date. For intraday, the snapshots array is append-only within a given date—poll at an interval appropriate for your UI and backfill snapshots by fetched_at timestamp.
Time zones: daily dates are day-level and not time-zone sensitive; intraday timestamps are UTC (see meta.timezone in intraday). Normalize all timestamps before aggregating with other datasets.
If an endpoint returns 404 for a non-business date or an unavailable combination, either back off to the previous business day or notify the user that no official data exists for the requested parameters.
Building an Egypt 10Y yield curve and analytics
To build an Egypt yield curve on a given date, prefer the /curve endpoint, which returns a consistent cross-maturity snapshot. If you need a mini-curve with only a few points, you can call /latest with maturities=2Y,5Y,10Y,30Y and stitch them into a curve. For time series of the 10Y only, use /timeseries; to compare across countries or benchmarks, use /spread, which directly returns basis point differentials.
Typical analytics include:
- 10Y changes over week/month/quarter using /fluctuation
- Spread monitoring vs US 10Y or another benchmark using /spread
- Curve slope: e.g., 10Y minus 2Y using values from /curve
- Intraday move tracking for alerting via /intraday
For production deployment, document your data lineage (source field), set alert thresholds in bps, and version your cache keys by endpoint to avoid schema collisions.
Error handling and common responses
All error responses share the same shape: success=false and an error message.
- 401: Missing or invalid X-API-Key. Ensure you send the X-API-Key header.
- 403: Account quota exceeded. Back off and review your usage in your Bonds API account.
- 404: No data for requested country/maturity/date. Validate parameters or choose a different date.
- 422: Invalid parameter (bad date format, unknown ISO2). Validate before sending.
- 429: Rate limit exceeded. Implement client-side retry with exponential backoff.
- 500: Server error. Retry with backoff; log request parameters and timestamps.
Always check the success flag before reading fields. For time series workflows, treat missing dates as acceptable and avoid imputing values unless your methodology explicitly allows it.
Use cases for Egypt 10Y in Finance
- Financial dashboards: show latest Egypt 10Y alongside key bills and long bonds via /latest and /curve.
- Portfolio risk: compute DV01 proxies and monitor daily moves using /fluctuation and /timeseries.
- Macro research: study co-movements with US rates via /spread, and track policy-sensitive tenors.
- Treasury management: watch intraday snapshots with /intraday to adjust issuance windows or hedges.
Explore additional capabilities at bonds-api.com and the in-browser tools at MCP.
FAQ
How are yields expressed?
All yields are percentage points (e.g., 4.52 means 4.52%). Spreads are in basis points (bps).
What time zone do timestamps use?
Daily dates are YYYY-MM-DD without time zone implications. Intraday fetched_at values are UTC; meta.timezone is provided for clarity.
How often should I poll for “latest” data?
Poll at a cadence aligned with your UI needs. Cache by date; when the date changes, refresh. For intraday monitoring, choose a sensible interval (e.g., minutes) and deduplicate by fetched_at.
What if I request a holiday or weekend date?
Some endpoints may return 404 if no official data exists for that date. Request the nearest prior business day or use /timeseries and select the last available point.
Can I request multiple maturities at once?
Yes, /latest supports multiple maturities (e.g., maturities=2Y,5Y,10Y). For a complete cross-maturity snapshot on a date, use /curve.
Ready to integrate Egypt’s 10Y and the full curve into your stack? Get an API key and start testing in minutes: Register. You can also explore endpoints interactively in the MCP and learn more at bonds-api.com.