Fetch Debt Statistics from the World Bank International Debt Statistics API
Source:R/ids_get.R
ids_get.Rd
This function returns a tibble with debt statistics data fetched from the World Bank International Debt Statistics (IDS) API. The data can be filtered by geographies, series, counterparts, and time periods.
Usage
ids_get(
geographies,
series,
counterparts = "all",
start_date = NULL,
end_date = NULL,
progress = FALSE
)
Arguments
- geographies
A character vector representing the geographic codes (e.g., "ZMB" for Zambia). This argument is required and cannot contain NA values.
- series
A character vector representing the series codes (e.g., "DT.DOD.DPPG.CD"). This argument is required and cannot contain NA values.
- counterparts
A character vector representing counterpart areas (e.g., "all", "001"). This argument is required and cannot contain NA values (default: "all").
- start_date
An optional numeric value representing the starting year (e.g., 2015). It must be greater than or equal to 1970. If not provided, the entire time range is used.
- end_date
An optional numeric value representing the ending year (e.g., 2020). It must be greater than or equal to 1970 and cannot be earlier than
start_date
. If not provided, the entire available time range is used.- progress
A logical value indicating whether to display a progress message during the request process (default:
FALSE
). Must be eitherTRUE
orFALSE
.
Value
A tibble containing debt statistics with the following columns:
- geography_id
The unique identifier for the geography (e.g., "ZMB").
- series_id
The unique identifier for the series (e.g., "DT.DOD.DPPG.CD").
- counterpart_id
The unique identifier for the counterpart (e.g., "all").
- year
The year corresponding to the data (e.g., 2020).
- value
The numeric value representing the statistic for the given geography, series, counterpart, and year.
Examples
# \donttest{
# Fetch data for a series without specifying a time range or counterpart
ids_get(
geographies = "ZMB",
series = "DT.DOD.DPPG.CD",
)
#> # A tibble: 18,483 × 5
#> geography_id series_id counterpart_id year value
#> <chr> <chr> <chr> <int> <dbl>
#> 1 ZMB DT.DOD.DPPG.CD 265 1970 19822458.
#> 2 ZMB DT.DOD.DPPG.CD 288 1970 NA
#> 3 ZMB DT.DOD.DPPG.CD 063 1970 NA
#> 4 ZMB DT.DOD.DPPG.CD 580 1970 NA
#> 5 ZMB DT.DOD.DPPG.CD 019 1970 NA
#> 6 ZMB DT.DOD.DPPG.CD 931 1970 NA
#> 7 ZMB DT.DOD.DPPG.CD 902 1970 NA
#> 8 ZMB DT.DOD.DPPG.CD 905 1970 NA
#> 9 ZMB DT.DOD.DPPG.CD 901 1970 61433000
#> 10 ZMB DT.DOD.DPPG.CD WLD 1970 623521836.
#> # ℹ 18,473 more rows
# Fetch specific debt statistics for Zambia from 2015 to 2020
ids_get(
geographies = "ZMB",
series = c("DT.DOD.DPPG.CD", "BM.GSR.TOTL.CD"),
start_date = 2015,
end_date = 2020
)
#> # A tibble: 3,636 × 5
#> geography_id series_id counterpart_id year value
#> <chr> <chr> <chr> <int> <dbl>
#> 1 ZMB BM.GSR.TOTL.CD 265 2015 NA
#> 2 ZMB BM.GSR.TOTL.CD 288 2015 NA
#> 3 ZMB BM.GSR.TOTL.CD 063 2015 NA
#> 4 ZMB BM.GSR.TOTL.CD 580 2015 NA
#> 5 ZMB BM.GSR.TOTL.CD 019 2015 NA
#> 6 ZMB BM.GSR.TOTL.CD 931 2015 NA
#> 7 ZMB BM.GSR.TOTL.CD 902 2015 NA
#> 8 ZMB BM.GSR.TOTL.CD 905 2015 NA
#> 9 ZMB BM.GSR.TOTL.CD 901 2015 NA
#> 10 ZMB BM.GSR.TOTL.CD WLD 2015 9225953069.
#> # ℹ 3,626 more rows
# Fetch data for specific counterparts
ids_get(
geographies = "ZMB",
series = "DT.DOD.DPPG.CD",
counterparts = c("216", "231")
)
#> # A tibble: 122 × 5
#> geography_id series_id counterpart_id year value
#> <chr> <chr> <chr> <int> <dbl>
#> 1 ZMB DT.DOD.DPPG.CD 216 1970 NA
#> 2 ZMB DT.DOD.DPPG.CD 216 1971 NA
#> 3 ZMB DT.DOD.DPPG.CD 216 1972 NA
#> 4 ZMB DT.DOD.DPPG.CD 216 1973 4842338.
#> 5 ZMB DT.DOD.DPPG.CD 216 1974 4241396.
#> 6 ZMB DT.DOD.DPPG.CD 216 1975 2616250
#> 7 ZMB DT.DOD.DPPG.CD 216 1976 1868750
#> 8 ZMB DT.DOD.DPPG.CD 216 1977 1121250
#> 9 ZMB DT.DOD.DPPG.CD 216 1978 1121250
#> 10 ZMB DT.DOD.DPPG.CD 216 1979 1179165
#> # ℹ 112 more rows
# Fetch data for multiple geographies and counterparts
ids_get(
geographies = c("ZMB", "CHN"),
series = "DT.DOD.DPPG.CD",
counterparts = c("216", "231"),
start_date = 2019,
end_date = 2020
)
#> # A tibble: 8 × 5
#> geography_id series_id counterpart_id year value
#> <chr> <chr> <chr> <int> <dbl>
#> 1 CHN DT.DOD.DPPG.CD 216 2019 NA
#> 2 CHN DT.DOD.DPPG.CD 216 2020 NA
#> 3 CHN DT.DOD.DPPG.CD 231 2019 NA
#> 4 CHN DT.DOD.DPPG.CD 231 2020 NA
#> 5 ZMB DT.DOD.DPPG.CD 216 2019 279060000
#> 6 ZMB DT.DOD.DPPG.CD 216 2020 271878000
#> 7 ZMB DT.DOD.DPPG.CD 231 2019 NA
#> 8 ZMB DT.DOD.DPPG.CD 231 2020 NA
# }