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()
,
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
#> ---
#> 6886: 2025-08-26 D.USD.EUR.SP00.A 1.1656 daily US dollar/Euro
#> 6887: 2025-08-27 D.USD.EUR.SP00.A 1.1593 daily US dollar/Euro
#> 6888: 2025-08-28 D.USD.EUR.SP00.A 1.1676 daily US dollar/Euro
#> 6889: 2025-08-29 D.USD.EUR.SP00.A 1.1658 daily US dollar/Euro
#> 6890: 2025-09-01 D.USD.EUR.SP00.A 1.1715 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
#> ---
#> 6886: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6887: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6888: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6889: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> 6890: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) USD
#> currency_denom exr_type exr_suffix unit_mult unit_index_base decimals
#> <char> <char> <char> <char> <char> <char>
#> 1: EUR SP00 A 0 99Q1=100 4
#> 2: EUR SP00 A 0 99Q1=100 4
#> 3: EUR SP00 A 0 99Q1=100 4
#> 4: EUR SP00 A 0 99Q1=100 4
#> 5: EUR SP00 A 0 99Q1=100 4
#> ---
#> 6886: EUR SP00 A 0 99Q1=100 4
#> 6887: EUR SP00 A 0 99Q1=100 4
#> 6888: EUR SP00 A 0 99Q1=100 4
#> 6889: EUR SP00 A 0 99Q1=100 4
#> 6890: EUR SP00 A 0 99Q1=100 4
#> source_agency time_format unit collection
#> <char> <char> <char> <char>
#> 1: 4F0 P1D USD A
#> 2: 4F0 P1D USD A
#> 3: 4F0 P1D USD A
#> 4: 4F0 P1D USD A
#> 5: 4F0 P1D USD A
#> ---
#> 6886: 4F0 P1D USD A
#> 6887: 4F0 P1D USD A
#> 6888: 4F0 P1D USD A
#> 6889: 4F0 P1D USD A
#> 6890: 4F0 P1D 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
#> ---
#> 13776: 2025-08-26 D.USD.EUR.SP00.A 1.1656 daily US dollar/Euro
#> 13777: 2025-08-27 D.USD.EUR.SP00.A 1.1593 daily US dollar/Euro
#> 13778: 2025-08-28 D.USD.EUR.SP00.A 1.1676 daily US dollar/Euro
#> 13779: 2025-08-29 D.USD.EUR.SP00.A 1.1658 daily US dollar/Euro
#> 13780: 2025-09-01 D.USD.EUR.SP00.A 1.1715 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.)
#> ---
#> 13776: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13777: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13778: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13779: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> 13780: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)
#> currency currency_denom exr_type exr_suffix source_agency unit
#> <char> <char> <char> <char> <char> <char>
#> 1: JPY EUR SP00 A 4F0 JPY
#> 2: JPY EUR SP00 A 4F0 JPY
#> 3: JPY EUR SP00 A 4F0 JPY
#> 4: JPY EUR SP00 A 4F0 JPY
#> 5: JPY EUR SP00 A 4F0 JPY
#> ---
#> 13776: USD EUR SP00 A 4F0 USD
#> 13777: USD EUR SP00 A 4F0 USD
#> 13778: USD EUR SP00 A 4F0 USD
#> 13779: USD EUR SP00 A 4F0 USD
#> 13780: USD EUR SP00 A 4F0 USD
#> unit_mult unit_index_base time_format collection decimals
#> <char> <char> <char> <char> <char>
#> 1: 0 99Q1=100 P1D A 2
#> 2: 0 99Q1=100 P1D A 2
#> 3: 0 99Q1=100 P1D A 2
#> 4: 0 99Q1=100 P1D A 2
#> 5: 0 99Q1=100 P1D A 2
#> ---
#> 13776: 0 99Q1=100 P1D A 4
#> 13777: 0 99Q1=100 P1D A 4
#> 13778: 0 99Q1=100 P1D A 4
#> 13779: 0 99Q1=100 P1D A 4
#> 13780: 0 99Q1=100 P1D A 4
# }