Skip to contents

Query the historical data endpoint of the ComexStat API to retrieve Brazilian export and import data from 1989 to 1996, before the SISCOMEX system was implemented. Historical data uses the NBM (Brazilian Nomenclature of Goods) classification.

Usage

comex_historical(
  flow = "export",
  start_period,
  end_period,
  details = NULL,
  filters = NULL,
  month_detail = TRUE,
  metric_fob = TRUE,
  metric_kg = TRUE,
  language = "en",
  verbose = TRUE
)

Arguments

flow

Trade flow: "export" or "import".

start_period

Start period in "YYYY-MM" format (e.g. "1990-01").

end_period

End period in "YYYY-MM" format (e.g. "1996-12").

details

Character vector of detail/grouping fields. The historical endpoint supports only: "country", "bloc" ("economic_block"), "state", "nbm".

filters

Named list of filters. Accepts the same names as details ("country", "bloc", "state", "nbm").

month_detail

Logical. If TRUE, break down by month. Default: TRUE.

metric_fob

Logical. Include FOB value (US$). Default: TRUE.

metric_kg

Logical. Include net weight (kg). Default: TRUE.

language

Response language: "pt", "en", or "es". Default: "en".

verbose

Logical. Show progress messages. Default: TRUE.

Value

A data.frame (or tibble if available) with query results. Metric columns (metricFOB, metricKG, ...) are numeric and year / monthNumber are integer; all other columns are character.

Details

Historical data differs from general data:

  • Available period: 1989 to 1996 only

  • Limited details: "country", "state", "nbm"

  • Product classification is NBM (not NCM)

  • Only FOB and KG metrics are available (no statistic, freight, insurance, or CIF)

  • The API ignores the months in the period and always returns whole years. With month_detail = TRUE the result is trimmed to the requested months; with month_detail = FALSE the yearly totals cover full years and a warning is issued if the period is not whole years.

Examples

if (FALSE) { # \dontrun{
# Historical exports 1995-1996 by country
comex_historical(
  flow = "export",
  start_period = "1995-01",
  end_period = "1996-12",
  details = "country"
)
} # }