Government debt and budget balance API reference
Government debt and budget balance by country and year, percent of GDP
Overview
How much a country's government owes, and whether it runs a surplus or a deficit, as a percent of GDP, from the IMF World Economic Outlook.
A country is its ISO 3166 alpha-3 code, such as IDN. Debt is general government gross debt. The balance is general government net lending (positive) or net borrowing (negative). Every value is a decimal string.
The route without observations returns the newest actual year. observations returns every year, oldest first. kind is actual up to the last year the IMF calls actual for that country and series, and forecast after it. Every answer names its source and its edition, the year and month of the World Economic Outlook round.
Base URL: https:/. Each route below is an MCP tool of its own, with the same parameters.
What every account gets
| What | Every account |
|---|---|
| One country and measure | One Economics call |
See pricing for what a call costs. A request is charged at the price of its API unless a route says otherwise.
- The last actual year differs between countries.
- Read
yearandkindrather than assuming last year is actual. - Some countries report by fiscal year. The year is the IMF's, placed on the calendar year its note gives.
- Only the newest edition is served. For earlier rounds of a forecast, use the forecasts route.
- A country the IMF gives no figure for is 404 not_covered. A range with no year is 404 not_found. Neither is charged.
- The figures are the IMF's, republished unchanged, checked weekly, and are for analysis, not financial, investment, legal or tax advice.
Endpoints
Every route is a GET and needs your key in the Authorization: Bearer header. The examples show the shape of an answer, not live data.
Get Government Debt
GET /v1/economics/{country}/government/debt
MCP: tool economics_.
Parameters
| Parameter | Where | Required | Type | Meaning |
|---|---|---|---|---|
country | path | Yes | string | ISO 3166 alpha-3 country code, for example DEU. |
Response fields
| Field | Type | Sent | Meaning |
|---|---|---|---|
country | string | Always | The country asked for, ISO 3166 alpha-3. |
indicator | one of government_debt_gdp, government_balance_gdp | Always | government_debt_gdp or government_balance_gdp. |
unit | always "percent of GDP" | Always | The unit of every value. |
year | integer | Always | The year of the value. |
value | string | Always | Percent of GDP, as the IMF writes it. A negative balance is a deficit. |
kind | one of actual, forecast | Always | actual up to the last year the IMF calls actual for the country, forecast after it. |
source | always "IMF World Economic Outlook" | Optional | Who publishes the figures. |
edition | string | Always | The World Economic Outlook round the figures come from, YYYY-MM. |
curl -H "Authorization: Bearer $NARWHAL_API_KEY" \
"https://api.narwhalapi.com/v1/economics/IDN/government/debt"{
"country": "IDN",
"indicator": "government_debt_gdp",
"unit": "percent of GDP",
"year": 2025,
"value": "40.879735",
"kind": "actual",
"source": "IMF World Economic Outlook",
"edition": "2026-10"
}Get Government Debt History
GET /v1/economics/{country}/government/debt/observations
MCP: tool economics_.
Parameters
| Parameter | Where | Required | Type | Meaning |
|---|---|---|---|---|
country | path | Yes | string | ISO 3166 alpha-3 country code, for example DEU. |
start | query | No | string | First year to return, as YYYY. |
end | query | No | string | Last year to return, as YYYY. |
Response fields
| Field | Type | Sent | Meaning |
|---|---|---|---|
country | string | Always | The country asked for, ISO 3166 alpha-3. |
indicator | one of government_debt_gdp, government_balance_gdp | Always | government_debt_gdp or government_balance_gdp. |
unit | always "percent of GDP" | Always | The unit of every value. |
source | always "IMF World Economic Outlook" | Optional | Who publishes the figures. |
edition | string | Always | The World Economic Outlook round the figures come from, YYYY-MM. |
observations | list of object | Always | One row per year, oldest first. |
observations[].year | integer | Always | The year of the value. |
observations[].value | string | Always | Percent of GDP, as the IMF writes it. |
observations[].kind | one of actual, forecast | Always | actual up to the last year the IMF calls actual for the country, forecast after it. |
curl -H "Authorization: Bearer $NARWHAL_API_KEY" \
"https://api.narwhalapi.com/v1/economics/IDN/government/debt/observations?start=2025&end=2026"{
"country": "IDN",
"indicator": "government_debt_gdp",
"unit": "percent of GDP",
"source": "IMF World Economic Outlook",
"edition": "2026-10",
"observations": [
{
"year": 2025,
"value": "40.879735",
"kind": "actual"
},
{
"year": 2026,
"value": "41.698325",
"kind": "forecast"
}
]
}Get Government Balance
GET /v1/economics/{country}/government/balance
MCP: tool economics_.
Parameters
| Parameter | Where | Required | Type | Meaning |
|---|---|---|---|---|
country | path | Yes | string | ISO 3166 alpha-3 country code, for example DEU. |
Response fields
| Field | Type | Sent | Meaning |
|---|---|---|---|
country | string | Always | The country asked for, ISO 3166 alpha-3. |
indicator | one of government_debt_gdp, government_balance_gdp | Always | government_debt_gdp or government_balance_gdp. |
unit | always "percent of GDP" | Always | The unit of every value. |
year | integer | Always | The year of the value. |
value | string | Always | Percent of GDP, as the IMF writes it. A negative balance is a deficit. |
kind | one of actual, forecast | Always | actual up to the last year the IMF calls actual for the country, forecast after it. |
source | always "IMF World Economic Outlook" | Optional | Who publishes the figures. |
edition | string | Always | The World Economic Outlook round the figures come from, YYYY-MM. |
curl -H "Authorization: Bearer $NARWHAL_API_KEY" \
"https://api.narwhalapi.com/v1/economics/IDN/government/balance"{
"country": "IDN",
"indicator": "government_balance_gdp",
"unit": "percent of GDP",
"year": 2025,
"value": "-2.916694",
"kind": "actual",
"source": "IMF World Economic Outlook",
"edition": "2026-10"
}Get Government Balance History
GET /v1/economics/{country}/government/balance/observations
MCP: tool economics_.
Parameters
| Parameter | Where | Required | Type | Meaning |
|---|---|---|---|---|
country | path | Yes | string | ISO 3166 alpha-3 country code, for example DEU. |
start | query | No | string | First year to return, as YYYY. |
end | query | No | string | Last year to return, as YYYY. |
Response fields
| Field | Type | Sent | Meaning |
|---|---|---|---|
country | string | Always | The country asked for, ISO 3166 alpha-3. |
indicator | one of government_debt_gdp, government_balance_gdp | Always | government_debt_gdp or government_balance_gdp. |
unit | always "percent of GDP" | Always | The unit of every value. |
source | always "IMF World Economic Outlook" | Optional | Who publishes the figures. |
edition | string | Always | The World Economic Outlook round the figures come from, YYYY-MM. |
observations | list of object | Always | One row per year, oldest first. |
observations[].year | integer | Always | The year of the value. |
observations[].value | string | Always | Percent of GDP, as the IMF writes it. |
observations[].kind | one of actual, forecast | Always | actual up to the last year the IMF calls actual for the country, forecast after it. |
curl -H "Authorization: Bearer $NARWHAL_API_KEY" \
"https://api.narwhalapi.com/v1/economics/IDN/government/balance/observations?start=2025&end=2026"{
"country": "IDN",
"indicator": "government_balance_gdp",
"unit": "percent of GDP",
"source": "IMF World Economic Outlook",
"edition": "2026-10",
"observations": [
{
"year": 2025,
"value": "-2.916694",
"kind": "actual"
},
{
"year": 2026,
"value": "-2.898354",
"kind": "forecast"
}
]
}Errors
Errors use the shared problem shape with a request_. See Errors and credits for the shape and the credit headers. Failed requests are not charged.
| Code | Status | Meaning |
|---|---|---|
invalid_ | 400 | The country is not a three letter code, or start or end is not a year, or start is after end. Not charged. |
not_ | 404 | No year in this range is held for this country. Not charged. |
not_ | 404 | The IMF World Economic Outlook gives no figure for this country. Not charged. |
insufficient_ | 402 | Your credit balance is less than the request costs. |
economics_ | 503 | Nothing is stored yet, or the stored data cannot answer. Not charged. |
invalid_ | 401 | The Bearer key is missing, malformed, unknown, or inactive. |
rate_ | 429 | The network or account per-minute limit was reached. Retry after the time in the Retry-After header. |
Was this page helpful?