Comprehensive Guide to the World Bank API (WBAPI)
The World Bank API (WBAPI) is a powerful tool for accessing a vast array of economic and development data. This guide provides detailed information about the API’s endpoints, examples of how to use them, and practical applications.
Overview of Key Endpoints
The API allows users to retrieve data related to countries, indicators, regions, and more. Below is a detailed explanation of the primary endpoints:
1. Countries
- Endpoint:
/country - Description: Retrieves a list of all countries available in the World Bank database, including their codes and names.
- Example Usage:
GET http://api.worldbank.org/v2/country?format=json
- Response Format: JSON, providing country details such as ID, name, and region.
2. Indicators
- Endpoint:
/indicator - Description: Accesses a comprehensive list of indicators that measure various economic, social, and environmental metrics.
- Example Usage:
GET http://api.worldbank.org/v2/indicator?format=json
- Response Format: JSON, detailing indicator ID, name, and related metadata.
3. Data Retrieval
- Endpoint:
/data - Description: Fetches data for a specific indicator over time for a specific country or group of countries.
- Example Usage:
GET http://api.worldbank.org/v2/country/{country_code}/indicator/{indicator_id}?format=json
- Replace
{country_code}with the desired country code (e.g.,BRfor Brazil) and{indicator_id}with the specific indicator ID (e.g.,NY.GDP.MKTP.CDfor GDP). - Response Format: JSON, containing time series data for the specified indicator.
4. Series
- Endpoint:
/series - Description: Provides information on series, which can be analyzed for specific aspects of data over time.
- Example Usage:
GET http://api.worldbank.org/v2/series?format=json
- Response Format: JSON, showing details about the series available.
5. Regions
- Endpoint:
/region - Description: Accesses a list of regions used by the World Bank for data classification.
- Example Usage:
GET http://api.worldbank.org/v2/region?format=json
- Response Format: JSON, listing regions with IDs and names.
Example Queries
Here are some practical examples to demonstrate how to fetch specific data using the API:
GDP Data for Brazil
GET http://api.worldbank.org/v2/country/BR/indicator/NY.GDP.MKTP.CD?format=json
This call retrieves the GDP data for Brazil, showing historical values over time.
Population Data for India
GET http://api.worldbank.org/v2/country/IN/indicator/SP.POP.TOTL?format=json
This fetches population data for India, providing a time series of total population counts.
Using the API in Python
Here’s a simple example of how to use the World Bank API in a Python script:
import requests
# Example to get GDP data for Brazil
url = 'http://api.worldbank.org/v2/country/BR/indicator/NY.GDP.MKTP.CD?format=json'
response = requests.get(url)
data = response.json()
# Print the GDP data
for entry in data[1]: # data[1] contains the actual data points
print(f"Year: {entry['date']}, GDP: {entry['value']}")
Summary Table of Endpoints
| Endpoint | Description | Example Usage |
|---|---|---|
/country | List all countries | GET http://api.worldbank.org/v2/country?format=json |
/indicator | Access all indicators | GET http://api.worldbank.org/v2/indicator?format=json |
/data | Fetch specific indicator data | GET http://api.worldbank.org/v2/country/{country_code}/indicator/{indicator_id}?format=json |
/series | Information on series | GET http://api.worldbank.org/v2/series?format=json |
/region | List of regions | GET http://api.worldbank.org/v2/region?format=json |
Conclusion
The World Bank API is a valuable resource for researchers, developers, and policymakers looking to access economic and social data globally. By utilizing the endpoints described in this guide, you can effectively gather data on various topics, aiding in research and analysis. For more detailed information, visit the official World Bank Data Help Desk

Leave a comment