Set up the client
Use Node 22 or later and set NARWHAL_API_KEY in your server environment. Never put an API key in browser code. Install the package and create the client. See the quickstart.
// npm install narwhalapi
import { Narwhal } from "narwhalapi";
// Reads NARWHAL_API_KEY from the server environment.
const nw = new Narwhal();Pull market interest rates from short yields
Request short-maturity government yields as market interest rates. A 3-month yield is available where the source publishes it. Available maturities vary by country and date; missing terms are omitted. Decimal values arrive as exact strings, and decimal inputs cannot be numbers.
const short = await nw.economics.yieldCurve("GBR", { maturity: ["3m", "2y"] });
for (const point of short.yields) {
console.log(point.maturity, point.yield_percent);
}Read the market-implied policy path
Request the Bank of England's market-implied policy rate path. Meetings include p_cut, p_hold and p_hike as probability strings, plus expected_change_bps, cumulative_change_bps and resolves_at. These are prediction-market odds, not official forecasts.
const path = await nw.predictions.policyPath("bank-of-england");
for (const meeting of path.meetings) {
console.log(meeting.resolves_at, meeting.p_cut, meeting.p_hold, meeting.p_hike);
}Go to the exact reference
Common questions
Can I fetch a central bank's current policy rate?
No. Narwhal has no endpoint for the current official policy rate. You can fetch short government yields and market-implied probabilities for upcoming policy meetings.
Why is the 3-month yield missing?
Available maturities depend on the country's source and the requested date. Missing terms are omitted, so a 3-month yield is returned only where the source publishes it.
Which other policy authorities can I query?
Other authorities include bank-of-canada, bank-of-japan and bank-indonesia. Their policy paths reflect prediction-market odds rather than official forecasts.
Sources and references
Published . Last reviewed .

