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(), boe_data(), 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
#>   ---                                                  
#> 6862: 2025-07-23 D.USD.EUR.SP00.A 1.1726 US dollar/Euro
#> 6863: 2025-07-24 D.USD.EUR.SP00.A 1.1756 US dollar/Euro
#> 6864: 2025-07-25 D.USD.EUR.SP00.A 1.1724 US dollar/Euro
#> 6865: 2025-07-28 D.USD.EUR.SP00.A 1.1654 US dollar/Euro
#> 6866: 2025-07-29 D.USD.EUR.SP00.A 1.1533 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
#>   ---                                                                     
#> 6862: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 6863: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 6864: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 6865: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 6866: ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#>       currency currency_denom exr_type exr_suffix decimals unit_index_base
#>         <char>         <char>   <char>     <char>   <char>          <char>
#>    1:      USD            EUR     SP00          A        4        99Q1=100
#>    2:      USD            EUR     SP00          A        4        99Q1=100
#>    3:      USD            EUR     SP00          A        4        99Q1=100
#>    4:      USD            EUR     SP00          A        4        99Q1=100
#>    5:      USD            EUR     SP00          A        4        99Q1=100
#>   ---                                                                     
#> 6862:      USD            EUR     SP00          A        4        99Q1=100
#> 6863:      USD            EUR     SP00          A        4        99Q1=100
#> 6864:      USD            EUR     SP00          A        4        99Q1=100
#> 6865:      USD            EUR     SP00          A        4        99Q1=100
#> 6866:      USD            EUR     SP00          A        4        99Q1=100
#>       collection   unit source_agency time_format unit_mult
#>           <char> <char>        <char>      <char>    <char>
#>    1:          A    USD           4F0         P1D         0
#>    2:          A    USD           4F0         P1D         0
#>    3:          A    USD           4F0         P1D         0
#>    4:          A    USD           4F0         P1D         0
#>    5:          A    USD           4F0         P1D         0
#>   ---                                                      
#> 6862:          A    USD           4F0         P1D         0
#> 6863:          A    USD           4F0         P1D         0
#> 6864:          A    USD           4F0         P1D         0
#> 6865:          A    USD           4F0         P1D         0
#> 6866:          A    USD           4F0         P1D         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
#>    ---                                                       
#> 13728: 2025-07-23 D.USD.EUR.SP00.A   1.1726    US dollar/Euro
#> 13729: 2025-07-24 D.USD.EUR.SP00.A   1.1756    US dollar/Euro
#> 13730: 2025-07-25 D.USD.EUR.SP00.A   1.1724    US dollar/Euro
#> 13731: 2025-07-28 D.USD.EUR.SP00.A   1.1654    US dollar/Euro
#> 13732: 2025-07-29 D.USD.EUR.SP00.A   1.1533    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
#>    ---                                                                        
#> 13728:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 13729:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 13730:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 13731:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#> 13732:    ECB reference exchange rate, US dollar/Euro, 2.15 pm (C.E.T.)  daily
#>        currency currency_denom exr_type exr_suffix decimals unit_mult
#>          <char>         <char>   <char>     <char>   <char>    <char>
#>     1:      JPY            EUR     SP00          A        2         0
#>     2:      JPY            EUR     SP00          A        2         0
#>     3:      JPY            EUR     SP00          A        2         0
#>     4:      JPY            EUR     SP00          A        2         0
#>     5:      JPY            EUR     SP00          A        2         0
#>    ---                                                               
#> 13728:      USD            EUR     SP00          A        4         0
#> 13729:      USD            EUR     SP00          A        4         0
#> 13730:      USD            EUR     SP00          A        4         0
#> 13731:      USD            EUR     SP00          A        4         0
#> 13732:      USD            EUR     SP00          A        4         0
#>        source_agency time_format   unit collection unit_index_base
#>               <char>      <char> <char>     <char>          <char>
#>     1:           4F0         P1D    JPY          A        99Q1=100
#>     2:           4F0         P1D    JPY          A        99Q1=100
#>     3:           4F0         P1D    JPY          A        99Q1=100
#>     4:           4F0         P1D    JPY          A        99Q1=100
#>     5:           4F0         P1D    JPY          A        99Q1=100
#>    ---                                                            
#> 13728:           4F0         P1D    USD          A        99Q1=100
#> 13729:           4F0         P1D    USD          A        99Q1=100
#> 13730:           4F0         P1D    USD          A        99Q1=100
#> 13731:           4F0         P1D    USD          A        99Q1=100
#> 13732:           4F0         P1D    USD          A        99Q1=100
# }