English | 日本語
dashboardapi is an unofficial R package for accessing
the Statistics Dashboard Web API provided by the Statistics Bureau of
Japan. The API requires no registration or API key.
The main workflow follows the same idea as bojapi and
WDI: search metadata for an indicator code, find any needed
region codes, and retrieve observations as a tidy data frame.
dashboard_search() /
dashboard_indicators(): find indicator codes and inspect
cycle, region, seasonal-adjustment, unit, source, and coveragedashboard_regions(): find Japanese municipality or ISO
country codesdashboard_data(): retrieve normalized long or wide
observationsdashboard_terms(), dashboard_events(), and
dashboard_surveys(): access the API’s auxiliary
metadatadashboard_codes(): inspect common API enumerations
offlineInstall the development version from GitHub:
install.packages("remotes")
remotes::install_github("kenjimyzk/dashboardapi")To install from a local clone of the repository:
remotes::install_local(".")library(dashboardapi)
# 1. Find an indicator
population_meta <- dashboard_search(
"Total population (Both sexes)",
lang = "en"
)
population_meta[, c(
"indicator_code", "name", "cycle_name",
"regional_rank_name", "unit"
)]
# 2. Inspect region codes
prefectures <- dashboard_regions(
parent_region_code = "00000",
lang = "en"
)
# 3. Retrieve annual Japanese population
population <- dashboard_data(
indicator_code = c(population = "0201010000000010000"),
region_code = "00000",
time_from = "2020CY00",
time_to = "2024CY00",
cycle = "year",
regional_rank = "japan",
seasonal = "original",
lang = "en"
)The time column preserves the API’s exact period code.
The date column contains the first day of the represented
period for analysis: 20240100 becomes 2024-01-01,
20242Q00 becomes 2024-04-01, 2024CY00 becomes
2024-01-01, and 2024FY00 becomes 2024-04-01.
prefecture_population <- dashboard_data(
indicator_code = c(population = "0201010000000010000"),
region_code = c("13000", "27000"),
time_from = "2020CY00",
time_to = "2024CY00",
cycle = "year",
regional_rank = "prefecture",
seasonal = "original",
wide = TRUE
)The official API page asks users not to generate a large access
volume in a short period. A request with more than five indicators or 50
regions is split automatically, and dashboardapi waits at
least one second between those requests.
options(
dashboardapi.wait = 2,
dashboardapi.timeout = 60,
dashboardapi.retries = 3
)API errors have class dashboard_api_response_error,
communication errors have class dashboard_http_error, and
unexpected structures have class dashboard_parse_error. A
successful no-data response issues a
dashboard_no_data_warning and returns a typed empty
tibble.
The official Copyright Policy distinguishes three requirements when content from the Statistics Dashboard is published:
dashboard_api_credit() returns the corresponding source
citation, edited-content template, and API credit. Replace
<entity> before publishing edited content:
attribution <- dashboard_api_credit("en")
attribution$source
attribution$processed
attribution$creditdashboardapi is independently developed and is not
affiliated with or endorsed by the Statistics Bureau of Japan. Its MIT
license does not relicense government or third-party data, metadata,
code systems, or official texts. Check any individual rights statement
before reusing third-party content.