Title: | Access 'BCRPDATA' API |
Version: | 1.0.1 |
Description: | Search and access more than ten thousand datasets included in 'BCRPDATA' (see https://estadisticas.bcrp.gob.pe/estadisticas/series/ayuda/bcrpdata for more information). |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Imports: | httr2, readr, tibble, yyjsonr |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
URL: | https://github.com/JulioCollazos64/bcRP |
BugReports: | https://github.com/JulioCollazos64/bcRP/issues |
NeedsCompilation: | no |
Packaged: | 2025-07-22 04:06:16 UTC; julio |
Author: | Julio Collazos |
Maintainer: | Julio Collazos <amarullazo626@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-07-22 12:10:12 UTC |
Perform an API request to BCRPData
Description
Perform an API request to BCRPData
Usage
get_bcrp_data(
codes,
from = NA,
to = NA,
request_strategy = c("sequential", "parallel")
)
Arguments
codes |
A character vector with valid BCRPData series codes, see the |
from |
A character vector of length 1, usually a year see Details. Optional. |
to |
A character vector of length 1. Must be greater than the
|
request_strategy |
Either "sequential" (default) or "parallel". This defines the strategy to be followed when making requests for more than one code. Visit httr2 for more details. |
Details
It is possible to specify only the from
or to
arguments in which case the request to the BCRPData API would only take into consideration the non-missing argument, if both are ommited the API will respond with the latest data.
BCRPData has data of different frequencies, it's important to consider that when defining the from
and to
arguments. Here's a list you can use to define the most suitable values to the from
and to
arguments.
Yearly: Provide a year, e.g 2018
Quarterly: Provide a year followed by a hyphen followed by the quarter in its numerical value, e.g 2018-2
Monthly: Provide a year followed by a hyphen followed by the month in its numerical value, e.g 2018-5
Daily: Provide a year followed by a hyphen followed by the month and followed by the day, e.g 2018-5-5
This function will try to get all the valid codes you provided in its codes
argument, if one of the requests fails it will stop its execution for all the codes and return an error, pointing out which codes caused this.
Value
Data frame with code-level observations.
Author(s)
Julio Collazos.
Examples
codes <- c("PN00009MM", "PN00002MM", "PN01270PM", "PD39557DA")
# Will get you the most recent data for these codes
# as you have not provided the `from` and `to` arguments.
get_bcrp_data(codes = codes)
# You can also provide the range of dates
# through the `from` and `to` arguments.
get_bcrp_data(codes = codes, from = "2015-01", to = "2020-01")
# If needed, you can sometimes speed up your data API calls
# by performing them in parallel. In this example we are
# querying just 5 codes so the benefits of parallelism does not
# outweigh its cost, making the request slower.
## Not run:
get_bcrp_data(codes = codes, request_strategy = "parallel")
## End(Not run)
Access metadata for all available datasets provided by the Peruvian Central Bank
Description
Access metadata for all available datasets provided by the Peruvian Central Bank
Usage
get_bcrp_metadata()
Value
A data frame with one row per code available for request.
Author(s)
Julio Collazos
Examples
# No arguments required, simply call the function.
get_bcrp_metadata()