| Title: | Client for the 'World Bank' APIs |
|---|---|
| Description: | Download and search data from the 'World Bank' APIs, including the 'Indicators' API, the 'Poverty and Inequality Platform (PIP)' API, the 'Finances One' API, and the 'Projects' API. See <https://datahelpdesk.worldbank.org/knowledgebase/articles/889386-developer-information-overview> for further details. |
| Authors: | Maximilian Mücke [aut, cre] (ORCID: <https://orcid.org/0009-0000-9432-9795>) |
| Maintainer: | Maximilian Mücke <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.9.0.9000 |
| Built: | 2026-06-02 10:24:04 UTC |
| Source: | https://github.com/m-muecke/worldbank |
wb_cache_dir() returns the path where cached API responses are stored.
wb_cache_clear() clears all cached responses.
wb_cache_dir() wb_cache_clear() wb_cache_delete()wb_cache_dir() wb_cache_clear() wb_cache_delete()
The cache is only used when enabled with options(worldbank.cache = TRUE).
Cached responses are stored for 1 day by default, but this can be customized with
options(worldbank.cache_max_age = seconds).
## Not run: # enable caching options(worldbank.cache = TRUE) # view cache location wb_cache_dir() # clear the cache wb_cache_clear() ## End(Not run)## Not run: # enable caching options(worldbank.cache = TRUE) # view cache location wb_cache_dir() # clear the cache wb_cache_clear() ## End(Not run)
Return Finances One API data
fone_dataset(dataset_id, resource_id, ..., limit = NULL) fone_view(view_id, ..., limit = NULL)fone_dataset(dataset_id, resource_id, ..., limit = NULL) fone_view(view_id, ..., limit = NULL)
dataset_id |
( |
resource_id |
( |
... |
( |
limit |
( |
view_id |
( |
A data.frame() with the requested dataset.
https://financesone.worldbank.org/data
## Not run: # get dataset data dataset <- fone_dataset(dataset_id = "DS00047", resource_id = "RS00005") head(dataset) # get view data view <- fone_view(view_id = "DS01538") head(view) ## End(Not run)## Not run: # get dataset data dataset <- fone_dataset(dataset_id = "DS00047", resource_id = "RS00005") head(dataset) # get view data view <- fone_view(view_id = "DS01538") head(view) ## End(Not run)
Return auxiliary data tables
pip_aux( table = NULL, release_version = NULL, ppp_version = NULL, version = NULL )pip_aux( table = NULL, release_version = NULL, ppp_version = NULL, version = NULL )
table |
( |
release_version |
( |
ppp_version |
( |
version |
( |
A character() with the available tables, or a data.frame() with the table data.
Other poverty and inequality statistics:
pip_citation(),
pip_cp(),
pip_data(),
pip_group(),
pip_health_check(),
pip_info(),
pip_valid_params(),
pip_versions()
# get a list of available tables pip_aux() # get countries aux <- pip_aux("countries") head(aux) # get GDP aux <- pip_aux("gdp") head(aux) # get CPI aux <- pip_aux("cpi") head(aux)# get a list of available tables pip_aux() # get countries aux <- pip_aux("countries") head(aux) # get GDP aux <- pip_aux("gdp") head(aux) # get CPI aux <- pip_aux("cpi") head(aux)
Return citation for a given version
pip_citation(release_version = NULL, ppp_version = NULL, version = NULL)pip_citation(release_version = NULL, ppp_version = NULL, version = NULL)
release_version |
( |
ppp_version |
( |
version |
( |
A data.frame() with the citation.
Other poverty and inequality statistics:
pip_aux(),
pip_cp(),
pip_data(),
pip_group(),
pip_health_check(),
pip_info(),
pip_valid_params(),
pip_versions()
pip_citation()pip_citation()
Return country profile data
pip_cp( country = NULL, povline = 2.15, release_version = NULL, ppp_version = NULL, version = NULL )pip_cp( country = NULL, povline = 2.15, release_version = NULL, ppp_version = NULL, version = NULL )
country |
( |
povline |
( |
release_version |
( |
ppp_version |
( |
version |
( |
A data.frame() with country profile statistics including headcount ratios, inequality
measures, and demographic breakdowns.
Other poverty and inequality statistics:
pip_aux(),
pip_citation(),
pip_data(),
pip_group(),
pip_health_check(),
pip_info(),
pip_valid_params(),
pip_versions()
cp <- pip_cp("ZAF") head(cp)cp <- pip_cp("ZAF") head(cp)
Return main poverty and inequality statistics
pip_data( country = NULL, year = NULL, povline = 2.15, popshare = NULL, fill_gaps = FALSE, nowcast = FALSE, welfare_type = c("all", "consumption", "income"), reporting_level = c("all", "national", "rural", "urban"), additional_ind = FALSE, release_version = NULL, ppp_version = NULL, version = NULL )pip_data( country = NULL, year = NULL, povline = 2.15, popshare = NULL, fill_gaps = FALSE, nowcast = FALSE, welfare_type = c("all", "consumption", "income"), reporting_level = c("all", "national", "rural", "urban"), additional_ind = FALSE, release_version = NULL, ppp_version = NULL, version = NULL )
country |
( |
year |
( |
povline |
( |
popshare |
( |
fill_gaps |
( |
nowcast |
( |
welfare_type |
( |
reporting_level |
( |
additional_ind |
( |
release_version |
( |
ppp_version |
( |
version |
( |
A data.frame() with the requested statistics.
Other poverty and inequality statistics:
pip_aux(),
pip_citation(),
pip_cp(),
pip_group(),
pip_health_check(),
pip_info(),
pip_valid_params(),
pip_versions()
data <- pip_data(c("ZAF", "ZMB")) head(data)data <- pip_data(c("ZAF", "ZMB")) head(data)
Return aggregation of PIP statistics
pip_group( country = NULL, year = NULL, povline = 2.15, popshare = NULL, group_by = c("wb", "none"), fill_gaps = FALSE, welfare_type = c("all", "consumption", "income"), reporting_level = c("all", "national", "rural", "urban"), additional_ind = FALSE, release_version = NULL, ppp_version = NULL, version = NULL )pip_group( country = NULL, year = NULL, povline = 2.15, popshare = NULL, group_by = c("wb", "none"), fill_gaps = FALSE, welfare_type = c("all", "consumption", "income"), reporting_level = c("all", "national", "rural", "urban"), additional_ind = FALSE, release_version = NULL, ppp_version = NULL, version = NULL )
country |
( |
year |
( |
povline |
( |
popshare |
( |
group_by |
( |
fill_gaps |
( |
welfare_type |
( |
reporting_level |
( |
additional_ind |
( |
release_version |
( |
ppp_version |
( |
version |
( |
A data.frame() with the requested statistics.
Other poverty and inequality statistics:
pip_aux(),
pip_citation(),
pip_cp(),
pip_data(),
pip_health_check(),
pip_info(),
pip_valid_params(),
pip_versions()
grp <- pip_group(c("AFE", "LAC")) head(grp)grp <- pip_group(c("AFE", "LAC")) head(grp)
Determine if the API is running and listening as expected
pip_health_check()pip_health_check()
A character(1) with the health check message.
Other poverty and inequality statistics:
pip_aux(),
pip_citation(),
pip_cp(),
pip_data(),
pip_group(),
pip_info(),
pip_valid_params(),
pip_versions()
pip_health_check()pip_health_check()
Return information about the API
pip_info()pip_info()
A list() with the API information.
Other poverty and inequality statistics:
pip_aux(),
pip_citation(),
pip_cp(),
pip_data(),
pip_group(),
pip_health_check(),
pip_valid_params(),
pip_versions()
pip_info()pip_info()
Return valid query parameters
pip_valid_params( endpoint = c("all", "aux", "pip", "pip-grp", "pip-info", "valid-params"), release_version = NULL, ppp_version = NULL, version = NULL )pip_valid_params( endpoint = c("all", "aux", "pip", "pip-grp", "pip-info", "valid-params"), release_version = NULL, ppp_version = NULL, version = NULL )
endpoint |
( |
release_version |
( |
ppp_version |
( |
version |
( |
A data.frame() with the valid parameters.
Other poverty and inequality statistics:
pip_aux(),
pip_citation(),
pip_cp(),
pip_data(),
pip_group(),
pip_health_check(),
pip_info(),
pip_versions()
params <- pip_valid_params() head(params)params <- pip_valid_params() head(params)
Return the available data versions
pip_versions()pip_versions()
A data.frame() with the available versions.
Other poverty and inequality statistics:
pip_aux(),
pip_citation(),
pip_cp(),
pip_data(),
pip_group(),
pip_health_check(),
pip_info(),
pip_valid_params()
vers <- pip_versions() head(vers)vers <- pip_versions() head(vers)
Download the entire World Development Indicators dataset as a single zip and return its
contents as a list of data frames. Useful for full-dataset analyses where paginating
through wb_data() would be slow, and for accessing footnote and series-time metadata
that the API does not expose.
wb_bulk(timeout = 600L)wb_bulk(timeout = 600L)
timeout |
( |
The download is roughly 280 MB compressed and may take a minute or more.
A named list() of data.frame()s:
data: indicator values in long format with columns country_name, country_code,
indicator_name, indicator_code, year, value.
country: country metadata.
series: series (indicator) metadata.
country_series: country-series-specific notes.
series_time: series-year-specific notes.
footnote: footnotes per country, series, and year.
https://databankfiles.worldbank.org/public/ddpext_download/WDI_CSV.zip
Other indicators data:
wb_country(),
wb_data(),
wb_income_level(),
wb_indicator(),
wb_language(),
wb_lending_type(),
wb_region(),
wb_search(),
wb_source(),
wb_topic()
## Not run: wdi <- wb_bulk() head(wdi$data) ## End(Not run)## Not run: wdi <- wb_bulk() head(wdi$data) ## End(Not run)
List all countries supported by the World Bank API.
wb_country(country = NULL, lang = "en")wb_country(country = NULL, lang = "en")
country |
( |
lang |
( |
A data.frame() with the available countries. The columns are:
country_id: The country ID.
country_code: The country code.
country_name: The country name.
region_id: The region ID.
region_code: The region code.
region_value: The region value.
admin_region_id: The admin region ID.
admin_region_code: The admin region code.
admin_region_value: The admin region value.
income_level_id: The income level ID.
income_level_code: The income level code.
income_level_value: The income level value.
lending_type_id: The lending type ID.
lending_type_code: The lending type code.
lending_type_value: The lending type value.
capital_city: The capital city.
longitude: The longitude.
latitude: The latitude.
https://api.worldbank.org/v2/country
Other indicators data:
wb_bulk(),
wb_data(),
wb_income_level(),
wb_indicator(),
wb_language(),
wb_lending_type(),
wb_region(),
wb_search(),
wb_source(),
wb_topic()
country <- wb_country() head(country)country <- wb_country() head(country)
List all country indicators supported by the World Bank API.
wb_data( indicator = "NY.GDP.MKTP.CD", country = NULL, lang = "en", start_date = NULL, end_date = NULL, mrv = NULL, gapfill = FALSE ) wb_country_indicator( indicator = "NY.GDP.MKTP.CD", country = NULL, lang = "en", start_date = NULL, end_date = NULL, mrv = NULL, gapfill = FALSE )wb_data( indicator = "NY.GDP.MKTP.CD", country = NULL, lang = "en", start_date = NULL, end_date = NULL, mrv = NULL, gapfill = FALSE ) wb_country_indicator( indicator = "NY.GDP.MKTP.CD", country = NULL, lang = "en", start_date = NULL, end_date = NULL, mrv = NULL, gapfill = FALSE )
indicator |
( |
country |
( |
lang |
( |
start_date |
(
|
end_date |
( |
mrv |
( |
gapfill |
( |
A data.frame() with the available country indicators.
The columns are:
date: The date
indicator_id: The indicator ID.
indicator_name: The indicator name.
country_id: The country ID.
country_name: The country name.
country_code: The country code.
value: The indicator value.
unit: The indicator unit.
obs_status: The observation status.
decimal: The decimal.
https://api.worldbank.org/v2/country/{country}/indicator/{indicator}
Other indicators data:
wb_bulk(),
wb_country(),
wb_income_level(),
wb_indicator(),
wb_language(),
wb_lending_type(),
wb_region(),
wb_search(),
wb_source(),
wb_topic()
# single indicator for a single country (all available years) ind <- wb_data("NY.GDP.MKTP.CD", "US") head(ind) # multiple indicators for multiple countries (2015-2023) ind <- wb_data( indicator = c("NY.GDP.MKTP.CD", "FP.CPI.TOTL.ZG"), country = c("US", "DE", "FR", "CH", "JP"), start_date = 2015, end_date = 2023 ) head(ind)# single indicator for a single country (all available years) ind <- wb_data("NY.GDP.MKTP.CD", "US") head(ind) # multiple indicators for multiple countries (2015-2023) ind <- wb_data( indicator = c("NY.GDP.MKTP.CD", "FP.CPI.TOTL.ZG"), country = c("US", "DE", "FR", "CH", "JP"), start_date = 2015, end_date = 2023 ) head(ind)
List all income levels supported by the World Bank API.
wb_income_level(income = NULL, lang = "en")wb_income_level(income = NULL, lang = "en")
income |
( |
lang |
( |
A data.frame() with the available income levels. The columns are:
id: The income level ID.
iso2code: The ISO 2 code of the income level.
value: The income level value.
https://api.worldbank.org/v2/incomeLevels
Other indicators data:
wb_bulk(),
wb_country(),
wb_data(),
wb_indicator(),
wb_language(),
wb_lending_type(),
wb_region(),
wb_search(),
wb_source(),
wb_topic()
wb_income_level()wb_income_level()
List all indicators supported by the World Bank API.
wb_indicator(indicator = NULL, lang = "en")wb_indicator(indicator = NULL, lang = "en")
indicator |
( |
lang |
( |
A data.frame() with the available indicators. The columns are:
id: The indicator ID.
name: The indicator name.
unit: The indicator unit.
source_id: The source ID.
source_value: The source value.
source_note: The source note.
source_organization: The source organization.
topic_id: The topic ID.
topic_value: The topic value.
https://api.worldbank.org/v2/indicator
Other indicators data:
wb_bulk(),
wb_country(),
wb_data(),
wb_income_level(),
wb_language(),
wb_lending_type(),
wb_region(),
wb_search(),
wb_source(),
wb_topic()
wb_indicator("NY.GDP.MKTP.CD")wb_indicator("NY.GDP.MKTP.CD")
List all languages supported by the World Bank API.
wb_language()wb_language()
A data.frame() with the available languages. The columns are:
code: The language code.
name: The language name.
native_form: The native form of the language name.
https://api.worldbank.org/v2/languages
Other indicators data:
wb_bulk(),
wb_country(),
wb_data(),
wb_income_level(),
wb_indicator(),
wb_lending_type(),
wb_region(),
wb_search(),
wb_source(),
wb_topic()
wb_language()wb_language()
List all lending types supported by the World Bank API.
wb_lending_type(type = NULL, lang = "en")wb_lending_type(type = NULL, lang = "en")
type |
( |
lang |
( |
A data.frame() with the available lending types. The columns are:
id: The lending type ID.
iso2code: The ISO 2 code of the lending type.
value: The lending type value.
https://api.worldbank.org/v2/lendingTypes
Other indicators data:
wb_bulk(),
wb_country(),
wb_data(),
wb_income_level(),
wb_indicator(),
wb_language(),
wb_region(),
wb_search(),
wb_source(),
wb_topic()
wb_lending_type()wb_lending_type()
Query World Bank project data from the Projects API.
wb_project( id = NULL, country = NULL, status = NULL, region = NULL, search = NULL, start_date = NULL, end_date = NULL )wb_project( id = NULL, country = NULL, status = NULL, region = NULL, search = NULL, start_date = NULL, end_date = NULL )
id |
( |
country |
( |
status |
( |
region |
( |
search |
( |
start_date |
( |
end_date |
( |
A data.frame() with World Bank project data. The columns are:
id: The project ID.
project_name: The project name.
status: The project status.
approval_date: The board approval date.
closing_date: The closing date.
country_code: The ISO country code.
country: The country name.
region: The region name.
total_commitment: The total commitment amount in millions USD.
ibrd_commitment: The IBRD commitment amount in millions USD.
ida_commitment: The IDA commitment amount in millions USD.
lending_instrument: The lending instrument type.
borrower: The borrower name.
implementing_agency: The implementing agency name.
url: The project URL.
https://search.worldbank.org/api/v2/projects
# active projects in Brazil related to education wb_project(country = "BR", status = "Active", search = "education") # look up a specific project wb_project(id = "P163868")# active projects in Brazil related to education wb_project(country = "BR", status = "Active", search = "education") # look up a specific project wb_project(id = "P163868")
List all regions supported by the World Bank API.
wb_region(region = NULL, lang = "en")wb_region(region = NULL, lang = "en")
region |
( |
lang |
( |
A data.frame() with the available regions. The columns are:
id: The region ID.
code: The region code.
iso2code: The ISO 2 code of the region.
name: The region name.
https://api.worldbank.org/v2/region
Other indicators data:
wb_bulk(),
wb_country(),
wb_data(),
wb_income_level(),
wb_indicator(),
wb_language(),
wb_lending_type(),
wb_search(),
wb_source(),
wb_topic()
region <- wb_region() head(region)region <- wb_region() head(region)
Search the indicator catalog returned by wb_indicator() for a regular expression
pattern across one or more text fields. By default the match is case insensitive.
wb_search( pattern, fields = c("id", "name", "source_note"), catalog = NULL, lang = "en", ignore.case = TRUE, ... )wb_search( pattern, fields = c("id", "name", "source_note"), catalog = NULL, lang = "en", ignore.case = TRUE, ... )
pattern |
( |
fields |
( |
catalog |
( |
lang |
( |
ignore.case |
( |
... |
( |
A data.frame() with the matching rows of the indicator catalog.
https://api.worldbank.org/v2/indicator
Other indicators data:
wb_bulk(),
wb_country(),
wb_data(),
wb_income_level(),
wb_indicator(),
wb_language(),
wb_lending_type(),
wb_region(),
wb_source(),
wb_topic()
# search for indicators related to GDP wb_search("GDP") # restrict the search to the indicator name wb_search("unemployment", fields = "name") # case-sensitive fixed-string match wb_search("GDP", ignore.case = FALSE, fixed = TRUE)# search for indicators related to GDP wb_search("GDP") # restrict the search to the indicator name wb_search("unemployment", fields = "name") # case-sensitive fixed-string match wb_search("GDP", ignore.case = FALSE, fixed = TRUE)
List all sources supported by the World Bank API.
wb_source(source = NULL, lang = "en")wb_source(source = NULL, lang = "en")
source |
( |
lang |
( |
A data.frame() with the available sources. The columns are:
id: The source ID.
last_updated: The date the source was last updated.
name: The source name.
code: The source code.
description: The source description.
url: The source URL.
data_availability: Whether the source has data available.
metadata_availability: Whether the source has metadata available.
concepts: The concepts associated with the source.
https://api.worldbank.org/v2/sources
Other indicators data:
wb_bulk(),
wb_country(),
wb_data(),
wb_income_level(),
wb_indicator(),
wb_language(),
wb_lending_type(),
wb_region(),
wb_search(),
wb_topic()
src <- wb_source() head(src)src <- wb_source() head(src)
List all topics supported by the World Bank API.
wb_topic(topic = NULL, lang = "en")wb_topic(topic = NULL, lang = "en")
topic |
( |
lang |
( |
A data.frame() with the available topics. The columns are:
id: The topic ID.
value: The topic value.
source_note: The source note.
https://api.worldbank.org/v2/topics
Other indicators data:
wb_bulk(),
wb_country(),
wb_data(),
wb_income_level(),
wb_indicator(),
wb_language(),
wb_lending_type(),
wb_region(),
wb_search(),
wb_source()
topic <- wb_topic() head(topic)topic <- wb_topic() head(topic)