Registry / data / wbdata

wbdata

JSON →
library1.1.0pypypi✓ verified 28d ago

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.

pip install wbdata
INSTALL
IMPORT
SIG · WBDATA
W
wbdata
datapythonv1.1.0
Install
3.7s avg
Import
1546ms
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.610s · 31.7MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.7s · import 1.482s · 33MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wbdata
✓ import wbdata
The primary way to use the library; all main functions are methods of the `wbdata` module (e.g., `wbdata.get_dataframe`).

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]}")
Debug
Known issues
breakingThe 1.0.0 release introduced significant architectural changes, renaming many functions and arguments for consistency and clarity. Code written for pre-1.0.0 versions will likely break.
fix
Consult the v1.0.0 documentation or examples for updated function and argument names (e.g., `get_dataframe` replaces older data retrieval methods). The overall data retrieval pattern has shifted.
affects: <1.0.0
breakingVersion 1.1.0 dropped support for older, End-of-Life Python versions, now requiring Python >=3.10. Additionally, version 0.3.0 previously dropped support for Python <= 3.5.
fix
Upgrade your Python environment to 3.10 or newer to use `wbdata` 1.1.0+. Ensure your development environment meets the `requires_python` specification.
affects: <1.1.0 on Python <3.10; <0.3.0 on Python <3.6
gotchaPrior to v1.0.0, date arguments exclusively required `datetime.datetime` objects. Since v1.0.0, string representations for years, months, or quarters are also accepted, which can lead to different interpretations of date ranges.
fix
For older versions, ensure `datetime.datetime` objects are consistently used. For v1.0.0+, while strings offer flexibility, use `datetime.datetime` objects for precise control over start and end dates in date ranges to avoid ambiguity.
affects: <1.0.0
breakingThe `display` argument in search functions (e.g., `search_indicator`, `search_country`) was removed in v0.3.0. These functions now return lists that pretty-print as tables when directly expressed in a shell or notebook.
fix
Remove the `display` argument from calls to search functions. Handle the returned list directly; its `__repr__` method provides the tabular display in interactive environments.
affects: <0.3.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'wbdata'
The 'wbdata' library has not been installed in the current Python environment.
fix
Install the library using pip: `pip install wbdata`
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: ...
The World Bank API returned an error, often due to invalid or malformed parameters provided in the `wbdata` function call (e.g., incorrect indicator code, country code, or an unsupported combination).
fix
Verify the accuracy of indicator codes, country codes, and date ranges using `wbdata.get_indicators()`, `wbdata.get_countries()`, etc., and ensure they conform to World Bank API requirements.
TypeError: cannot unpack non-iterable str object
The `date` argument in `wbdata.get_dataframe()` or similar functions was provided as a single string (e.g., "2010") when it expects an iterable like a tuple `(start_year, end_year)` or a list of specific years `[year1, year2]`.
fix
Provide the date as a tuple for a range or a list for specific years, e.g., `date=(2010, 2010)` for a single year, or `date=[2010, 2011]`.
AttributeError: module 'wbdata' has no attribute 'get_dataframes'
A common typo was made in the function name `get_dataframe` by adding an 's' at the end, or an attempt was made to call a non-existent method.
fix
Correct the function name to `wbdata.get_dataframe()`.
Upgrade
Version history
1.1.0latest on PyPI · released Oct 5, 2025
Audit
Dependencies
pandasrequiredFor returning data as Pandas DataFrames, which is a common and highly recommended use case.
requestsrequiredUnderpins HTTP requests to the World Bank API.
cachetoolsrequiredProvides in-memory caching of API responses to improve performance and reduce redundant calls.
Agent activity
37 hits · last 30 days
node
31
Amazon
1
OpenAI (training)
1
Resources
wbdata — pip install wbdata · libregistry