GnistAI GnistAI
Log in

Getting Started with World Bank

World Bank development indicators — poverty, health, education, and economic data by country.

All Tutorials   |   Overview   |   Playground   |   MCP   |   REST API   |   Home
Economics

Data source: World Bank Open Data

Overview

World Bank wraps World Bank Open Data, handling authentication, pagination, and rate limits for you. This tutorial covers all 5 tools with working code examples you can copy and run.

Prerequisites

  1. Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
  2. Choose your integration method: MCP protocol or REST API.

Connect via MCP

Add to your MCP client config (Claude Desktop, Cursor, etc.):

MCP Config
{
  "mcpServers": {
    "gnist-worldbank": {
      "url": "https://context.gnist.ai/mcp/worldbank/",
      "headers": {
        "Gnist-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Tools (5)

get_indicator

Fetch a time series for a World Bank indicator. Args: country_code: ISO 3166-1 alpha-2 or alpha-3 country code (e.g. "US", "USA", "NO"). Use "WLD" for global aggregates or "all" for every country. indicator_code: World Bank indicator ID (e.g. "NY.GDP.MKTP.CD" for GDP, "SP.POP.TOTL" for population). Use search_indicators to find codes. year_from: Start year (inclusive). If omitted, uses mrv instead. year_to: End year (inclusive). If omitted, uses year_from as single year. mrv: Most recent values to return (1–50, default 10). Used when year_from/year_to are not set. Returns: Time series of indicator values with date, value, and country metadata. Values may be null for years where data is unavailable.

ParameterTypeRequiredDescription
country_codestringrequiredISO 3166-1 alpha-2 or alpha-3 country code (e.g. "US", "USA", "NO"). Use "WLD" for global aggregates or "all" for every country.
indicator_codestringrequiredWorld Bank indicator ID (e.g. "NY.GDP.MKTP.CD" for GDP, "SP.POP.TOTL" for population). Use search_indicators to find codes.
year_fromanyoptionalStart year (inclusive). If omitted, uses mrv instead.
year_toanyoptionalEnd year (inclusive). If omitted, uses year_from as single year.
mrvintegeroptionalMost recent values to return (1–50, default 10). Used when year_from/year_to are not set. (default: 10)
curl -X POST "https://context.gnist.ai/mcp/worldbank/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_indicator", "arguments": {"country_code": "US", "indicator_code": "NY.GDP.MKTP.CD"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/worldbank/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'country_code': 'US',
                          'indicator_code': 'NY.GDP.MKTP.CD'},
            'name': 'get_indicator'}},
)
print(resp.json())

search_indicators

Search the World Bank indicator catalog by keyword. Covers 1,400+ socioeconomic indicators including GDP, population, health, education, trade, energy, environment, and more. Args: query: Search term (e.g. "gdp", "literacy rate", "co2 emissions"). per_page: Number of results to return (1–50, default 20). Returns: List of matching indicators with ID, name, unit, and topic classification. Use the indicator id field with get_indicator or compare_countries.

ParameterTypeRequiredDescription
querystringrequiredSearch term (e.g. "gdp", "literacy rate", "co2 emissions").
per_pageintegeroptionalNumber of results to return (1–50, default 20). (default: 20)
curl -X POST "https://context.gnist.ai/mcp/worldbank/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_indicators", "arguments": {"query": "gdp"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/worldbank/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'query': 'gdp'}, 'name': 'search_indicators'}},
)
print(resp.json())

country_profile

Get a snapshot of key development indicators for a country. Covers: GDP (total and per capita), population, life expectancy, and CO2 emissions. Data comes from World Bank Open Data (CC-BY-4.0). Args: country_code: ISO 3166-1 alpha-2 or alpha-3 country code (e.g. "NO", "USA", "DE"). year: Specific year to retrieve. Defaults to most recent available data. Returns: Country profile with GDP, population, life expectancy, and CO2 figures. Any field may be null if the World Bank has no data for that country/year combination.

ParameterTypeRequiredDescription
country_codestringrequiredISO 3166-1 alpha-2 or alpha-3 country code (e.g. "NO", "USA", "DE").
yearanyoptionalSpecific year to retrieve. Defaults to most recent available data.
curl -X POST "https://context.gnist.ai/mcp/worldbank/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "country_profile", "arguments": {"country_code": "NO"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/worldbank/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'country_code': 'NO'}, 'name': 'country_profile'}},
)
print(resp.json())

compare_countries

Compare one indicator across multiple countries for a given year. Args: indicator_code: World Bank indicator ID (e.g. "NY.GDP.MKTP.CD"). Use search_indicators to find the right code. country_codes: List of ISO 3166-1 alpha-2 or alpha-3 codes (e.g. ["US", "DE", "JP"]). Maximum 20 countries per request. year: The year to compare (e.g. 2022). Returns: Indicator values for each country in the requested year. Values may be null if data is unavailable for a country/year pair.

ParameterTypeRequiredDescription
indicator_codestringrequiredWorld Bank indicator ID (e.g. "NY.GDP.MKTP.CD"). Use search_indicators to find the right code.
country_codeslist[string]requiredList of ISO 3166-1 alpha-2 or alpha-3 codes (e.g. ["US", "DE", "JP"]). Maximum 20 countries per request.
yearintegerrequiredThe year to compare (e.g. 2022).
curl -X POST "https://context.gnist.ai/mcp/worldbank/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "compare_countries", "arguments": {"indicator_code": "NY.GDP.MKTP.CD", "country_codes": "[\"US\"", "year": 2022}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/worldbank/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'country_codes': '["US"',
                          'indicator_code': 'NY.GDP.MKTP.CD',
                          'year': 2022},
            'name': 'compare_countries'}},
)
print(resp.json())

report_feedback

Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.

ParameterTypeRequiredDescription
feedbackstringrequired
feedback_typestringoptional (default: general)
curl -X POST "https://context.gnist.ai/mcp/worldbank/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/worldbank/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())

Common Patterns

Search then retrieve
Use search_indicators to find items, then get_indicator to get full details. This two-step pattern is common for exploring data before drilling down.

FAQ

What data does World Bank provide?

World Bank development indicators — poverty, health, education, and economic data by country. It exposes 5 tools: get_indicator, search_indicators, country_profile, compare_countries, report_feedback.

What do I need to get started?

A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.

What format does the World Bank API return?

JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.

Next Steps

Related Tutorials