| bde_series_api | R Documentation |
These functions retrieve BdE time series using theStatistics web service (API).
The API is a JSON web service that provides URL-based access to information available in the Statistics section of Banco de España and the BIEST application.
The API defines two request types. bde_series_api_latest() uses the Latest
Data request to obtain the latest published observation for one or more
series. bde_series_api_load() uses the Series List request to obtain the
details of one or more complete series and their metadata.
bde_series_api_latest(series_code, language = c("en", "es"), verbose = FALSE)
bde_series_api_load(
series_code,
series_label = NULL,
out_format = "wide",
language = c("en", "es"),
time_range = NULL,
verbose = FALSE,
extract_metadata = FALSE
)
series_code |
A character vector of API series codes from the
|
language |
A string specifying the output language: |
verbose |
Logical. If |
series_label |
An optional character vector of labels to assign to the extracted series. |
out_format |
The output format, either |
time_range |
An optional string specifying a year or API range code. It
can be a year, such as |
extract_metadata |
Logical. If |
Allowed time_range values depend on the series frequency:
Daily frequency (D): "3M" (last 3 months), "12M" and "36M".
Monthly frequency (M): "30M", "60M" and "MAX" (entire series).
Quarterly frequency (Q): "30M", "60M" and "MAX".
Annual frequency (A): "60M" and "MAX".
If time_range is not specified, the request returns the smallest range for
the series frequency. For example, monthly series return "30M".
bde_series_api_latest() returns a tibble with the latest
published observation for each valid series. It includes fields returned by
the Latest Data request such as serie, descripcionCorta, codFrecuencia,
decimales, simbolo, tendencia, fechaValor and valor.
bde_series_api_load() returns a tibble. When
extract_metadata = FALSE, API dates are parsed as Date
values and observations are returned in wide or long format according to
out_format. When extract_metadata = TRUE, it returns one row per valid
series with fields returned by the Series List request, including
fechaInicio, fechaFin and metadata fields derived from informacion.
BdE identifies each series with a stable sequential number
(Numero_secuencial) in bulk CSV files and an API series code
(Nombre_de_la_serie) in the Statistics web service.
bde_series_load() accepts stable sequential numbers in series_code.
bde_series_api_latest() and bde_series_api_load() use the same argument
for API series codes. Use bde_catalog_load() or bde_catalog_search() to
find both identifiers.
bde_catalog_load() and bde_catalog_search() help find API series codes.
bde_series_load() loads time series from bulk CSV files.
Time series functions:
bde_series
xr <- bde_catalog_load(catalog = "TC")
# Extract the latest value.
library(dplyr)
xr |>
slice_head(n = 3) |>
pull(Nombre_de_la_serie) |>
bde_series_api_latest(language = "en") |>
glimpse()
# Extract the latest months.
xr |>
slice_head(n = 1) |>
pull(Nombre_de_la_serie) |>
bde_series_api_load(language = "en", time_range = "12M") |>
glimpse()
# Extract metadata.
xr |>
slice_head(n = 1) |>
pull(Nombre_de_la_serie) |>
bde_series_api_load(
language = "en", time_range = "12M",
extract_metadata = TRUE
) |>
glimpse()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.