MyNixOS website logo
Description

Access Chinese Data via Public APIs and Curated Datasets.

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 China, such as holidays, economic indicators, and international demographic and geopolitical indicators. Additionally, the package includes one of the largest curated collections of open datasets focused on China and Hong Kong, covering topics such as air quality, demographics, input-output tables, epidemiology, political structure, names, and social indicators. 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/>.

ChinAPIs

License: MIT

The ChinAPIs package provides a unified interface to access open data from the World Bank API, Nager.Date API, and the REST Countries API, with a focus on China. It allows users to retrieve up-to-date information on topics such as economic indicators, population statistics, unemployment rates, holidays, and basic geopolitical details.

In addition to API-access functions, the package includes one of the largest curated collections of open datasets related to China and Hong Kong. These datasets cover areas such as air quality, demographic indicators, input-output economic tables, epidemiology, administrative divisions, name distributions, political structure, and various social indicators.

Installation

You can install the ChinAPIs package from CRAN with the following R function:


install.packages("ChinAPIs")

Usage

After installation, load the package and start exploring and using its functions and datasets.


library(ChinAPIs)

ChinAPIs Functions

Below is a list of the main functions included in the package:

  • get_country_info_cn(): Get key geopolitical and administrative information about China from the REST Countries API.

  • get_china_gdp(): Get China’s Gross Domestic Product (current US$) from the World Bank

  • get_china_cpi(): Get China's Consumer Price Index from World Bank

  • get_china_population(): Get China’s total population from the World Bank

  • get_china_literacy_rate(): Get China's adult literacy rate (Age 15+) from the World Bank

  • get_china_life_expectancy(): Get life expectancy at birth for China from the World Bank

  • get_china_unemployment(): Get China's Unemployment Rate from World Bank

  • get_china_energy_use(): Get China's energy use per capita (kg of oil equivalent) from the World Bank

  • get_china_child_mortality(): Get under-5 mortality rate (per 1,000 live births) in China from the World Bank

  • get_china_hospital_beds(): Get hospital beds per 1,000 people in China from the World Bank

  • get_china_holidays(): Retrieve Chinese public holidays (including past and upcoming dates) from the Nager.Date API (e.g., get_china_holidays(2024), get_china_holidays(2025)).

  • view_datasets_ChinAPIs(): Lists all curated datasets included in the ChinAPIs package

Dataset Suffixes

Each dataset in ChinAPIs is labeled with a suffix to indicate its structure and type:

  • _df: A standard data frame.

  • _tbl_df: A tibble data frame object.

  • _list: A list object.

  • _matrix: A matrix object.

Datasets Included in ChinAPIs

In addition to API access functions, ChinAPIs provides several preloaded datasets related to China’s air quality, demographics, input-output tables, epidemiology, political structure, names, and social indicators. Here are some featured examples:

  • bj_air_quality_tbl_df: Tibble of hourly air pollution and weather measurements from Dongsi, Beijing.

  • china_admin_divisions_df: Data frame containing the codes and names of China's administrative divisions.

  • shanghai_factories_df: Data frame containing data on per capita output of workers in 17 factories located in Shanghai.

Example Code:


# Load the package

library(ChinAPIs)

# Retrieves essential information about China

get_country_info_cn()

# Get China's Population (Total) from World Bank

get_china_population()

# Load a dataset

data(china_cars_tbl_df)

# Shows six rows of the dataset

head(china_cars_tbl_df)

# Display the structure of the dataset

str(china_cars_tbl_df)

# Shows the whole dataset

View(china_cars_tbl_df)


Metadata

Version

0.1.0

License

Unknown

Platforms (76)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows