boj_data: Retrieve Bank of Japan time-series data by series code

View source: R/data.R

boj_dataR Documentation

Retrieve Bank of Japan time-series data by series code

Description

boj_data() is the main data function. It accepts one or more BOJ series codes, splits requests into safe batches of 250 codes, follows NEXTPOSITION until complete, and returns one observation per row. All codes in a BOJ code request must have the same frequency.

Usage

boj_data(
  db,
  code,
  start_date = NULL,
  end_date = NULL,
  lang = boj_default("lang", "en"),
  wide = FALSE,
  wait = boj_default("wait", 1),
  timeout = boj_default("timeout", 30),
  retries = boj_default("retries", 3)
)

Arguments

db

BOJ database identifier, such as "FM08".

code

Character vector of series codes without the database prefix. For example, use "MADR1Z@D", not "IR01'MADR1Z@D". Names become aliases in the series column and wide output.

start_date, end_date

Optional BOJ period codes. Accepted request forms are YYYY or YYYYPP; daily and weekly filters also use YYYYMM.

lang

Response language, "en" or "jp".

wide

If FALSE (default), return normalized long data. If TRUE, return time, parsed date, and one column per code or alias.

wait

Requested seconds between automatic requests. The default is one second, and values below one are treated as one whenever another request is needed, to avoid high-frequency access prohibited by the BOJ.

timeout

Request timeout in seconds.

retries

Number of retries for network and transient server errors.

Details

A named code vector creates convenient aliases, following the style of WDI::WDI(). The original BOJ code is always retained in series_code.

Value

A tibble. Long output contains db, series, series_code, name, unit, frequency, category, last_update, time, date, and value. time preserves the exact BOJ period code. date is the first day of non-daily periods (April 1 for fiscal years); use time when exact period semantics matter.

Examples

## Not run: 
fx <- boj_data(
  db = "FM08",
  code = c(usd_yen = "FXERM07"),
  start_date = "202401",
  end_date = "202412"
)

boj_data(
  "FM08",
  c(usd_yen = "FXERM07", euro_yen = "FXERM09"),
  start_date = "202401",
  wide = TRUE
)

## End(Not run)

bojapi documentation built on July 24, 2026, 5:07 p.m.