World Bank APIwits.worldbank.org ↗
Access country trade profiles, bilateral trade data, tariffs, GDP, and World Bank development indicators via the WITS API. 5 endpoints, 266 countries covered.
What is the World Bank API?
The WITS API delivers trade statistics and development indicators from the World Bank's World Integrated Trade Solution platform across 266 countries through 5 endpoints. Use get_country_list to look up ISO3 codes and regional groupings, get_trade_by_partner to retrieve bilateral import/export volumes and trade balances, or get_trade_indicators to pull GDP, GNI, merchandise trade breakdowns, and tariff figures for any country-year pair.
curl -X GET 'https://api.parse.bot/scraper/2f90776c-49cd-4aae-bacb-3de969248392/get_country_list?region=Sub-Saharan+Africa' \ -H 'X-API-Key: $PARSE_API_KEY'
Typed, relational, agent-ready
A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.
- Fully typed · autocompletes
- Objects link to objects
- Typed errors & pagination
Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:
uv add parse-sdk uv run parse init uv run parse add --marketplace wits-worldbank-org-api
uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.
"""Walkthrough: WITS Trade API — bounded, re-runnable; every call capped."""
from parse_apis.world_bank_wits_trade_api import WITS, Region, Year, CountryNotFound
client = WITS()
# List countries in Sub-Saharan Africa, capped at 5 items.
for country in client.countries.list(region=Region.SUB_SAHARAN_AFRICA, limit=5):
print(country.name, country.iso3, country.region, country.income_group)
# Drill into one country's snapshot via .first()
country = client.countries.list(region=Region.SUB_SAHARAN_AFRICA, limit=1).first()
if country:
snapshot = country.snapshot()
print(snapshot.iso3, snapshot.summary_stats)
# Get trade indicators for a specific year
indicators = country.trade_indicators(year=Year._2021)
print(indicators.iso3, indicators.year, indicators.indicators)
# Get detailed trade summary tables
summary = country.trade_summary(year=Year._2021)
print(summary.iso3, summary.year, len(summary.tables))
# List bilateral trade partners (sub-resource)
for partner in country.partners.list(year=Year._2021, limit=3):
print(partner.partner, partner.export_value, partner.import_value)
# Typed error handling for a country that doesn't exist
try:
bad = client.countries.list(region="Nonexistent Region", limit=1).first()
if bad:
bad.snapshot()
except CountryNotFound as exc:
print(f"Country not found: {exc.iso3}")
print("exercised: countries.list / snapshot / trade_indicators / trade_summary / partners.list")
Retrieve the list of countries available in WITS with their ISO3 codes, names, regions, and income groups. Optionally filter by region name (case-insensitive substring match). Returns all 266 countries when no filter is applied. Each country includes its World Bank region classification and income group.
| Param | Type | Description |
|---|---|---|
| region | string | Region filter applied as a case-insensitive substring match on the region field. Accepted values include 'Sub-Saharan Africa', 'Europe & Central Asia', 'Middle East & North Africa', 'East Asia & Pacific', 'South Asia', 'Latin America & Caribbean', 'North America'. Omit to return all countries. |
{
"type": "object",
"fields": {
"count": "integer total number of countries returned",
"countries": "array of country objects each containing name, iso3, region, and income_group"
},
"sample": {
"data": {
"count": 48,
"countries": [
{
"iso3": "AGO",
"name": "Angola",
"region": "Sub-Saharan Africa",
"income_group": "Lower middle income"
},
{
"iso3": "NGA",
"name": "Nigeria",
"region": "Sub-Saharan Africa",
"income_group": "Lower middle income"
}
]
},
"status": "success"
}
}About the World Bank API
Country Coverage and Lookup
The get_country_list endpoint returns all 266 countries in the WITS database, each with a name, iso3 code, region, and income_group. An optional region parameter filters results by case-insensitive substring match, so querying 'Sub-Saharan' narrows the list to Sub-Saharan African economies. ISO3 codes returned here are the required input for every other endpoint.
Country Trade Profiles
get_country_snapshot returns an at-a-glance trade summary for a given ISO3 code. The response includes summary_stats — a flat object of labeled indicators like total exports, imports, FDI inflows, and average tariff rates — plus top_partners, which maps category headings to ranked arrays of trading partners with associated value_mil figures. get_trade_summary goes deeper: for a specific iso3 and year, it returns multiple structured tables covering top products, top export markets, top import sources, product category breakdowns, market concentration indexes, and GDP indicators.
Bilateral and Indicator Data
get_trade_by_partner accepts an iso3 and year and returns partner-level records containing Reporter, Partner, Import, Export, and MetaData fields, including partner share percentages and trade balance figures. An optional limit parameter caps the number of partner records returned. get_trade_indicators maps a broad set of World Bank indicators — including trade as a percentage of GDP, service trade values, tax data, and GNI figures — to their values for a given country and year, returned as a flat indicators object.
Data Source Notes
WITS aggregates data from UN Comtrade, UNCTAD, and World Bank datasets. Not all country-year combinations have complete data; some indicators or trade tables may return sparse results depending on a country's reporting history. The year parameter accepts four-digit strings and should reflect years for which the country has submitted trade data to the underlying databases.
The World Bank API is a managed, monitored endpoint for wits.worldbank.org — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when wits.worldbank.org changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.
This isn't an official wits.worldbank.org API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Build a country trade profile dashboard showing exports, imports, FDI, and top partners using
get_country_snapshot - Analyze bilateral trade balances between specific country pairs with import/export values from
get_trade_by_partner - Filter countries by income group or region using
get_country_listto scope economic research datasets - Track GDP, GNI, and trade-as-percent-of-GDP trends over time with
get_trade_indicators - Compare top export markets and product category breakdowns across years using
get_trade_summarytables - Identify market concentration and tariff exposure for a given country-year using trade summary indexes
- Populate country selectors in trade analytics tools with ISO3 codes and region metadata from
get_country_list
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.
Does WITS have an official developer API?+
What does `get_trade_by_partner` return, and how does the `limit` parameter work?+
get_trade_by_partner returns one record per trading partner, each with Reporter, Partner, Import, Export, and a MetaData array containing aggregate trade values and partner share percentages. The optional limit parameter caps how many partner records are included in data; omitting it returns all available partners for that country-year.Can I retrieve historical time-series data across multiple years in a single call?+
get_trade_summary, get_trade_by_partner, and get_trade_indicators accepts a single year per request. To build a time series you would need one call per year. You can fork this API on Parse and revise it to add a multi-year endpoint that loops and aggregates results.Does the API expose product-level tariff lines or HS code data?+
get_trade_summary includes aggregate tariff figures and product category breakdowns, and get_country_snapshot surfaces average tariff rates in summary_stats, but line-level tariff schedules are not currently returned. You can fork this API on Parse and revise it to add an endpoint targeting WITS product-level tariff data.Are there gaps in country or year coverage?+
get_country_list confirms which ISO3 codes exist, but it does not indicate which years have data for a given country.