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
#>   ---                                                  
#> 6727: 2025-01-10 D.USD.EUR.SP00.A 1.0304 Euro/US dollar
#> 6728: 2025-01-13 D.USD.EUR.SP00.A 1.0198 Euro/US dollar
#> 6729: 2025-01-14 D.USD.EUR.SP00.A 1.0245 Euro/US dollar
#> 6730: 2025-01-15 D.USD.EUR.SP00.A 1.0300 Euro/US dollar
#> 6731: 2025-01-16 D.USD.EUR.SP00.A 1.0272 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
#>   ---                                                                     
#> 6727: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 6728: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 6729: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 6730: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 6731: ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#>       currency currency_denom exr_type exr_suffix source_agency   unit
#>         <char>         <char>   <char>     <char>        <char> <char>
#>    1:      USD            EUR     SP00          A           4F0    USD
#>    2:      USD            EUR     SP00          A           4F0    USD
#>    3:      USD            EUR     SP00          A           4F0    USD
#>    4:      USD            EUR     SP00          A           4F0    USD
#>    5:      USD            EUR     SP00          A           4F0    USD
#>   ---                                                                 
#> 6727:      USD            EUR     SP00          A           4F0    USD
#> 6728:      USD            EUR     SP00          A           4F0    USD
#> 6729:      USD            EUR     SP00          A           4F0    USD
#> 6730:      USD            EUR     SP00          A           4F0    USD
#> 6731:      USD            EUR     SP00          A           4F0    USD
#>       collection time_format unit_mult decimals
#>           <char>      <char>    <char>   <char>
#>    1:          A         P1D         0        4
#>    2:          A         P1D         0        4
#>    3:          A         P1D         0        4
#>    4:          A         P1D         0        4
#>    5:          A         P1D         0        4
#>   ---                                          
#> 6727:          A         P1D         0        4
#> 6728:          A         P1D         0        4
#> 6729:          A         P1D         0        4
#> 6730:          A         P1D         0        4
#> 6731:          A         P1D         0        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 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
#>    ---                                                       
#> 13458: 2025-01-10 D.USD.EUR.SP00.A   1.0304    Euro/US dollar
#> 13459: 2025-01-13 D.USD.EUR.SP00.A   1.0198    Euro/US dollar
#> 13460: 2025-01-14 D.USD.EUR.SP00.A   1.0245    Euro/US dollar
#> 13461: 2025-01-15 D.USD.EUR.SP00.A   1.0300    Euro/US dollar
#> 13462: 2025-01-16 D.USD.EUR.SP00.A   1.0272    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
#>    ---                                                                        
#> 13458:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 13459:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 13460:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 13461:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#> 13462:    ECB reference exchange rate, Euro/US dollar, 2:15 pm (C.E.T.)  daily
#>        currency currency_denom exr_type exr_suffix source_agency decimals
#>          <char>         <char>   <char>     <char>        <char>   <char>
#>     1:      JPY            EUR     SP00          A           4F0        2
#>     2:      JPY            EUR     SP00          A           4F0        2
#>     3:      JPY            EUR     SP00          A           4F0        2
#>     4:      JPY            EUR     SP00          A           4F0        2
#>     5:      JPY            EUR     SP00          A           4F0        2
#>    ---                                                                   
#> 13458:      USD            EUR     SP00          A           4F0        4
#> 13459:      USD            EUR     SP00          A           4F0        4
#> 13460:      USD            EUR     SP00          A           4F0        4
#> 13461:      USD            EUR     SP00          A           4F0        4
#> 13462:      USD            EUR     SP00          A           4F0        4
#>        time_format unit_mult collection   unit
#>             <char>    <char>     <char> <char>
#>     1:         P1D         0          A    JPY
#>     2:         P1D         0          A    JPY
#>     3:         P1D         0          A    JPY
#>     4:         P1D         0          A    JPY
#>     5:         P1D         0          A    JPY
#>    ---                                        
#> 13458:         P1D         0          A    USD
#> 13459:         P1D         0          A    USD
#> 13460:         P1D         0          A    USD
#> 13461:         P1D         0          A    USD
#> 13462:         P1D         0          A    USD
# }