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
#> ---
#> 6914: 2025-10-03 D.USD.EUR.SP00.A 1.1734 daily US dollar/Euro
#> 6915: 2025-10-06 D.USD.EUR.SP00.A 1.1678 daily US dollar/Euro
#> 6916: 2025-10-07 D.USD.EUR.SP00.A 1.1666 daily US dollar/Euro
#> 6917: 2025-10-08 D.USD.EUR.SP00.A 1.1627 daily US dollar/Euro
#> 6918: 2025-10-09 D.USD.EUR.SP00.A 1.1611 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
#> ---
#> 6914: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6915: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6916: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6917: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6918: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> currency_denom exr_type exr_suffix time_format unit_index_base unit_mult
#> <char> <char> <char> <char> <char> <char>
#> 1: EUR SP00 A P1D 99Q1=100 0
#> 2: EUR SP00 A P1D 99Q1=100 0
#> 3: EUR SP00 A P1D 99Q1=100 0
#> 4: EUR SP00 A P1D 99Q1=100 0
#> 5: EUR SP00 A P1D 99Q1=100 0
#> ---
#> 6914: EUR SP00 A P1D 99Q1=100 0
#> 6915: EUR SP00 A P1D 99Q1=100 0
#> 6916: EUR SP00 A P1D 99Q1=100 0
#> 6917: EUR SP00 A P1D 99Q1=100 0
#> 6918: EUR SP00 A P1D 99Q1=100 0
#> decimals source_agency unit collection
#> <char> <char> <char> <char>
#> 1: 4 4F0 USD A
#> 2: 4 4F0 USD A
#> 3: 4 4F0 USD A
#> 4: 4 4F0 USD A
#> 5: 4 4F0 USD A
#> ---
#> 6914: 4 4F0 USD A
#> 6915: 4 4F0 USD A
#> 6916: 4 4F0 USD A
#> 6917: 4 4F0 USD A
#> 6918: 4 4F0 USD A
# 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
#> ---
#> 13832: 2025-10-03 D.USD.EUR.SP00.A 1.1734 daily US dollar/Euro
#> 13833: 2025-10-06 D.USD.EUR.SP00.A 1.1678 daily US dollar/Euro
#> 13834: 2025-10-07 D.USD.EUR.SP00.A 1.1666 daily US dollar/Euro
#> 13835: 2025-10-08 D.USD.EUR.SP00.A 1.1627 daily US dollar/Euro
#> 13836: 2025-10-09 D.USD.EUR.SP00.A 1.1611 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.)
#> ---
#> 13832: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13833: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13834: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13835: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13836: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> currency currency_denom exr_type exr_suffix unit_index_base
#> <char> <char> <char> <char> <char>
#> 1: JPY EUR SP00 A 99Q1=100
#> 2: JPY EUR SP00 A 99Q1=100
#> 3: JPY EUR SP00 A 99Q1=100
#> 4: JPY EUR SP00 A 99Q1=100
#> 5: JPY EUR SP00 A 99Q1=100
#> ---
#> 13832: USD EUR SP00 A 99Q1=100
#> 13833: USD EUR SP00 A 99Q1=100
#> 13834: USD EUR SP00 A 99Q1=100
#> 13835: USD EUR SP00 A 99Q1=100
#> 13836: USD EUR SP00 A 99Q1=100
#> source_agency time_format decimals unit_mult collection unit
#> <char> <char> <char> <char> <char> <char>
#> 1: 4F0 P1D 2 0 A JPY
#> 2: 4F0 P1D 2 0 A JPY
#> 3: 4F0 P1D 2 0 A JPY
#> 4: 4F0 P1D 2 0 A JPY
#> 5: 4F0 P1D 2 0 A JPY
#> ---
#> 13832: 4F0 P1D 4 0 A USD
#> 13833: 4F0 P1D 4 0 A USD
#> 13834: 4F0 P1D 4 0 A USD
#> 13835: 4F0 P1D 4 0 A USD
#> 13836: 4F0 P1D 4 0 A USD
# }