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
)Arguments
- flow
(
character(1))
Flow to query.- key
(
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.
Value
A data.table::data.table() with the requested data.
See also
Other data:
bbk_data(),
bbk_series(),
bde_data(),
bdf_codelist(),
bdf_data(),
bdf_dataset(),
boc_data(),
boe_data(),
onb_data(),
snb_data()
Examples
# \donttest{
# fetch US dollar/Euro exchange rate
ecb_data("EXR", "D.USD.EUR.SP00.A")
#> date key value freq title
#> <Date> <char> <num> <char> <char>
#> 1: 1999-01-04 D.USD.EUR.SP00.A 1.1789 daily US dollar/Euro
#> 2: 1999-01-05 D.USD.EUR.SP00.A 1.1790 daily US dollar/Euro
#> 3: 1999-01-06 D.USD.EUR.SP00.A 1.1743 daily US dollar/Euro
#> 4: 1999-01-07 D.USD.EUR.SP00.A 1.1632 daily US dollar/Euro
#> 5: 1999-01-08 D.USD.EUR.SP00.A 1.1659 daily US dollar/Euro
#> ---
#> 6931: 2025-10-28 D.USD.EUR.SP00.A 1.1630 daily US dollar/Euro
#> 6932: 2025-10-29 D.USD.EUR.SP00.A 1.1636 daily US dollar/Euro
#> 6933: 2025-10-30 D.USD.EUR.SP00.A 1.1550 daily US dollar/Euro
#> 6934: 2025-10-31 D.USD.EUR.SP00.A 1.1554 daily US dollar/Euro
#> 6935: 2025-11-03 D.USD.EUR.SP00.A 1.1514 daily US dollar/Euro
#> 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
#> ---
#> 6931: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6932: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6933: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6934: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6935: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> currency_denom exr_type exr_suffix source_agency time_format unit_mult
#> <char> <char> <char> <char> <char> <char>
#> 1: EUR SP00 A 4F0 P1D 0
#> 2: EUR SP00 A 4F0 P1D 0
#> 3: EUR SP00 A 4F0 P1D 0
#> 4: EUR SP00 A 4F0 P1D 0
#> 5: EUR SP00 A 4F0 P1D 0
#> ---
#> 6931: EUR SP00 A 4F0 P1D 0
#> 6932: EUR SP00 A 4F0 P1D 0
#> 6933: EUR SP00 A 4F0 P1D 0
#> 6934: EUR SP00 A 4F0 P1D 0
#> 6935: EUR SP00 A 4F0 P1D 0
#> unit collection unit_index_base decimals
#> <char> <char> <char> <char>
#> 1: USD A 99Q1=100 4
#> 2: USD A 99Q1=100 4
#> 3: USD A 99Q1=100 4
#> 4: USD A 99Q1=100 4
#> 5: USD A 99Q1=100 4
#> ---
#> 6931: USD A 99Q1=100 4
#> 6932: USD A 99Q1=100 4
#> 6933: USD A 99Q1=100 4
#> 6934: USD A 99Q1=100 4
#> 6935: USD A 99Q1=100 4
# fetch data for multiple keys
ecb_data("EXR", c("D.USD", "JPY.EUR.SP00.A"))
#> date key value freq title
#> <Date> <char> <num> <char> <char>
#> 1: 1999-01-04 D.JPY.EUR.SP00.A 133.7300 daily Japanese yen/Euro
#> 2: 1999-01-05 D.JPY.EUR.SP00.A 130.9600 daily Japanese yen/Euro
#> 3: 1999-01-06 D.JPY.EUR.SP00.A 131.4200 daily Japanese yen/Euro
#> 4: 1999-01-07 D.JPY.EUR.SP00.A 129.4300 daily Japanese yen/Euro
#> 5: 1999-01-08 D.JPY.EUR.SP00.A 130.0900 daily Japanese yen/Euro
#> ---
#> 13866: 2025-10-28 D.USD.EUR.SP00.A 1.1630 daily US dollar/Euro
#> 13867: 2025-10-29 D.USD.EUR.SP00.A 1.1636 daily US dollar/Euro
#> 13868: 2025-10-30 D.USD.EUR.SP00.A 1.1550 daily US dollar/Euro
#> 13869: 2025-10-31 D.USD.EUR.SP00.A 1.1554 daily US dollar/Euro
#> 13870: 2025-11-03 D.USD.EUR.SP00.A 1.1514 daily US dollar/Euro
#> 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.)
#> ---
#> 13866: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13867: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13868: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13869: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13870: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> currency currency_denom exr_type exr_suffix time_format source_agency
#> <char> <char> <char> <char> <char> <char>
#> 1: JPY EUR SP00 A P1D 4F0
#> 2: JPY EUR SP00 A P1D 4F0
#> 3: JPY EUR SP00 A P1D 4F0
#> 4: JPY EUR SP00 A P1D 4F0
#> 5: JPY EUR SP00 A P1D 4F0
#> ---
#> 13866: USD EUR SP00 A P1D 4F0
#> 13867: USD EUR SP00 A P1D 4F0
#> 13868: USD EUR SP00 A P1D 4F0
#> 13869: USD EUR SP00 A P1D 4F0
#> 13870: USD EUR SP00 A P1D 4F0
#> unit_index_base unit unit_mult collection decimals
#> <char> <char> <char> <char> <char>
#> 1: 99Q1=100 JPY 0 A 2
#> 2: 99Q1=100 JPY 0 A 2
#> 3: 99Q1=100 JPY 0 A 2
#> 4: 99Q1=100 JPY 0 A 2
#> 5: 99Q1=100 JPY 0 A 2
#> ---
#> 13866: 99Q1=100 USD 0 A 4
#> 13867: 99Q1=100 USD 0 A 4
#> 13868: 99Q1=100 USD 0 A 4
#> 13869: 99Q1=100 USD 0 A 4
#> 13870: 99Q1=100 USD 0 A 4
# }