Skip to contents

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). Default NULL.

end_period

(character(1)) end date of the data, in the same format as start_period. If NULL, no end date restriction is applied (data retrieved up to the most recent available date). Default NULL.

first_n

(numeric(1)) number of observations to retrieve from the start of the series. If NULL, no restriction is applied. Default NULL.

last_n

(numeric(1)) number of observations to retrieve from the end of the series. If NULL, no restriction is applied. Default NULL.

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 Euro/US dollar
#>    2: 1999-01-05 D.USD.EUR.SP00.A 1.1790 Euro/US dollar
#>    3: 1999-01-06 D.USD.EUR.SP00.A 1.1743 Euro/US dollar
#>    4: 1999-01-07 D.USD.EUR.SP00.A 1.1632 Euro/US dollar
#>    5: 1999-01-08 D.USD.EUR.SP00.A 1.1659 Euro/US dollar
#>   ---                                                  
#> 6786: 2025-04-03 D.USD.EUR.SP00.A 1.1097 Euro/US dollar
#> 6787: 2025-04-04 D.USD.EUR.SP00.A 1.1057 Euro/US dollar
#> 6788: 2025-04-07 D.USD.EUR.SP00.A 1.0967 Euro/US dollar
#> 6789: 2025-04-08 D.USD.EUR.SP00.A 1.0950 Euro/US dollar
#> 6790: 2025-04-09 D.USD.EUR.SP00.A 1.1045 Euro/US dollar
#>                                                         description   freq
#>                                                              <char> <char>
#>    1: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#>    2: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#>    3: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#>    4: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#>    5: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#>   ---                                                                     
#> 6786: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 6787: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 6788: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 6789: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 6790: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#>       currency currency_denom exr_type exr_suffix collection source_agency
#>         <char>         <char>   <char>     <char>     <char>        <char>
#>    1:      USD            EUR     SP00          A          A           4F0
#>    2:      USD            EUR     SP00          A          A           4F0
#>    3:      USD            EUR     SP00          A          A           4F0
#>    4:      USD            EUR     SP00          A          A           4F0
#>    5:      USD            EUR     SP00          A          A           4F0
#>   ---                                                                     
#> 6786:      USD            EUR     SP00          A          A           4F0
#> 6787:      USD            EUR     SP00          A          A           4F0
#> 6788:      USD            EUR     SP00          A          A           4F0
#> 6789:      USD            EUR     SP00          A          A           4F0
#> 6790:      USD            EUR     SP00          A          A           4F0
#>       time_format   unit decimals unit_mult
#>            <char> <char>   <char>    <char>
#>    1:         P1D    USD        4         0
#>    2:         P1D    USD        4         0
#>    3:         P1D    USD        4         0
#>    4:         P1D    USD        4         0
#>    5:         P1D    USD        4         0
#>   ---                                      
#> 6786:         P1D    USD        4         0
#> 6787:         P1D    USD        4         0
#> 6788:         P1D    USD        4         0
#> 6789:         P1D    USD        4         0
#> 6790:         P1D    USD        4         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 Euro/Japanese yen
#>     2: 1999-01-05 D.JPY.EUR.SP00.A 130.9600 Euro/Japanese yen
#>     3: 1999-01-06 D.JPY.EUR.SP00.A 131.4200 Euro/Japanese yen
#>     4: 1999-01-07 D.JPY.EUR.SP00.A 129.4300 Euro/Japanese yen
#>     5: 1999-01-08 D.JPY.EUR.SP00.A 130.0900 Euro/Japanese yen
#>    ---                                                       
#> 13576: 2025-04-03 D.USD.EUR.SP00.A   1.1097    Euro/US dollar
#> 13577: 2025-04-04 D.USD.EUR.SP00.A   1.1057    Euro/US dollar
#> 13578: 2025-04-07 D.USD.EUR.SP00.A   1.0967    Euro/US dollar
#> 13579: 2025-04-08 D.USD.EUR.SP00.A   1.0950    Euro/US dollar
#> 13580: 2025-04-09 D.USD.EUR.SP00.A   1.1045    Euro/US dollar
#>                                                             description   freq
#>                                                                  <char> <char>
#>     1: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.)  daily
#>     2: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.)  daily
#>     3: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.)  daily
#>     4: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.)  daily
#>     5: ECB reference exchange rate, Euro/Japanese yen, 2:15 pm (C.E.T.)  daily
#>    ---                                                                        
#> 13576:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 13577:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 13578:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 13579:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 13580:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#>        currency currency_denom exr_type exr_suffix time_format collection
#>          <char>         <char>   <char>     <char>      <char>     <char>
#>     1:      JPY            EUR     SP00          A         P1D          A
#>     2:      JPY            EUR     SP00          A         P1D          A
#>     3:      JPY            EUR     SP00          A         P1D          A
#>     4:      JPY            EUR     SP00          A         P1D          A
#>     5:      JPY            EUR     SP00          A         P1D          A
#>    ---                                                                   
#> 13576:      USD            EUR     SP00          A         P1D          A
#> 13577:      USD            EUR     SP00          A         P1D          A
#> 13578:      USD            EUR     SP00          A         P1D          A
#> 13579:      USD            EUR     SP00          A         P1D          A
#> 13580:      USD            EUR     SP00          A         P1D          A
#>          unit decimals source_agency unit_mult
#>        <char>   <char>        <char>    <char>
#>     1:    JPY        2           4F0         0
#>     2:    JPY        2           4F0         0
#>     3:    JPY        2           4F0         0
#>     4:    JPY        2           4F0         0
#>     5:    JPY        2           4F0         0
#>    ---                                        
#> 13576:    USD        4           4F0         0
#> 13577:    USD        4           4F0         0
#> 13578:    USD        4           4F0         0
#> 13579:    USD        4           4F0         0
#> 13580:    USD        4           4F0         0
# }