Returns ECB data for a given flow and key
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(1)
) key to query.- start_period
(
character(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
(
character(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
(
numeric(1)
) number of observations to retrieve from the start of the series. IfNULL
, no restriction is applied. DefaultNULL
.- last_n
(
numeric(1)
) number of observations to retrieve from the end of the series. IfNULL
, no restriction is applied. DefaultNULL
.
See also
Other data:
bbk_data()
,
bbk_series()
,
snb_data()
Examples
# \donttest{
# fetch US dollar/Euro exchange rate
ecb_data("EXR", "D.USD.EUR.SP00.A")
#> date key value title
#> <Date> <char> <num> <char>
#> 1: 1999-01-04 D.USD.EUR.SP00.A 1.1789 US dollar/Euro
#> 2: 1999-01-05 D.USD.EUR.SP00.A 1.1790 US dollar/Euro
#> 3: 1999-01-06 D.USD.EUR.SP00.A 1.1743 US dollar/Euro
#> 4: 1999-01-07 D.USD.EUR.SP00.A 1.1632 US dollar/Euro
#> 5: 1999-01-08 D.USD.EUR.SP00.A 1.1659 US dollar/Euro
#> ---
#> 6820: 2025-05-26 D.USD.EUR.SP00.A 1.1381 US dollar/Euro
#> 6821: 2025-05-27 D.USD.EUR.SP00.A 1.1356 US dollar/Euro
#> 6822: 2025-05-28 D.USD.EUR.SP00.A 1.1317 US dollar/Euro
#> 6823: 2025-05-29 D.USD.EUR.SP00.A 1.1281 US dollar/Euro
#> 6824: 2025-05-30 D.USD.EUR.SP00.A 1.1339 US dollar/Euro
#> description freq
#> <char> <char>
#> 1: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 2: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 3: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 4: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 5: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> ---
#> 6820: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 6821: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 6822: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 6823: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 6824: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> currency currency_denom exr_type exr_suffix decimals collection unit
#> <char> <char> <char> <char> <char> <char> <char>
#> 1: USD EUR SP00 A 4 A USD
#> 2: USD EUR SP00 A 4 A USD
#> 3: USD EUR SP00 A 4 A USD
#> 4: USD EUR SP00 A 4 A USD
#> 5: USD EUR SP00 A 4 A USD
#> ---
#> 6820: USD EUR SP00 A 4 A USD
#> 6821: USD EUR SP00 A 4 A USD
#> 6822: USD EUR SP00 A 4 A USD
#> 6823: USD EUR SP00 A 4 A USD
#> 6824: USD EUR SP00 A 4 A USD
#> unit_index_base time_format source_agency unit_mult
#> <char> <char> <char> <char>
#> 1: 99Q1=100 P1D DE2 0
#> 2: 99Q1=100 P1D DE2 0
#> 3: 99Q1=100 P1D DE2 0
#> 4: 99Q1=100 P1D DE2 0
#> 5: 99Q1=100 P1D DE2 0
#> ---
#> 6820: 99Q1=100 P1D DE2 0
#> 6821: 99Q1=100 P1D DE2 0
#> 6822: 99Q1=100 P1D DE2 0
#> 6823: 99Q1=100 P1D DE2 0
#> 6824: 99Q1=100 P1D DE2 0
# fetch data for multiple keys
ecb_data("EXR", c("D.USD", "JPY.EUR.SP00.A"))
#> date key value title
#> <Date> <char> <num> <char>
#> 1: 1999-01-04 D.JPY.EUR.SP00.A 133.7300 Japanese yen/Euro
#> 2: 1999-01-05 D.JPY.EUR.SP00.A 130.9600 Japanese yen/Euro
#> 3: 1999-01-06 D.JPY.EUR.SP00.A 131.4200 Japanese yen/Euro
#> 4: 1999-01-07 D.JPY.EUR.SP00.A 129.4300 Japanese yen/Euro
#> 5: 1999-01-08 D.JPY.EUR.SP00.A 130.0900 Japanese yen/Euro
#> ---
#> 13644: 2025-05-26 D.USD.EUR.SP00.A 1.1381 US dollar/Euro
#> 13645: 2025-05-27 D.USD.EUR.SP00.A 1.1356 US dollar/Euro
#> 13646: 2025-05-28 D.USD.EUR.SP00.A 1.1317 US dollar/Euro
#> 13647: 2025-05-29 D.USD.EUR.SP00.A 1.1281 US dollar/Euro
#> 13648: 2025-05-30 D.USD.EUR.SP00.A 1.1339 US dollar/Euro
#> description freq
#> <char> <char>
#> 1: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.) daily
#> 2: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.) daily
#> 3: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.) daily
#> 4: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.) daily
#> 5: ECB reference exchange rate, Japanese yen/Euro, 2.15 pm (C.E.T.) daily
#> ---
#> 13644: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 13645: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 13646: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 13647: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> 13648: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.) daily
#> currency currency_denom exr_type exr_suffix decimals unit time_format
#> <char> <char> <char> <char> <char> <char> <char>
#> 1: JPY EUR SP00 A 4 JPY P1D
#> 2: JPY EUR SP00 A 4 JPY P1D
#> 3: JPY EUR SP00 A 4 JPY P1D
#> 4: JPY EUR SP00 A 4 JPY P1D
#> 5: JPY EUR SP00 A 4 JPY P1D
#> ---
#> 13644: USD EUR SP00 A 4 USD P1D
#> 13645: USD EUR SP00 A 4 USD P1D
#> 13646: USD EUR SP00 A 4 USD P1D
#> 13647: USD EUR SP00 A 4 USD P1D
#> 13648: USD EUR SP00 A 4 USD P1D
#> unit_index_base source_agency collection unit_mult
#> <char> <char> <char> <char>
#> 1: 99Q1=100 DE2 A 0
#> 2: 99Q1=100 DE2 A 0
#> 3: 99Q1=100 DE2 A 0
#> 4: 99Q1=100 DE2 A 0
#> 5: 99Q1=100 DE2 A 0
#> ---
#> 13644: 99Q1=100 DE2 A 0
#> 13645: 99Q1=100 DE2 A 0
#> 13646: 99Q1=100 DE2 A 0
#> 13647: 99Q1=100 DE2 A 0
#> 13648: 99Q1=100 DE2 A 0
# }