| Title: | Access Peruvian Data via Public APIs and Curated Datasets |
|---|---|
| Description: | Provides functions to access data from public RESTful APIs including 'Nager.Date', 'World Bank API', and 'REST Countries API', retrieving real-time or historical data related to Peru, such as holidays, economic indicators, and international demographic and geopolitical indicators. Additionally, the package includes curated datasets focused on Peru, covering topics such as administrative divisions, electoral data, demographics, biodiversity and educational classifications. The package supports reproducible research and teaching by integrating reliable international APIs and structured datasets from public, academic, and government sources. For more information on the APIs, see: 'Nager.Date' <https://date.nager.at/Api>, 'World Bank API' <https://datahelpdesk.worldbank.org/knowledgebase/articles/889392>, and 'REST Countries API' <https://restcountries.com/>. |
| Authors: | Renzo Caceres Rossi [aut, cre] (ORCID: <https://orcid.org/0009-0005-0744-854X>) |
| Maintainer: | Renzo Caceres Rossi <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-14 06:38:36 UTC |
| Source: | https://github.com/lightbluetitan/peruapis |
This dataset, andean_migrants_health_df, is a data frame containing health data from a random sample of Peruvians born in the Andes mountains, but who have since migrated to lower altitudes. The sample was collected to assess the long-term effects of altitude on blood pressure and other health indicators, providing valuable insights into the physiological adaptations of high-altitude populations.
data(andean_migrants_health_df)data(andean_migrants_health_df)
A data frame with 39 observations and 5 variables:
Age of the subject (integer)
Years since migration to lower altitude (integer)
Weight of the subject (numeric)
Height of the subject (integer)
Blood pressure measurement (integer)
The dataset name has been kept as 'andean_migrants_health_df' to avoid confusion with other datasets in the R ecosystem. This naming convention helps distinguish this dataset as part of the PeruAPIs package and assists users in identifying its specific characteristics. The suffix 'df' indicates that the dataset is a data frame object. The original content has not been modified in any way.
Data taken from the s20x package version 3.1-40
This dataset, birds_peru_tbl_df, is a tibble containing an updated list of bird species recorded in Peru, based on the most recent taxonomic revisions by the South American Checklist Committee (SACC). It provides comprehensive information about avian biodiversity in Peru, including taxonomic classification, common names in English and Spanish, and conservation status for each species.
data(birds_peru_tbl_df)data(birds_peru_tbl_df)
A tibble with 1,914 observations and 6 variables:
Taxonomic order of the bird species (character)
Taxonomic family of the bird species (character)
Scientific name of the bird species (character)
Common name in English (character)
Common name in Spanish (character)
Conservation or taxonomic status of the species (character)
The dataset name has been kept as 'birds_peru_tbl_df' to avoid confusion with other datasets in the R ecosystem. This naming convention helps distinguish this dataset as part of the PeruAPIs package and assists users in identifying its specific characteristics. The suffix 'tbl_df' indicates that the dataset is a tibble object. The original content has not been modified in any way.
Data taken from the avesperu package version 0.0.6
Retrieves comprehensive country information for Peru from the REST Countries API. This function fetches data including official and common names, geographical information, capital, area, population, and languages.
get_country_info_pe()get_country_info_pe()
This function makes a request to the REST Countries API v3.1 endpoint specifically for Peru using full text search. It handles API errors gracefully and returns NULL if the request fails or no data is found.
A tibble with one row containing Peru's country information:
Common name of the country
Official name of the country
Geographic region
Geographic subregion
Capital city(ies)
Total area in square kilometers
Total population
Languages spoken (comma-separated)
# Get Peru information pe_info <- get_country_info_pe() print(pe_info)# Get Peru information pe_info <- get_country_info_pe() print(pe_info)
Retrieves Peru's under-5 mortality rate, measured as the number of deaths
of children under five years of age per 1,000 live births, for the years 2010 to 2022
using the World Bank Open Data API. The indicator used is SH.DYN.MORT.
get_peru_child_mortality()get_peru_child_mortality()
This function sends a GET request to the World Bank API.
If the API request fails or returns an error status code,
the function returns NULL with an informative message.
A tibble with the following columns:
indicator: Indicator name (e.g., "Mortality rate, under-5 (per 1,000 live births)")
country: Country name ("Peru")
year: Year of the data (integer)
value: Mortality rate (per 1,000 live births)
Requires internet connection.
World Bank Open Data API: https://data.worldbank.org/indicator/SH.DYN.MORT
if (interactive()) { get_peru_child_mortality() }if (interactive()) { get_peru_child_mortality() }
Retrieves Peru's Consumer Price Index (CPI), with 2010 as the base year (index = 100),
for the years 2010 to 2022 using the World Bank Open Data API.
The indicator used is FP.CPI.TOTL.
get_peru_cpi()get_peru_cpi()
This function sends a GET request to the World Bank API.
If the API request fails or returns an error status code,
the function returns NULL with an informative message.
A tibble with the following columns:
indicator: Indicator name (e.g., "Consumer price index (2010 = 100)")
country: Country name ("Peru")
year: Year of the data (integer)
value: Consumer Price Index (numeric, base year 2010 = 100)
Requires internet connection.
World Bank Open Data API: https://data.worldbank.org/indicator/FP.CPI.TOTL
if (interactive()) { get_peru_cpi() }if (interactive()) { get_peru_cpi() }
Retrieves Peru's energy use per capita, measured in kilograms of oil equivalent,
for the years 2010 to 2022 using the World Bank Open Data API.
The indicator used is EG.USE.PCAP.KG.OE.
get_peru_energy_use()get_peru_energy_use()
This function sends a GET request to the World Bank API.
If the API request fails or returns an error status code,
the function returns NULL with an informative message.
A tibble with the following columns:
indicator: Indicator name (e.g., "Energy use (kg of oil equivalent per capita)")
country: Country name ("Peru")
year: Year of the data (integer)
value: Energy use in kilograms of oil equivalent per capita
Requires internet connection.
World Bank Open Data API: https://data.worldbank.org/indicator/EG.USE.PCAP.KG.OE
if (interactive()) { get_peru_energy_use() }if (interactive()) { get_peru_energy_use() }
Retrieves Peru's Gross Domestic Product (GDP) in current US dollars
for the years 2010 to 2022 using the World Bank Open Data API.
The indicator used is NY.GDP.MKTP.CD.
get_peru_gdp()get_peru_gdp()
This function sends a GET request to the World Bank API.
If the API request fails or returns an error status code,
the function returns NULL with an informative message.
A tibble with the following columns:
indicator: Indicator name (e.g., "GDP (current US$)")
country: Country name ("Peru")
year: Year of the data (integer)
value: GDP in current US dollars
value_label: Formatted GDP with commas (e.g., "1,800,000,000,000")
Requires internet connection.
World Bank Open Data API: https://data.worldbank.org/indicator/NY.GDP.MKTP.CD
GET, fromJSON, as_tibble, comma
if (interactive()) { get_peru_gdp() }if (interactive()) { get_peru_gdp() }
Retrieves the list of official public holidays in Peru for a specific year using the Nager.Date public holidays API. This function returns a tibble containing the date of the holiday, the name in the local language (Spanish), and the English name. It is useful for academic, planning, and data analysis purposes. The information is retrieved directly from the Nager.Date API and reflects the current status of holidays for the requested year. The field names returned are consistent with the API structure.
get_peru_holidays(year)get_peru_holidays(year)
year |
An integer indicating the year (e.g., 2024 or 2025). |
A tibble with the following columns:
date: Date of the holiday (class Date)
local_name: Holiday name in the local language (Spanish)
name: Holiday name in English
Data obtained from the Nager.Date API: https://date.nager.at/
get_peru_holidays(2024) get_peru_holidays(2025)get_peru_holidays(2024) get_peru_holidays(2025)
Retrieves Peru's number of hospital beds per 1,000 people
for the years 2010 to 2022 using the World Bank Open Data API.
The indicator used is SH.MED.BEDS.ZS.
get_peru_hospital_beds()get_peru_hospital_beds()
This function sends a GET request to the World Bank API.
If the API request fails or returns an error status code,
the function returns NULL with an informative message.
A tibble with the following columns:
indicator: Indicator name (e.g., "Hospital beds (per 1,000 people)")
country: Country name ("Peru")
year: Year of the data (integer)
value: Number of hospital beds per 1,000 people
Requires internet connection.
World Bank Open Data API: https://data.worldbank.org/indicator/SH.MED.BEDS.ZS
if (interactive()) { get_peru_hospital_beds() }if (interactive()) { get_peru_hospital_beds() }
Retrieves Peru's life expectancy at birth (total, years)
for the years 2010 to 2022 using the World Bank Open Data API.
The indicator used is SP.DYN.LE00.IN.
get_peru_life_expectancy()get_peru_life_expectancy()
This function sends a GET request to the World Bank API.
If the API request fails or returns an error status code,
the function returns NULL with an informative message.
A tibble with the following columns:
indicator: Indicator name (e.g., "Life expectancy at birth, total (years)")
country: Country name ("Peru")
year: Year of the data (integer)
value: Life expectancy at birth in years
Requires internet connection.
World Bank Open Data API: https://data.worldbank.org/indicator/SP.DYN.LE00.IN
if (interactive()) { get_peru_life_expectancy() }if (interactive()) { get_peru_life_expectancy() }
Retrieves Peru's adult literacy rate (
for the years 2010 to 2022 using the World Bank Open Data API.
The indicator used is SE.ADT.LITR.ZS.
get_peru_literacy_rate()get_peru_literacy_rate()
This function sends a GET request to the World Bank API.
If the API request fails or returns an error status code,
the function returns NULL with an informative message.
A tibble with the following columns:
indicator: Indicator name
country: Country name ("Peru")
year: Year of the data (integer)
value: Literacy rate as a percentage
Requires internet connection.
World Bank Open Data API: https://data.worldbank.org/indicator/SE.ADT.LITR.ZS
literacy_data <- get_peru_literacy_rate() head(literacy_data)literacy_data <- get_peru_literacy_rate() head(literacy_data)
Retrieves Peru's total population for the years 2010 to 2022
using the World Bank Open Data API. The indicator used is SP.POP.TOTL.
get_peru_population()get_peru_population()
The function sends a GET request to the World Bank API.
If the API request fails or returns an error status code, the function returns NULL with an informative message.
A tibble with the following columns:
indicator: Indicator name (e.g., "Population, total")
country: Country name ("Peru")
year: Year of the data (integer)
value: Population as a numeric value
value_label: Formatted population with commas (e.g., "51,000,000")
Requires internet connection. The data is retrieved in real time from the World Bank API.
World Bank Open Data API: https://data.worldbank.org/indicator/SP.POP.TOTL
GET, fromJSON, as_tibble, comma
if (interactive()) { get_peru_population() }if (interactive()) { get_peru_population() }
Retrieves Peru's total unemployment rate, measured as a percentage of the total labor force,
for the years 2010 to 2022 using the World Bank Open Data API.
The indicator used is SL.UEM.TOTL.ZS.
get_peru_unemployment()get_peru_unemployment()
This function sends a GET request to the World Bank API.
If the API request fails or returns an error status code,
the function returns NULL with an informative message.
A tibble with the following columns:
indicator: Indicator name (e.g., "Unemployment, total (
country: Country name ("Peru")
year: Year of the data (integer)
value: Unemployment rate as a numeric value (percentage)
Requires internet connection.
World Bank Open Data API: https://data.worldbank.org/indicator/SL.UEM.TOTL.ZS
if (interactive()) { get_peru_unemployment() }if (interactive()) { get_peru_unemployment() }
This dataset, iscd_education_tbl_df, is a tibble containing Peru's educational programs classified according to the International Standard Classification of Education (ISCED). It provides comprehensive information about educational codes, classifications, academic levels, and program specifications used in Peru's educational system, facilitating standardized comparison and analysis of educational data.
data(iscd_education_tbl_df)data(iscd_education_tbl_df)
A tibble with 8,357 observations and 8 variables:
Education classification code (character)
Education category description (character)
Specific classification code (character)
Specific category description (character)
Academic level description (character)
Academic level code (character)
Education program name (character)
Education program lemmatized form (character)
The dataset name has been kept as 'iscd_education_tbl_df' to avoid confusion with other datasets in the R ecosystem. This naming convention helps distinguish this dataset as part of the PeruAPIs package and assists users in identifying its specific characteristics. The suffix 'tbl_df' indicates that the dataset is a tibble object. The original content has not been modified in any way.
Data taken from the CINE package version 0.1.3
This dataset, peru_blank_votes_df, is a data frame containing data on the blank votes in the 2006 Peruvian general election. It provides information about voting patterns and their relationship with the Human Development Index (HDI), offering insights into electoral behavior and socioeconomic factors in Peru's democratic process.
data(peru_blank_votes_df)data(peru_blank_votes_df)
A data frame with 194 observations and 2 variables:
Number of blank votes (numeric)
Human Development Index (numeric)
The dataset name has been kept as 'peru_blank_votes_df' to avoid confusion with other datasets in the R ecosystem. This naming convention helps distinguish this dataset as part of the PeruAPIs package and assists users in identifying its specific characteristics. The suffix 'df' indicates that the dataset is a data frame object. The original content has not been modified in any way.
Data taken from the PLreg package version 0.4.1
This dataset, peru_coastline_df, is a data frame containing the coastline of Peru represented as a spatial object. It provides geographical coordinates that define the outline of Peru's Pacific coast, which can be used for mapping, spatial analysis, and visualization purposes.
data(peru_coastline_df)data(peru_coastline_df)
A data frame with 23,481 observations and 2 variables:
Longitude coordinates of coastline points (numeric)
Latitude coordinates of coastline points (numeric)
The dataset name has been kept as 'peru_coastline_df' to avoid confusion with other datasets in the R ecosystem. This naming convention helps distinguish this dataset as part of the PeruAPIs package and assists users in identifying its specific characteristics. The suffix 'df' indicates that the dataset is a data frame object. The original content has not been modified in any way.
Data taken from the Tivy package version 0.1.1
This package provides functions to access data from public RESTful APIs including 'Nager.Date', 'World Bank API', and 'REST Countries API', retrieving real-time or historical data related to Peru, such as holidays, economic indicators, and international demographic and geopolitical indicators. Additionally, the package includes curated datasets focused on Peru, covering topics such as administrative divisions, electoral data, demographics, biodiversity and educational classifications.
PeruAPIs: Access Peruvian Data via Public APIs and Curated Datasets
Access Peruvian Data via Public APIs and Curated Datasets.
Maintainer: Renzo Caceres Rossi [email protected]
Useful links:
This function lists all datasets available in the 'PeruAPIs' package. If the 'PeruAPIs' package is not loaded, it stops and shows an error message. If no datasets are available, it returns a message and an empty vector.
view_datasets_PeruAPIs()view_datasets_PeruAPIs()
A character vector with the names of the available datasets. If no datasets are found, it returns an empty character vector.
if (requireNamespace("PeruAPIs", quietly = TRUE)) { library(PeruAPIs) view_datasets_PeruAPIs() }if (requireNamespace("PeruAPIs", quietly = TRUE)) { library(PeruAPIs) view_datasets_PeruAPIs() }