ThePeruAPIs package provides a unified interface toaccess open data from theWorld Bank API,Nager.Date API, and theREST CountriesAPI, with a focus onPeru. It allows users toretrieve up-to-date or historical information on topics such as economicindicators, demographics, national holidays, and key geopoliticaldetails.
In addition to API-access functions, the package includes a curatedcollection of open datasets related toPeru. Thesedatasets cover a wide range of topics including administrativedivisions, electoral data, demographics, biodiversity and educationalclassifications.
You can install thePeruAPIs package from CRAN with thefollowing R function:
install.packages("PeruAPIs")After installation, load the package and start exploring and usingits functions and datasets.
library(PeruAPIs)get_peru_child_mortality(): Get Peru’s Under-5Mortality Rate data from the World Bank.
get_peru_cpi(): Get Peru’s Consumer Price Index(2010 = 100) data from the World Bank.
get_peru_energy_use(): Get Peru’s Energy Use (kg ofoil equivalent per capita) data from the World Bank.
get_peru_gdp(): Get Peru’s GDP (current US$) datafrom the World Bank.
get_peru_holidays(): Get official public holidays inPeru for a given year, e.g.,get_peru_holidays(2025).
get_peru_hospital_beds(): Get Peru’s Hospital Beds(per 1,000 people) data from the World Bank.
get_peru_literacy_rate(): Get Peru’s Adult LiteracyRate data from the World Bank.
get_peru_life_expectancy(): Get Peru’s LifeExpectancy at Birth data from the World Bank.
get_peru_population(): Get Peru’s Total Populationdata from the World Bank.
get_peru_unemployment(): Get Peru’s TotalUnemployment Rate data from the World Bank.
get_country_info_pe(): Get key country informationfor Peru.
view_datasets_PeruAPIs(): View available curateddatasets included in PeruAPIs.
Each dataset inPeruAPIs is labeled with asuffix to indicate its structure and type:
_df: A standard data frame.
_tbl_df: A tibble data frame object.
In addition to API access functions,PeruAPIs provides acurated collection of open datasets focused onPeru.
Below are some featured examples:
andean_migrants_health_df: A data framecontaining health data from a random sample of Peruvians born in theAndes mountains, but who have since migrated to loweraltitudes.
birds_peru_tbl_df: A tibble containing anupdated list of bird species recorded in Peru, based on the most recenttaxonomic revisions by the South American.
# Load the packagelibrary(PeruAPIs)# Retrieves essential information about Peruget_country_info_pe()# Get Peru's Population (Total) from World Bankget_peru_population()# Load a datasetdata(birds_peru_tbl_df)# Shows six rows of the datasethead(birds_peru_tbl_df)# Display the structure of the datasetstr(birds_peru_tbl_df)# Shows the whole datasetView(birds_peru_tbl_df)# Display all the datasets within PeruAPIs packageview_datasets_PeruAPIs()