WBData - World Bank Data Client

1.1.0 · active · verified Thu Apr 09

WBData is a Python library designed to simplify access to data from the World Bank's Indicators API. It provides an intuitive interface for searching indicators, countries, topics, and sources, and for retrieving time-series data. The current version is 1.1.0, with recent releases indicating active maintenance and regular updates.

Warnings

Install

Imports

Quickstart

Demonstrates how to fetch time-series data for multiple indicators and countries, retrieve metadata about indicators, and perform searches for available indicators. Data is typically returned as a Pandas DataFrame for easy manipulation.

import wbdata
import datetime

# Define the date range from 2000 to 2010
data_date = datetime.datetime(2000, 1, 1), datetime.datetime(2010, 1, 1)

# Define countries using their ISO2 codes
countries = ["FR", "DE", "IT"]

# Define indicators with human-readable aliases
indicators = {"NY.GDP.PCAP.CD": "GDP per Capita", "SP.POP.TOTL": "Total Population"}

# Get data as a Pandas DataFrame
df = wbdata.get_dataframe(indicators, country=countries, data_date=data_date)
print("\n--- Sample Data (GDP per Capita, Total Population) ---")
print(df.head())

# Get information about a specific indicator
print("\n--- Indicator Info for GDP per Capita ---")
indicators_info = wbdata.get_indicator("NY.GDP.PCAP.CD")
for key, value in indicators_info.items():
    print(f"{key}: {value}")

# Search for indicators containing 'population'
print("\n--- Search Results for 'population' ---")
population_indicators = wbdata.search_indicator("population")
# In an interactive shell or notebook, printing the list directly would show a table
print(f"Found {len(population_indicators)} indicators matching 'population'. Showing first 3:\n{population_indicators[:3]}")

view raw JSON →