get_country_info {MexicoDataAPI}R Documentation

Get Key Country Information from the REST Countries API

Description

Retrieves selected, essential information about Mexico or any other country by its full name. The data is retrieved from the REST Countries API. See the API documentation at https://restcountries.com/. Example API usage: https://restcountries.com/v3.1/name/mexico?fullText=true.

Usage

get_country_info(name)

Arguments

name

Full country name (common or official). For example: "Mexico", "Peru", "France".

Details

This function returns readable details such as the country's common and official name, capital, region, subregion, population, area, and official languages.

The function sends a GET request to the REST Countries API. If the request is successful (HTTP 200), it parses the JSON and extracts the key fields. If the country is not found or there's an error, the function returns NULL with a user-friendly message.

Value

A data frame with 8 columns:

See Also

GET, fromJSON, tibble

Examples

## Not run: 
get_country_info("Mexico")
get_country_info("Japan")
get_country_info("France")

## End(Not run)


[Package MexicoDataAPI version 0.1.0 Index]