Retrieve time series data from the ECB SDMX Web Service.
Usage
ecb_data(
flow,
key = NULL,
start_period = NULL,
end_period = NULL,
first_n = NULL,
last_n = NULL,
updated_after = NULL
)Arguments
- flow
(
character(1))
Flow to query.- key
(
NULL|character())
The series keys to query.- start_period
(
NULL|character(1)|integer(1))
Start date of the data. Supported formats:YYYY for annual data (e.g.,
2019)YYYY-S[1-2] for semi-annual data (e.g.,
"2019-S1")YYYY-Q[1-4] for quarterly data (e.g.,
"2019-Q1")YYYY-MM for monthly data (e.g.,
"2019-01")YYYY-W[01-53] for weekly data (e.g.,
"2019-W01")YYYY-MM-DD for daily and business data (e.g.,
"2019-01-01")
If
NULL, no start date restriction is applied (data retrieved from the earliest available date). DefaultNULL.- end_period
(
NULL|character(1)|integer(1))
End date of the data, in the same format as start_period. IfNULL, no end date restriction is applied (data retrieved up to the most recent available date). DefaultNULL.- first_n
(
NULL|numeric(1))
Number of observations to retrieve from the start of the series. IfNULL, no restriction is applied. DefaultNULL.- last_n
(
NULL|numeric(1))
Number of observations to retrieve from the end of the series. IfNULL, no restriction is applied. DefaultNULL.- updated_after
(
NULL|character(1)|Date(1)|POSIXct(1))
Retrieve only observations updated after the given timestamp (e.g.,"2024-06-01T00:00:00"). Useful for incremental retrieval. IfNULL, no restriction is applied. DefaultNULL.
Value
A data.table::data.table() with the requested data.
See also
Other data:
banxico_data(),
bbk_data(),
bbk_series(),
bcb_data(),
bcb_expectations(),
bcb_fx_rates(),
bcb_inflation(),
bcb_selic(),
bcb_top5(),
bde_data(),
bde_latest(),
bdf_codelist(),
bdf_data(),
bdf_dataset(),
bdp_data(),
bis_data(),
boc_data(),
boe_data(),
boi_data(),
boj_data(),
cnb_czeonia(),
cnb_data(),
cnb_fx_other_rates(),
cnb_fx_rates(),
cnb_pribor(),
nbp_fx_rates(),
nbp_gold(),
nob_data(),
onb_data(),
snb_data(),
srb_cross_rates(),
srb_data()
Examples
# \donttest{
# fetch US dollar/Euro exchange rate
ecb_data("EXR", "D.USD.EUR.SP00.A")
#> date key value freq
#> <Date> <char> <num> <char>
#> 1: 1999-01-04 D.USD.EUR.SP00.A 1.1789 daily
#> 2: 1999-01-05 D.USD.EUR.SP00.A 1.1790 daily
#> 3: 1999-01-06 D.USD.EUR.SP00.A 1.1743 daily
#> 4: 1999-01-07 D.USD.EUR.SP00.A 1.1632 daily
#> 5: 1999-01-08 D.USD.EUR.SP00.A 1.1659 daily
#> ---
#> 7117: 2026-07-23 D.USD.EUR.SP00.A 1.1392 daily
#> 7118: 2026-07-24 D.USD.EUR.SP00.A 1.1377 daily
#> 7119: 2026-07-27 D.USD.EUR.SP00.A 1.1389 daily
#> 7120: 2026-07-28 D.USD.EUR.SP00.A 1.1367 daily
#> 7121: 2026-07-29 D.USD.EUR.SP00.A 1.1380 daily
#> title
#> <char>
#> 1: US dollar/Euro ECB reference exchange rate
#> 2: US dollar/Euro ECB reference exchange rate
#> 3: US dollar/Euro ECB reference exchange rate
#> 4: US dollar/Euro ECB reference exchange rate
#> 5: US dollar/Euro ECB reference exchange rate
#> ---
#> 7117: US dollar/Euro ECB reference exchange rate
#> 7118: US dollar/Euro ECB reference exchange rate
#> 7119: US dollar/Euro ECB reference exchange rate
#> 7120: US dollar/Euro ECB reference exchange rate
#> 7121: US dollar/Euro ECB reference exchange rate
#> description currency
#> <char> <char>
#> 1: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 2: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 3: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 4: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 5: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> ---
#> 7117: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 7118: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 7119: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 7120: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 7121: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> currency_denom exr_type exr_suffix unit_index_base time_format collection
#> <char> <char> <char> <char> <char> <char>
#> 1: EUR SP00 A 99Q1=100 P1D A
#> 2: EUR SP00 A 99Q1=100 P1D A
#> 3: EUR SP00 A 99Q1=100 P1D A
#> 4: EUR SP00 A 99Q1=100 P1D A
#> 5: EUR SP00 A 99Q1=100 P1D A
#> ---
#> 7117: EUR SP00 A 99Q1=100 P1D A
#> 7118: EUR SP00 A 99Q1=100 P1D A
#> 7119: EUR SP00 A 99Q1=100 P1D A
#> 7120: EUR SP00 A 99Q1=100 P1D A
#> 7121: EUR SP00 A 99Q1=100 P1D A
#> unit_mult source_agency unit decimals
#> <char> <char> <char> <char>
#> 1: 0 4F0 USD 4
#> 2: 0 4F0 USD 4
#> 3: 0 4F0 USD 4
#> 4: 0 4F0 USD 4
#> 5: 0 4F0 USD 4
#> ---
#> 7117: 0 4F0 USD 4
#> 7118: 0 4F0 USD 4
#> 7119: 0 4F0 USD 4
#> 7120: 0 4F0 USD 4
#> 7121: 0 4F0 USD 4
# fetch data for multiple keys
ecb_data("EXR", c("D.USD", "JPY.EUR.SP00.A"))
#> date key value freq
#> <Date> <char> <num> <char>
#> 1: 1999-01-04 D.JPY.EUR.SP00.A 133.7300 daily
#> 2: 1999-01-05 D.JPY.EUR.SP00.A 130.9600 daily
#> 3: 1999-01-06 D.JPY.EUR.SP00.A 131.4200 daily
#> 4: 1999-01-07 D.JPY.EUR.SP00.A 129.4300 daily
#> 5: 1999-01-08 D.JPY.EUR.SP00.A 130.0900 daily
#> ---
#> 14238: 2026-07-23 D.USD.EUR.SP00.A 1.1392 daily
#> 14239: 2026-07-24 D.USD.EUR.SP00.A 1.1377 daily
#> 14240: 2026-07-27 D.USD.EUR.SP00.A 1.1389 daily
#> 14241: 2026-07-28 D.USD.EUR.SP00.A 1.1367 daily
#> 14242: 2026-07-29 D.USD.EUR.SP00.A 1.1380 daily
#> title
#> <char>
#> 1: Japanese yen/Euro ECB reference exchange rate
#> 2: Japanese yen/Euro ECB reference exchange rate
#> 3: Japanese yen/Euro ECB reference exchange rate
#> 4: Japanese yen/Euro ECB reference exchange rate
#> 5: Japanese yen/Euro ECB reference exchange rate
#> ---
#> 14238: US dollar/Euro ECB reference exchange rate
#> 14239: US dollar/Euro ECB reference exchange rate
#> 14240: US dollar/Euro ECB reference exchange rate
#> 14241: US dollar/Euro ECB reference exchange rate
#> 14242: US dollar/Euro ECB reference exchange rate
#> description
#> <char>
#> 1: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.)
#> 2: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.)
#> 3: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.)
#> 4: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.)
#> 5: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.)
#> ---
#> 14238: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 14239: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 14240: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 14241: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 14242: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> currency currency_denom exr_type exr_suffix unit_index_base time_format
#> <char> <char> <char> <char> <char> <char>
#> 1: JPY EUR SP00 A 99Q1=100 P1D
#> 2: JPY EUR SP00 A 99Q1=100 P1D
#> 3: JPY EUR SP00 A 99Q1=100 P1D
#> 4: JPY EUR SP00 A 99Q1=100 P1D
#> 5: JPY EUR SP00 A 99Q1=100 P1D
#> ---
#> 14238: USD EUR SP00 A 99Q1=100 P1D
#> 14239: USD EUR SP00 A 99Q1=100 P1D
#> 14240: USD EUR SP00 A 99Q1=100 P1D
#> 14241: USD EUR SP00 A 99Q1=100 P1D
#> 14242: USD EUR SP00 A 99Q1=100 P1D
#> collection unit_mult unit source_agency decimals
#> <char> <char> <char> <char> <char>
#> 1: A 0 JPY 4F0 2
#> 2: A 0 JPY 4F0 2
#> 3: A 0 JPY 4F0 2
#> 4: A 0 JPY 4F0 2
#> 5: A 0 JPY 4F0 2
#> ---
#> 14238: A 0 USD 4F0 4
#> 14239: A 0 USD 4F0 4
#> 14240: A 0 USD 4F0 4
#> 14241: A 0 USD 4F0 4
#> 14242: A 0 USD 4F0 4
# }