You need clean, current Malaysia government bond yields inside your models and dashboards, updated across maturities and aligned to business days. By the end of this guide, you’ll be able to fetch Malaysia (ISO2: MY) sovereign yields in JSON, build yield curves and spreads, and embed the data into Python, JavaScript, and PHP systems using Bonds API’s REST endpoints.
What you can fetch for Malaysia with Bonds API
Bonds API provides sovereign bond yields for Malaysia across bill and bond maturities (from 1M to 30Y, and beyond where available). The endpoints cover point-in-time data, complete daily time series, intraday snapshots, yield curve construction, spreads to a benchmark country, and fluctuations over a period.
All endpoints are GET under the base URL https://bonds-api.com/api/v1/ and authenticate with an API key sent in the X-API-Key header. Yields are returned as percentages (for example, 4.52 means 4.52%) unless specifically noted as basis points (bps) for spreads.
Useful links to keep handy:
- Bonds API product site
- Bonds API documentation for reference
- Register for an API key
- MCP to manage keys and monitor usage
Data model, units, and time
Fields you will see repeatedly across endpoints:
- yield: A percentage yield (e.g., 4.52 represents 4.52%).
- date: Trading date in YYYY-MM-DD format; reflects the local market’s last available business day for the country unless you specify a date.
- fetched_at or timestamp: ISO 8601 UTC timestamp (e.g., 2026-11-16T12:00:00Z) for intraday snapshots and metadata.
- spread_bps: Spread in basis points (1 bps = 0.01%).
- source: Data provenance string such as "official" or "market".
Calendar and frequency considerations for Malaysia:
- Business days: Malaysian public holidays and weekends are excluded. If you query a holiday or weekend date, the /latest endpoint will return the last available business day; historical endpoints return a 404 if no data exists for the requested date.
- Update frequency: Daily official closing yields and, where available, intraday snapshots. Use /intraday for sub-daily observations, which are timestamped in UTC.
- Caching: If you cache responses, include the date field to know when to refresh. For intraday, consider time-based invalidation aligned with your UI update cadence.
To get an API key, visit Get started with Bonds API or Register for Bonds API. You can also manage keys via the Bonds API MCP.
Quick start: fetch Malaysia 2Y and 10Y latest yields
The /latest endpoint returns the most recent yields for specified countries and (optionally) maturities. For Malaysia, pass countries=MY and a comma-separated list of maturities when you only need specific tenors.
Endpoint: GET /api/v1/latest
Parameters:
- countries (required): ISO2 codes, e.g., MY
- maturities (optional): Comma-separated maturities, e.g., 2Y,10Y. Omit to get all available for the country.
cURL
curl -s "https://bonds-api.com/api/v1/latest?countries=US&maturities=10Y&api_key=YOUR_API_KEY"
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"}
)
data = resp.json()
# Access fields:
two_year = data["data"]["MY"]["2Y"]["yield"] # percentage
ten_year = data["data"]["MY"]["10Y"]["yield"] # percentage
ten_year_date = data["data"]["MY"]["10Y"]["date"] # YYYY-MM-DD
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.toString(), {
method: "GET",
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(json => {
const my = json.data.MY;
console.log("MY 2Y:", my["2Y"].yield, "on", my["2Y"].date);
console.log("MY 10Y:", my["10Y"].yield, "on", my["10Y"].date);
});
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=MY&maturities=2Y,10Y";
$json = file_get_contents($url, 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";
Example JSON response (official sample)
{
"success": true,
"date": "2026-11-16",
"rates": {
"US_10Y": 5.151
},
"dates": {
"US_10Y": "2026-11-16"
},
"currencies": {
"US_10Y": "USD"
},
"meta": {
"request_id": "32d0192a-13d2-45df-abb0-260c1ad9ac11",
"timestamp": "2026-11-16T00:04:05+00:00"
}
}
How to read it:
- yield: percentage value; 4.52 means 4.52%.
- date: YYYY-MM-DD for the trading date applicable to that yield.
- source: "official" signals an official publication or validated market close.
Point-in-time Malaysia yield: historical date lookup
Use /historical when you need the Malaysia yield for a specific tenor on a specific date (e.g., backtesting or end-of-month valuation checks).
Endpoint: GET /api/v1/historical
Parameters:
- country (required): MY
- maturity (required): e.g., 10Y
- date (required): YYYY-MM-DD
cURL
Python (requests)
import requests
params = {"country": "MY", "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
)
row = resp.json()
ten_yield = row["yield"]
as_of = row["date"]
JavaScript (fetch)
const params = new URLSearchParams({ country: "MY", maturity: "10Y", date: "2025-06-15" });
fetch("https://bonds-api.com/api/v1/historical?" + params.toString(), {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(json => {
console.log(`MY 10Y on ${json.date} = ${json.yield}%`);
});
PHP (file_get_contents)
<?php
$q = http_build_query(["country" => "MY", "maturity" => "10Y", "date" => "2025-06-15"]);
$opts = ["http" => ["method" => "GET", "header" => "X-API-Key: YOUR_API_KEY\r\n"]];
$json = file_get_contents("https://bonds-api.com/api/v1/historical?$q", false, stream_context_create($opts));
$data = json_decode($json, true);
echo "Yield: ".$data["yield"]."% as of ".$data["date"]."\n";
Example JSON response
Notes:
- If the requested date is a non-trading day with no published value, you may receive 404 with an error message.
- Use YYYY-MM-DD; incorrect formats return 422.
Malaysia time series: build charts and regressions
/timeseries returns a continuous series of daily yields for a specific maturity between start and end dates. This is ideal for plotting, volatility estimation, or macro regressions.
Endpoint: GET /api/v1/timeseries
Parameters:
- country (required): MY
- maturity (required): e.g., 10Y
- start (required): YYYY-MM-DD
- end (required): YYYY-MM-DD (>= start)
cURL
Python (requests)
import requests
params = {
"country": "MY",
"maturity": "10Y",
"start": "2025-11-16",
"end": "2026-11-16"
}
resp = requests.get(
"https://bonds-api.com/api/v1/timeseries",
headers={"X-API-Key": "YOUR_API_KEY"},
params=params
)
series = resp.json()["series"]
# Example: compute simple daily changes
changes = []
for i in range(1, len(series)):
changes.append(series[i]["yield"] - series[i-1]["yield"])
JavaScript (fetch)
const params = new URLSearchParams({
country: "MY",
maturity: "10Y",
start: "2025-11-16",
end: "2026-11-16"
});
fetch("https://bonds-api.com/api/v1/timeseries?" + params.toString(), {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(json => {
json.series.forEach(p => console.log(p.date, p.yield));
});
PHP (file_get_contents)
<?php
$q = http_build_query([
"country" => "MY",
"maturity" => "10Y",
"start" => "2025-11-16",
"end" => "2026-11-16"
]);
$ctx = stream_context_create(["http" => ["method" => "GET", "header" => "X-API-Key: YOUR_API_KEY\r\n"]]);
$data = json_decode(file_get_contents("https://bonds-api.com/api/v1/timeseries?$q", false, $ctx), true);
foreach ($data["series"] as $row) {
echo $row["date"].": ".$row["yield"]."%\n";
}
Example JSON response
Interpretation:
- Each element has a trading date and a closing yield in percent.
- Missing holidays and weekends are naturally absent; do not attempt to forward-fill unless required by your model.
Spread to a benchmark: Malaysia vs US Treasuries
For cross-market comparison, /spread computes the Malaysia yield spread versus a benchmark country (e.g., US) at a given maturity. The spread is returned in basis points.
Endpoint: GET /api/v1/spread
Parameters:
- country (required): MY
- benchmark (required): ISO2 of benchmark country (e.g., US)
- maturity (optional): Defaults to 10Y if omitted
cURL
Python (requests)
import requests
params = {"country": "MY", "benchmark": "US", "maturity": "10Y"}
resp = requests.get(
"https://bonds-api.com/api/v1/spread",
headers={"X-API-Key": "YOUR_API_KEY"},
params=params
)
row = resp.json()
print("Spread (bps):", row["spread_bps"])
print("MY 10Y:", row["country_yield"], "US 10Y:", row["benchmark_yield"])
JavaScript (fetch)
const params = new URLSearchParams({ country: "MY", benchmark: "US", maturity: "10Y" });
fetch("https://bonds-api.com/api/v1/spread?" + params.toString(), {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(json => {
console.log(`MY-US 10Y spread: ${json.spread_bps} bps`);
});
PHP (file_get_contents)
<?php
$q = http_build_query(["country" => "MY", "benchmark" => "US", "maturity" => "10Y"]);
$ctx = stream_context_create(["http" => ["method" => "GET", "header" => "X-API-Key: YOUR_API_KEY\r\n"]]);
$data = json_decode(file_get_contents("https://bonds-api.com/api/v1/spread?$q", false, $ctx), true);
echo "Spread: ".$data["spread_bps"]." bps\n";
Example JSON response
Reading the fields:
- spread_bps: Malaysia yield minus benchmark yield in basis points.
- country_yield and benchmark_yield: Percentage yields for the comparison, same trading date.
Full Malaysia yield curve in one call
/curve returns a country’s yield curve for a single date (default: latest available). This is the preferred way to pull several maturities at once for curve-fitting or risk calculations.
Endpoint: GET /api/v1/curve
Parameters:
- country (required): MY
- date (optional): YYYY-MM-DD. If omitted, the latest available trading day is returned.
cURL
Python (requests)
import requests
resp = requests.get(
"https://bonds-api.com/api/v1/curve",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"country": "MY"}
)
curve = resp.json()
tenors = list(curve["curve"].keys())
levels = list(curve["curve"].values())
JavaScript (fetch)
const params = new URLSearchParams({ country: "MY" });
fetch("https://bonds-api.com/api/v1/curve?" + params.toString(), {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(json => {
console.log("Curve date:", json.date, "Inverted:", json.inverted);
Object.entries(json.curve).forEach(([tenor, y]) => console.log(tenor, y));
});
PHP (file_get_contents)
<?php
$q = http_build_query(["country" => "MY"]);
$ctx = stream_context_create(["http" => ["method" => "GET", "header" => "X-API-Key: YOUR_API_KEY\r\n"]]);
$data = json_decode(file_get_contents("https://bonds-api.com/api/v1/curve?$q", false, $ctx), true);
foreach ($data["curve"] as $tenor => $y) {
echo $tenor.": ".$y."%\n";
}
Example JSON response
Interpretation:
- curve: Map of tenor to yield in percentage.
- inverted: Boolean indicating if longer tenors are below shorter tenors in aggregate.
- date: Curve snapshot date. Cache by date if you show historical curves.
Intraday Malaysia yields: snapshots for trading UIs
Use /intraday to show how a yield moved during a trading day. Snapshots are timestamped in UTC and include a source such as "market".
Endpoint: GET /api/v1/intraday
Parameters:
- country (required): MY
- maturity (required): e.g., 10Y
- date (required): YYYY-MM-DD trading date
cURL
Python (requests)
import requests
params = {"country": "MY", "maturity": "10Y", "date": "2026-11-16"}
resp = requests.get(
"https://bonds-api.com/api/v1/intraday",
headers={"X-API-Key": "YOUR_API_KEY"},
params=params
)
snapshots = resp.json()["snapshots"]
# Example: last snapshot
last = snapshots[-1] if snapshots else None
JavaScript (fetch)
const params = new URLSearchParams({ country: "MY", maturity: "10Y", date: "2026-11-16" });
fetch("https://bonds-api.com/api/v1/intraday?" + params.toString(), {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(json => {
json.snapshots.forEach(s => console.log(s.fetched_at, s.yield, s.source));
});
PHP (file_get_contents)
<?php
$q = http_build_query(["country" => "MY", "maturity" => "10Y", "date" => "2026-11-16"]);
$ctx = stream_context_create(["http" => ["method" => "GET", "header" => "X-API-Key: YOUR_API_KEY\r\n"]]);
$data = json_decode(file_get_contents("https://bonds-api.com/api/v1/intraday?$q", false, $ctx), true);
foreach ($data["snapshots"] as $s) {
echo $s["fetched_at"]." => ".$s["yield"]."% (".$s["source"].")\n";
}
Example JSON response
Key points:
- fetched_at is UTC (Z suffix). Convert to your user’s timezone in the UI.
- Use count for quick integrity checks and to detect empty days.
Malaysia yield fluctuation over a period
/fluctuation summarizes change, min, and max between two dates for one or more countries at a given maturity. This is useful for risk summaries and weekly notes.
Endpoint: GET /api/v1/fluctuation
Parameters:
- countries (required): e.g., MY
- maturity (required): e.g., 10Y
- start (required): YYYY-MM-DD
- end (required): YYYY-MM-DD
cURL
Python (requests)
import requests
params = {
"countries": "MY",
"maturity": "10Y",
"start": "2025-11-16",
"end": "2026-11-16"
}
resp = requests.get(
"https://bonds-api.com/api/v1/fluctuation",
headers={"X-API-Key": "YOUR_API_KEY"},
params=params
)
row = resp.json()["data"]["MY"]
summary = {
"start_yield": row["start_yield"],
"end_yield": row["end_yield"],
"change": row["change"],
"min": row["min"],
"max": row["max"]
}
JavaScript (fetch)
const params = new URLSearchParams({
countries: "MY",
maturity: "10Y",
start: "2025-11-16",
end: "2026-11-16"
});
fetch("https://bonds-api.com/api/v1/fluctuation?" + params.toString(), {
headers: { "X-API-Key": "YOUR_API_KEY" }
})
.then(r => r.json())
.then(json => {
const my = json.data.MY;
console.log(`Start=${my.start_yield}, End=${my.end_yield}, Δ=${my.change}`);
});
PHP (file_get_contents)
<?php
$q = http_build_query(["countries" => "MY", "maturity" => "10Y", "start" => "2025-11-16", "end" => "2026-11-16"]);
$ctx = stream_context_create(["http" => ["method" => "GET", "header" => "X-API-Key: YOUR_API_KEY\r\n"]]);
$data = json_decode(file_get_contents("https://bonds-api.com/api/v1/fluctuation?$q", false, $ctx), true);
$my = $data["data"]["MY"];
echo "Δ: ".$my["change"]." (".$my["min"]." to ".$my["max"].")\n";
Example JSON response
Interpretation:
- change is in percentage points (end_yield minus start_yield).
- min and max reflect extremes within the window, not necessarily on the endpoints.
Sovereign bond basics (Malaysia context)
Malaysia issues government securities across bills (short-term) and longer-dated bonds. The yield is the annualized return implied by market price. Analysts track term structure (across maturities), curve slope (e.g., 2s10s), and spreads vs benchmarks to gauge monetary stance, growth expectations, and risk premia.
With Bonds API, you can:
- Construct Malaysia yield curves for curve-fitting models.
- Monitor intraday shifts in the 10Y or 3Y for trading UIs.
- Compute spreads to US Treasuries and other benchmarks.
- Backtest strategies using historical and fluctuation endpoints.
Putting it together: multi-tenor curve and spreads
Two common build patterns for a Malaysia fixed-income dashboard:
- Curve-first: Call /curve for MY to get the full on-the-run curve as of the latest day. Fit Nelson-Siegel or spline on the returned levels.
- Latest by selection: Call /latest with countries=MY and maturities like 1Y,2Y,5Y,10Y for a lean payload when you only show a subset. Use /spread for MY vs US at 10Y to display cross-country differentials in bps.
Handling business days and holidays:
- Daily endpoints use trading dates. If your UI expects today’s date, show the data’s actual date field to avoid confusion on holidays.
- For time series alignment between MY and US when computing rolling spreads, join on the intersection of available dates.
Caching guidance:
- /latest and /curve: Cache until the next market open or your data refresh window (e.g., end-of-day). Always display the date field.
- /intraday: Short TTL in caches (e.g., a few minutes) to keep UIs snappy without hammering the API.
- Consider storing server responses keyed by (endpoint + params). Include versioning if your app evolves field dependencies.
Error handling and resilience
Standardized error responses help you recover gracefully. The shape is success=false with an error message. Watch for:
- 401: Missing or invalid X-API-Key (check header name and value).
- 403: Account quota exceeded (lower frequency, contact support, or adjust caching).
- 404: No data for the requested combination (e.g., non-trading date).
- 422: Invalid parameter (date format must be YYYY-MM-DD; country must be MY; maturity must be a supported tenor).
- 429: Rate limit exceeded (backoff and retry with jitter; increase cache TTLs).
- 500: Server error (retry with exponential backoff; show last cached value with date).
Tip for developers: log the full request URL, headers you send (excluding the raw API key), and the response status to ease debugging. Keep the API key encrypted and never embed it in frontend code distributed to end users; if you must call directly from the browser, route requests through your backend.
Complete endpoint index with samples
Below is a compact index of all seven endpoints covered above, each using GET, the X-API-Key header, and Malaysia as the focus country:
- /api/v1/latest: Latest MY yields across selected maturities.
- /api/v1/historical: Point-in-time MY yield for given date and maturity.
- /api/v1/timeseries: Daily MY yield series between two dates.
- /api/v1/spread: MY vs benchmark spread in bps.
- /api/v1/curve: Full MY curve with inverted flag.
- /api/v1/intraday: Intraday MY snapshots with UTC timestamps.
- /api/v1/fluctuation: Start/end, change, min, max for MY over a window.
All examples in this article use the official field names and structures from bonds-api.com. Keep the X-API-Key header as X-API-Key: YOUR_API_KEY in production code.
Use cases developers are shipping today
- Financial dashboards: Display Malaysia 2Y–10Y curve with color-coded inversion status and daily change badges.
- Portfolio risk: Feed /timeseries into DV01 and duration-contribution calculations; use /fluctuation for weekly PM summaries.
- Macro research: Create MY vs US 10Y spread charts with /spread, highlighting widening/narrowing periods.
- Trading UIs: Stream /intraday snapshots and show last, change since open, and timestamp in local time.
FAQ
How are yields expressed?
Yields are percentages (e.g., 4.52 means 4.52%). Only spread_bps fields are in basis points.
What timezone are timestamps in?
Fields like fetched_at and meta.timestamp are in UTC (Z suffix). The date field is a trading date (YYYY-MM-DD) without a time component.
How do I handle Malaysia market holidays?
/latest returns the most recent business day; historical and timeseries omit non-trading days. Your UI should display the date from the response to avoid “stale” confusion.
Can I get several Malaysia maturities in one call?
Yes. Use /curve for the full curve on a date, or /latest with maturities=1Y,2Y,5Y,10Y for a subset.
What if I exceed my rate limit?
You’ll receive 429. Implement exponential backoff and leverage caching on your side. Consider caching /curve and /latest until the next scheduled refresh.
Ready to integrate Malaysia sovereign yields into your stack? Register for an API key, explore the MCP, and start calling the endpoints documented here. You can also Get started with Bonds API for more details and examples.