wb_data: World Bank country indicator data

View source: R/indicators.R

wb_dataR Documentation

World Bank country indicator data

Description

List all country indicators supported by the World Bank API.

Usage

wb_data(
  indicator = "NY.GDP.MKTP.CD",
  country = NULL,
  lang = "en",
  start_date = NULL,
  end_date = NULL,
  mrv = NULL,
  gapfill = FALSE,
  footnote = FALSE
)

wb_country_indicator(
  indicator = "NY.GDP.MKTP.CD",
  country = NULL,
  lang = "en",
  start_date = NULL,
  end_date = NULL,
  mrv = NULL,
  gapfill = FALSE,
  footnote = FALSE
)

Arguments

indicator

(character())
Indicators to query.

country

(NULL | character())
Countries to query. Default NULL. If NULL, all countries are returned.

lang

(character(1))
Language to query. Default "en".

start_date

(NULL | character(1) | integer(1))
Start date to query. Default NULL. Supported formats:

  • YYYY for yearly data (e.g. 2020 or "2020")

  • YYYYQ[1-4] for quarterly data (e.g. "2020Q1")

  • YYYYM[1-12] for monthly data (e.g. "2020M02")

end_date

(NULL | character(1) | integer(1))
End date to query, in the same format as start_date. Default NULL.

mrv

(NULL | integer(1))
Most recent values to return. An alternative to start_date/end_date. Default NULL.

gapfill

(logical(1))
Whether to fill missing values by carrying forward the last available value. Only used when mrv is set. Default FALSE.

footnote

(logical(1))
Whether to return the footnotes published alongside the observations, such as uncertainty bounds or the survey a figure was derived from. Default FALSE.

Value

A data.frame() with the available country indicators. The columns are:

  • date: The date. An integer if all observations are annual, otherwise a character vector.

  • 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.

  • footnote: The observation footnote, or NA if there is none. Only present when footnote = TRUE.

Source

https://api.worldbank.org/v2/country/{country}/indicator/{indicator}

See Also

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()

Examples



# 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)

# include the per-observation footnotes
ind <- wb_data("SI.POV.DDAY", "ALB", footnote = TRUE)
head(ind[c("date", "value", "footnote")])



worldbank documentation built on Aug. 21, 2026, 9:07 a.m.