| Title: | Download Data from the Bank of Mexico |
|---|---|
| Description: | Accesses observations and metadata from the Bank of Mexico SIE REST API with authenticated requests, typed long-format results, and compatibility adapters for legacy callers. |
| Authors: | Eduardo Flores [aut, cre] |
| Maintainer: | Eduardo Flores <[email protected]> |
| License: | CC0 |
| Version: | 0.9.0.9000 |
| Built: | 2026-10-15 21:29:31 UTC |
| Source: | https://github.com/eflores89/banxicor |
Uses the authenticated SIE REST API. Obtain a token from Banxico and configure
BANXICO_TOKEN or use banxico_set_token(). Metadata retrieval is explicit.
banxico_data( series, start_date = NULL, end_date = NULL, token = banxico_get_token(), language = "es" ) banxico_latest(series, token = banxico_get_token(), language = "es") banxico_metadata(series, token = banxico_get_token(), language = "es")banxico_data( series, start_date = NULL, end_date = NULL, token = banxico_get_token(), language = "es" ) banxico_latest(series, token = banxico_get_token(), language = "es") banxico_metadata(series, token = banxico_get_token(), language = "es")
series |
Character vector of alphanumeric series identifiers. |
start_date, end_date
|
Inclusive date bounds as scalar Dates or ISO YYYY-MM-DD strings. Two bounds use the range endpoint; a single bound filters full history locally. |
token |
API token, defaulting to |
language |
API locale: |
banxico_data() and banxico_latest() return a data.frame with
provider, series_id, title, period, date (Date), value (double), and value_raw
columns. Raw API periods and unavailable observations are retained. Rows
follow requested series order and ascending dates within each series.
banxico_metadata() returns provider, series_id, title and available raw
API metadata fields; unavailable titles are NA. Empty data is typed.
## Not run: # First configure BANXICO_TOKEN locally with your registered token. x <- banxico_data(c("SF43718", "SF110168"), start_date = "2025-01-01", end_date = "2025-12-31") banxico_latest("SF43718") banxico_metadata("SF43718") ## End(Not run)## Not run: # First configure BANXICO_TOKEN locally with your registered token. x <- banxico_data(c("SF43718", "SF110168"), start_date = "2025-01-01", end_date = "2025-12-31") banxico_latest("SF43718") banxico_metadata("SF43718") ## End(Not run)
Uses the session token configured by banxico_set_token(), falling back to
the BANXICO_TOKEN environment variable. Treat the returned value as secret.
banxico_get_token()banxico_get_token()
A validated scalar character token.
Configure a Banxico token for this R session
banxico_set_token(token)banxico_set_token(token)
token |
A nonempty character token without whitespace or control characters. |
Invisibly returns NULL. The token is stored only in the session environment.
A dataset containing the id's for some Banxico series.
BanxicoCatalogBanxicoCatalog
A data frame with 133 rows and 9 variables:
Parent or theme of data series
Level one category
Level two category
Level three category
Level four category
Level five category
Level six category
Frequency of data (i.e. monthly)
ID to pass to banxico series
Uses banxico_series() with metadata requested explicitly. Configure
BANXICO_TOKEN or use banxico_set_token() before calling without a token.
compact_banxico_series( series, token = banxico_get_token(), start_date = NULL, end_date = NULL, language = "es" )compact_banxico_series( series, token = banxico_get_token(), start_date = NULL, end_date = NULL, language = "es" )
series |
A single character series identifier. |
token |
API token, defaulting to |
start_date, end_date
|
Inclusive scalar Date or ISO YYYY-MM-DD bounds. |
language |
API locale, either "es" or "en". |
A data.frame with Dates, an ID-named numeric value column, and IndicatorName, IndicatorId, Units, DataType, Period and Frequency repeated per observation. Unavailable metadata is NA; empty data has zero rows.
Eduardo Flores
Retained helpers for historical quarterly labels and IQY metadata text. These helpers do not contact the API.
banxico_parsetrim(string, trim_begin = TRUE) banxico_parsemeta(slist, lookfor, exclude = FALSE)banxico_parsetrim(string, trim_begin = TRUE) banxico_parsemeta(slist, lookfor, exclude = FALSE)
string |
A single quarterly label such as |
trim_begin |
Logical; select the quarter's first month when TRUE. |
slist |
Character vector of legacy metadata lines. |
lookfor |
Regular expression selecting metadata lines. |
exclude |
Logical; exclude matching lines when TRUE. |
With trim_begin = FALSE, the quarterly helper returns the first
day of the quarter's final month, not the quarter's last calendar day.
Unrecognized labels warn and return their nonnumeric text.
banxico_parsetrim() returns a Date for recognized labels, otherwise
character text. banxico_parsemeta() returns lowercase character values
with the text preceding the first colon removed.
# trimester string <- "Jan-Mar 2015" trim <- banxico_parsetrim(string)# trimester string <- "Jan-Mar 2015" trim <- banxico_parsetrim(string)
Legacy adapters retain their original column names and argument positions.
API access now requires a token: set BANXICO_TOKEN or call
banxico_set_token(). For multiple series and raw values use banxico_data().
banxico_series( series, metadata = FALSE, verbose = FALSE, mask = FALSE, token = banxico_get_token(), start_date = NULL, end_date = NULL, language = "es" ) banxico_series2( series, token = banxico_get_token(), metadata = FALSE, mask = FALSE, start_date = NULL, end_date = NULL, language = "es" )banxico_series( series, metadata = FALSE, verbose = FALSE, mask = FALSE, token = banxico_get_token(), start_date = NULL, end_date = NULL, language = "es" ) banxico_series2( series, token = banxico_get_token(), metadata = FALSE, mask = FALSE, start_date = NULL, end_date = NULL, language = "es" )
series |
A single character series identifier. |
metadata |
Logical; include legacy metadata (or Name in banxico_series2). |
verbose |
Logical; print a safe observation count after retrieval. |
mask |
Logical; use Values or Value instead of an ID-named value column. |
token |
API token, defaulting to |
start_date, end_date
|
Inclusive scalar Date or ISO YYYY-MM-DD bounds. |
language |
API locale, either "es" or "en". |
banxico_series returns Dates and an ID-named numeric column (Values when masked), or a list with MetaData and Data. MetaData contains IndicatorName, IndicatorId, Units, DataType, Period and Frequency; fields unavailable from the API are NA. banxico_series2 returns Date and an ID-named numeric column (Value when masked), plus Name if requested. Missing observations remain rows with NA values.
Eduardo Flores