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 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
#>   ---                                                  
#> 6840: 2025-06-23 D.USD.EUR.SP00.A 1.1472 US dollar/Euro
#> 6841: 2025-06-24 D.USD.EUR.SP00.A 1.1607 US dollar/Euro
#> 6842: 2025-06-25 D.USD.EUR.SP00.A 1.1598 US dollar/Euro
#> 6843: 2025-06-26 D.USD.EUR.SP00.A 1.1695 US dollar/Euro
#> 6844: 2025-06-27 D.USD.EUR.SP00.A 1.1704 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
#>   ---                                                                     
#> 6840: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 6841: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 6842: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 6843: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 6844: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#>       currency currency_denom exr_type exr_suffix unit_mult time_format
#>         <char>         <char>   <char>     <char>    <char>      <char>
#>    1:      USD            EUR     SP00          A         0         P1D
#>    2:      USD            EUR     SP00          A         0         P1D
#>    3:      USD            EUR     SP00          A         0         P1D
#>    4:      USD            EUR     SP00          A         0         P1D
#>    5:      USD            EUR     SP00          A         0         P1D
#>   ---                                                                  
#> 6840:      USD            EUR     SP00          A         0         P1D
#> 6841:      USD            EUR     SP00          A         0         P1D
#> 6842:      USD            EUR     SP00          A         0         P1D
#> 6843:      USD            EUR     SP00          A         0         P1D
#> 6844:      USD            EUR     SP00          A         0         P1D
#>       collection unit_index_base source_agency   unit decimals
#>           <char>          <char>        <char> <char>   <char>
#>    1:          A        99Q1=100           DE2    USD        4
#>    2:          A        99Q1=100           DE2    USD        4
#>    3:          A        99Q1=100           DE2    USD        4
#>    4:          A        99Q1=100           DE2    USD        4
#>    5:          A        99Q1=100           DE2    USD        4
#>   ---                                                         
#> 6840:          A        99Q1=100           DE2    USD        4
#> 6841:          A        99Q1=100           DE2    USD        4
#> 6842:          A        99Q1=100           DE2    USD        4
#> 6843:          A        99Q1=100           DE2    USD        4
#> 6844:          A        99Q1=100           DE2    USD        4
# 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
#>    ---                                                       
#> 13684: 2025-06-23 D.USD.EUR.SP00.A   1.1472    US dollar/Euro
#> 13685: 2025-06-24 D.USD.EUR.SP00.A   1.1607    US dollar/Euro
#> 13686: 2025-06-25 D.USD.EUR.SP00.A   1.1598    US dollar/Euro
#> 13687: 2025-06-26 D.USD.EUR.SP00.A   1.1695    US dollar/Euro
#> 13688: 2025-06-27 D.USD.EUR.SP00.A   1.1704    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
#>    ---                                                                        
#> 13684:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 13685:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 13686:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 13687:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 13688:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#>        currency currency_denom exr_type exr_suffix time_format unit_mult
#>          <char>         <char>   <char>     <char>      <char>    <char>
#>     1:      JPY            EUR     SP00          A         P1D         0
#>     2:      JPY            EUR     SP00          A         P1D         0
#>     3:      JPY            EUR     SP00          A         P1D         0
#>     4:      JPY            EUR     SP00          A         P1D         0
#>     5:      JPY            EUR     SP00          A         P1D         0
#>    ---                                                                  
#> 13684:      USD            EUR     SP00          A         P1D         0
#> 13685:      USD            EUR     SP00          A         P1D         0
#> 13686:      USD            EUR     SP00          A         P1D         0
#> 13687:      USD            EUR     SP00          A         P1D         0
#> 13688:      USD            EUR     SP00          A         P1D         0
#>        decimals collection source_agency   unit unit_index_base
#>          <char>     <char>        <char> <char>          <char>
#>     1:        4          A           DE2    JPY        99Q1=100
#>     2:        4          A           DE2    JPY        99Q1=100
#>     3:        4          A           DE2    JPY        99Q1=100
#>     4:        4          A           DE2    JPY        99Q1=100
#>     5:        4          A           DE2    JPY        99Q1=100
#>    ---                                                         
#> 13684:        4          A           DE2    USD        99Q1=100
#> 13685:        4          A           DE2    USD        99Q1=100
#> 13686:        4          A           DE2    USD        99Q1=100
#> 13687:        4          A           DE2    USD        99Q1=100
#> 13688:        4          A           DE2    USD        99Q1=100
# }