get_goldprice_from: Retrieves the gold price from a specific date.

View source: R/endpoint_goldprice.R

get_goldprice_fromR Documentation

Retrieves the gold price from a specific date.

Description

Retrieves the gold price from a specific date.

Usage

get_goldprice_from(date)

Arguments

date

date from which the gold price should be fetched.

Details

As gold prices are not published on the weekends fetching values from a weekend date will result in a 404 error. In those cases the function returns an error with an appropriate message.

Value

nbp_api_response object containing the gold price from the specified date.

See Also

https://api.nbp.pl/#cenyZlota

Other goldprice: get_current_goldprice(), get_goldprice_from_interval(), get_last_n_goldprices(), get_todays_goldprice()

Examples


tryCatch(
  {
    ## Fetch the gold price from a week ago
    response <- get_goldprice_from(Sys.Date() - 7)
    ## Preview response content
    response$content
  },
  error = function(e) message(e)
)



szymanskir/rnbp documentation built on April 12, 2025, 8:51 p.m.