You need reliable, programmatic access to Malaysia government bond yields for dashboards, models, and backtests. By the end of this guide, you’ll be able to fetch the latest MY curve, retrieve specific dates, stream intraday snapshots, compute Malaysia–US spreads, and assemble a yield curve for analytics using the Bonds-API REST endpoints.
What you get from Bonds-API for Malaysia
Bonds-API exposes sovereign yields as clean, typed JSON over GET endpoints with an API key in the X-API-Key header. For Malaysia (ISO2: MY), you can request T-bill and MGS maturities from 1M out to 30Y (and more where available), read daily or intraday timestamps, and compute spreads versus benchmarks like the US 10Y Treasury. Yields are returned as percentages (e.g., 4.52 = 4.52%). Spreads are returned in basis points (bps; 1 bps = 0.01%).
All examples below use the base URL https://bonds-api.com/api/v1/ and require the HTTP header X-API-Key: YOUR_API_KEY. All requests are GET.
Helpful resources: the product homepage at bonds-api.com, the MCP for tooling, and registration at Register.
Conventions, units, timestamps, and practical considerations
- Yields are reported in percent (e.g., "yield": 4.52 means 4.52%).
- Dates are ISO 8601 calendar dates in YYYY-MM-DD, unless otherwise specified.
- Intraday timestamps are returned in UTC as full ISO-8601 datetimes (e.g., 2026-11-01T12:00:00Z).
- Business days: Daily endpoints return the last available business day with data for Malaysia. Weekends and MY market holidays may be absent; use the time series endpoints to confirm continuity.
- Update cadence: Daily yields are typically refreshed once per business day; intraday snapshots provide multiple timestamps throughout the session where supported.
- Caching: Cache curve and latest endpoints within the trading day to reduce rate usage; invalidate after market close or when you detect a new date stamp. For intraday, respect the snapshot cadence and avoid polling more frequently than you need.
Endpoint: Latest Malaysia yields
Fetch the most recent yields for selected maturities or all available maturities.
cURL
curl -s "https://bonds-api.com/api/v1/latest?countries=US&maturities=10Y&api_key=YOUR_API_KEY"
JSON response
{
"success": true,
"date": "2026-10-30",
"rates": {
"US_10Y": 4.94
},
"dates": {
"US_10Y": "2026-10-30"
},
"currencies": {
"US_10Y": "USD"
},
"meta": {
"request_id": "8e7fe074-3961-4125-8755-9e2d5a551dc7",
"timestamp": "2026-11-01T00:04:04+00:00"
}
}
How to read this:
- success: true indicates a valid response.
- data.MY.2Y.yield is the 2-year yield in percent.
- data.MY.10Y.date is the last business date with data for these maturities.
- source indicates the provenance of the reading (e.g., "official").
Python (requests)
import requests
resp = requests.get(
"https://bonds-api.com/api/v1/latest",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"countries": "MY", "maturities": "2Y,10Y"}
)
resp.raise_for_status()
data = resp.json()
my_2y = data["data"]["MY"]["2Y"]["yield"]
my_10y = data["data"]["MY"]["10Y"]["yield"]
as_of = data["data"]["MY"]["10Y"]["date"]
print("MY 2Y:", my_2y, "MY 10Y:", my_10y, "as of", as_of)
JavaScript (fetch)
const url = new URL("https://bonds-api.com/api/v1/latest");
url.search = new URLSearchParams({ countries: "MY", maturities: "2Y,10Y" }).toString();
fetch(url, { headers: { "X-API-Key": "YOUR_API_KEY" } })
.then(r => r.json())
.then(j => {
const twoY = j.data.MY["2Y"].yield;
const tenY = j.data.MY["10Y"].yield;
const d = j.data.MY["10Y"].date;
console.log(`Malaysia as of ${d} | 2Y=${twoY}% 10Y=${tenY}%`);
});
PHP (file_get_contents)
<?php
$context = stream_context_create([
"http" => [
"method" => "GET",
"header" => "X-API-Key: YOUR_API_KEY\r\n"
]
]);
$q = http_build_query(["countries" => "MY", "maturities" => "2Y,10Y"]);
$json = file_get_contents("https://bonds-api.com/api/v1/latest?$q", false, $context);
$data = json_decode($json, true);
$y2 = $data["data"]["MY"]["2Y"]["yield"];
$y10 = $data["data"]["MY"]["10Y"]["yield"];
echo "MY 2Y=$y2, 10Y=$y10\n";
Endpoint: Historical Malaysia yield (single date)
Get the Malaysia yield for a specific maturity on a specific date (useful for spot checks, valuation dates, or backfills).
cURL
JSON response
Fields:
- yield: percentage on the specified calendar date.
- date: YYYY-MM-DD local market date; non-business dates may return the last available date if applicable, or a 404 if no data exists.
Python (requests)
import requests
params = {"country": "MY", "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
)
r.raise_for_status()
j = r.json()
print(j["country"], j["maturity"], j["date"], j["yield"])
JavaScript (fetch)
const params = new URLSearchParams({ country: "MY", maturity: "10Y", date: "2025-06-15" });
fetch("https://bonds-api.com/api/v1/historical?" + params, {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(j => console.log(`MY ${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/",
"headers" => ["X-API-Key" => "YOUR_API_KEY"]
]);
$res = $client->get("historical", ["query" => [
"country" => "MY",
"maturity" => "10Y",
"date" => "2025-06-15"
]]);
$j = json_decode($res->getBody(), true);
echo "MY {$j['maturity']} on {$j['date']}: {$j['yield']}%\n";
Endpoint: Malaysia time series (date range)
Download a continuous series to chart or compute rolling metrics. Start and end are inclusive and use YYYY-MM-DD.
cURL
JSON response
Each series element contains the daily date (YYYY-MM-DD) and the yield in percent. Non-trading days will be absent; do not assume weekends or holidays appear in the series.
Python (requests)
import requests
q = {"country": "MY", "maturity": "10Y", "start": "2025-11-01", "end": "2026-11-01"}
r = requests.get(
"https://bonds-api.com/api/v1/timeseries",
headers={"X-API-Key": "YOUR_API_KEY"},
params=q
)
r.raise_for_status()
series = r.json()["series"]
# Example: simple average
avg = sum(pt["yield"] for pt in series) / len(series) if series else None
print("Observations:", len(series), "Average:", avg)
JavaScript (fetch)
const qs = new URLSearchParams({
country: "MY", maturity: "10Y", start: "2025-11-01", end: "2026-11-01"
});
fetch("https://bonds-api.com/api/v1/timeseries?" + qs, {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(j => {
const n = j.series.length;
const avg = j.series.reduce((s, p) => s + p.yield, 0) / n;
console.log(`MY 10Y count=${n}, avg=${avg.toFixed(2)}%`);
});
PHP (file_get_contents)
<?php
$params = http_build_query([
"country" => "MY",
"maturity" => "10Y",
"start" => "2025-11-01",
"end" => "2026-11-01"
]);
$context = stream_context_create([
"http" => ["method" => "GET", "header" => "X-API-Key: YOUR_API_KEY\r\n"]
]);
$raw = file_get_contents("https://bonds-api.com/api/v1/timeseries?$params", false, $context);
$j = json_decode($raw, true);
echo "Points: " . count($j["series"]) . PHP_EOL;
Endpoint: Malaysia spread vs benchmark
Compute the spread between Malaysia and a benchmark country at the same maturity. Spreads are returned in basis points (bps).
cURL
JSON response
Interpretation:
- spread_bps: Malaysia minus benchmark in basis points. 215 bps equals +2.15%.
- country_yield and benchmark_yield: both in percent.
Python (requests)
import requests
params = {"country": "MY", "benchmark": "US", "maturity": "10Y"}
r = requests.get(
"https://bonds-api.com/api/v1/spread",
headers={"X-API-Key": "YOUR_API_KEY"},
params=params
)
j = r.json()
print(f"MY-{j['benchmark']} {j['maturity']} spread: {j['spread_bps']} bps")
JavaScript (fetch)
const p = new URLSearchParams({ country: "MY", benchmark: "US", maturity: "10Y" });
fetch("https://bonds-api.com/api/v1/spread?" + p, {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(j => {
console.log(`Spread MY vs ${j.benchmark} (${j.maturity}): ${j.spread_bps} bps`);
});
PHP (Guzzle)
<?php
require "vendor/autoload.php";
$g = new \GuzzleHttp\Client([
"base_uri" => "https://bonds-api.com/api/v1/",
"headers" => ["X-API-Key" => "YOUR_API_KEY"]
]);
$res = $g->get("spread", ["query" => ["country" => "MY", "benchmark" => "US", "maturity" => "10Y"]]);
$j = json_decode($res->getBody(), true);
echo "Spread: {$j['spread_bps']} bps (MY {$j['country_yield']}% vs US {$j['benchmark_yield']}%)\n";
Endpoint: Full Malaysia yield curve
Retrieve the entire curve (bills to long bonds) for Malaysia on the latest available date, or a specified date.
cURL
JSON response
Notes:
- curve: key-value map from maturity string to yield in percent.
- inverted: true if the curve is downward-sloping from short to long (a quick diagnostic).
- date: the curve’s valuation date.
Python (requests)
import requests
r = requests.get(
"https://bonds-api.com/api/v1/curve",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"country": "MY"}
)
curve = r.json()
pts = curve["curve"]
ten_thirty_slope = pts["30Y"] - pts["10Y"]
print("10s30s slope (MY):", ten_thirty_slope, "percentage points")
JavaScript (fetch)
fetch("https://bonds-api.com/api/v1/curve?country=MY", {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(j => {
const c = j.curve;
const slope2s10s = (c["10Y"] - c["2Y"]).toFixed(2);
console.log(`MY 2s10s: ${slope2s10s} pp, inverted=${j.inverted}`);
});
PHP (file_get_contents)
<?php
$ctx = stream_context_create(["http" => ["header" => "X-API-Key: YOUR_API_KEY\r\n"]]);
$json = file_get_contents("https://bonds-api.com/api/v1/curve?country=MY", false, $ctx);
$j = json_decode($json, true);
echo "Curve date: {$j['date']}, 10Y={$j['curve']['10Y']}%\n";
Endpoint: Intraday Malaysia snapshots
For trading applications and dashboards, you can retrieve multiple intraday reads for a given date and maturity. Timestamps are in UTC.
cURL
JSON response
Each snapshot has yield (percent) and fetched_at (UTC). The count summarizes how many snapshots were returned for the date.
Python (requests)
import requests
from datetime import datetime
r = requests.get(
"https://bonds-api.com/api/v1/intraday",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"country": "MY", "maturity": "10Y", "date": "2026-11-01"}
)
j = r.json()
snaps = [(s["fetched_at"], s["yield"]) for s in j["snapshots"]]
for t, y in snaps:
print(datetime.fromisoformat(t.replace("Z", "+00:00")), y)
JavaScript (fetch)
const paramsIntra = new URLSearchParams({ country: "MY", maturity: "10Y", date: "2026-11-01" });
fetch("https://bonds-api.com/api/v1/intraday?" + paramsIntra, {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(j => {
j.snapshots.forEach(s => console.log(`${s.fetched_at}Z ${s.yield}%`));
});
PHP (Guzzle)
<?php
require "vendor/autoload.php";
$c = new \GuzzleHttp\Client([
"base_uri" => "https://bonds-api.com/api/v1/",
"headers" => ["X-API-Key" => "YOUR_API_KEY"]
]);
$r = $c->get("intraday", ["query" => ["country" => "MY", "maturity" => "10Y", "date" => "2026-11-01"]]);
$j = json_decode($r->getBody(), true);
echo "Snapshots: {$j['count']}\n";
Endpoint: Malaysia yield fluctuation over a period
Summarize the change from start to end, plus min/max over a date window, for Malaysia (and optionally multiple countries).
cURL
JSON response
All yield values are in percent. change is end_yield minus start_yield (percentage points). Use this to power risk summaries and quarterly notes.
Python (requests)
import requests
p = { "countries": "MY", "maturity": "10Y", "start": "2025-11-01", "end": "2026-11-01" }
r = requests.get("https://bonds-api.com/api/v1/fluctuation",
headers={"X-API-Key": "YOUR_API_KEY"},
params=p)
j = r.json()
row = j["data"]["MY"]
print("Δ:", row["change"], "pp; min:", row["min"], "max:", row["max"])
JavaScript (fetch)
const qp = new URLSearchParams({
countries: "MY", maturity: "10Y", start: "2025-11-01", end: "2026-11-01"
});
fetch("https://bonds-api.com/api/v1/fluctuation?" + qp, {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(j => {
const row = j.data.MY;
console.log(`Change=${row.change} pp; range=[${row.min}, ${row.max}]`);
});
PHP (file_get_contents)
<?php
$params = http_build_query([
"countries" => "MY", "maturity" => "10Y",
"start" => "2025-11-01", "end" => "2026-11-01"
]);
$ctx = stream_context_create(["http" => ["header" => "X-API-Key: YOUR_API_KEY\r\n"]]);
$res = file_get_contents("https://bonds-api.com/api/v1/fluctuation?$params", false, $ctx);
$j = json_decode($res, true);
$my = $j["data"]["MY"];
echo "Start={$my['start_yield']} End={$my['end_yield']} Change={$my['change']}\n";
Malaysia fundamentals and how to build a curve for analytics
Malaysia sovereign securities include short-dated treasury bills and longer-dated MGS/ GII bonds. The yield curve captures the term structure of interest rates, a critical input for discount curves, macro analysis, and asset allocation. With the curve endpoint, you can:
- Compute slopes (e.g., 2s10s, 5s30s) to track steepening/flattening.
- Identify curve inversion (inverted: true) to flag late-cycle signals.
- Fit smooth curves (e.g., cubic splines) for pricing off-the-run points using the curve map.
When the endpoint supports multiple symbols (e.g., latest with maturities= list), you can stitch the points into a curve. Sort by tenor order (1M, 3M, 6M, 1Y, 2Y, 5Y, 10Y, 30Y), check for missing tenors, and interpolate as needed. Cache results for the business day; refresh after close or if your application observes a date change from the API.
Error handling and reliability
- 401 (Missing or invalid X-API-Key): ensure the X-API-Key header is present and correct.
- 403 (Quota exceeded): back off and retry after quota resets.
- 404 (No data): the requested country/maturity/date combination may be unavailable; validate inputs and consider fallback logic.
- 422 (Invalid parameter): check date formats (YYYY-MM-DD) and ISO2 codes (MY).
- 429 (Rate limit): implement exponential backoff and caching.
- 500 (Server error): retry with jitter; log request parameters and server message.
Official sample block (verbatim)
The following official sample demonstrates a live-style response shape for a US 10Y request. It is provided verbatim for reference:
If you are building US–Malaysia comparative dashboards, combine the Malaysia endpoints above with the US equivalents. Use spread to compute MY–US differentials directly.
Use cases: how teams use Malaysia yields in production
- Financial dashboards: Display MY 2Y/5Y/10Y tiles with daily deltas and a small intraday sparkline from the intraday snapshots.
- Portfolio risk tools: Download 10Y and 30Y time series to drive DV01 and key rate duration scenarios; use fluctuation to summarize performance bands.
- Economic research: Run regressions on term premia using timeseries outputs; flag inversions via the curve endpoint’s inverted field.
- Trading analytics: Monitor MY–US 10Y spreads with the spread endpoint; trigger alerts when spreads cross thresholds in bps.
Reference matrix: Malaysia maturities returned in curve
| Maturity | Typical Use | Unit |
|---|---|---|
| 1M, 3M, 6M | Cash curve, short-term funding | Percent yield |
| 1Y, 2Y | Front-end rates, policy expectations | Percent yield |
| 5Y, 10Y | Benchmark tenors for macro and valuation | Percent yield |
| 30Y | Long-duration hedging and ALM | Percent yield |
Operational guidance: holidays, updates, and caching
- Holidays: Malaysia market holidays result in missing dates; time series will skip those days. Avoid forward-filling unless analytics require it.
- Daily updates: Latest and curve endpoints reflect the most recent available business day. For overnight runs, fetch after the market’s official close time to stabilize the date stamp.
- Intraday: Snapshots are in UTC. Normalize to your app timezone for UI display; keep the underlying timestamps in UTC for storage.
- Caching: Cache curve and latest per country-date. E.g., key: MY:curve:2026-11-01. Invalidate if the API starts returning a new "date".
- Resilience: Implement retries with jitter on 429/500, and instrument logs with correlation IDs if provided by the API’s meta payloads.
Putting it together: building a Malaysia yield curve and spread dashboard
Here is a minimal sequence:
- Fetch the full curve via /curve?country=MY and display tenors from 1M to 30Y.
- Show 2s10s and 10s30s slopes in percentage points. Highlight if inverted is true.
- Call /spread?country=MY&benchmark=US&maturity=10Y to display the Malaysia–US 10Y spread in bps.
- Use /intraday for 10Y snapshots to draw a sparkline. Interleave with /latest for end-of-day labels.
- Run /fluctuation over the last 1Y to show change, min, and max in a side widget.
All responses are ready-to-plot. The yields are in percent, the spread is in basis points, and timestamps are either YYYY-MM-DD or ISO-8601 UTC for intraday.
FAQs
Q: Are yields returned as decimals or percentages?
A: Percentages. For example, 4.52 means 4.52%.
Q: How do I handle non-trading days and holidays for Malaysia?
A: Daily endpoints return the last available business day, and time series omit non-trading days. Do not expect weekends or holidays in the series.
Q: What timezone are intraday timestamps in?
A: UTC, as ISO-8601 datetimes (e.g., 2026-11-01T12:00:00Z). Convert to local time for display if needed.
Q: How do I compute Malaysia–US spreads?
A: Use /api/v1/spread with country=MY, benchmark=US, and an optional maturity (default 10Y). The response returns spread_bps and both underlying yields.
Q: How should I cache results?
A: Cache latest/curve by country and date within the trading day. For intraday, respect your update interval; avoid polling more frequently than snapshots are produced.
Ready to integrate Malaysia yields into your models and dashboards? Use the Register link to get an API key, explore developer tooling via the MCP, and read more at bonds-api.com. Build, test, and ship your Malaysia yield curve analytics today.