The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

comexr comex logo

R-CMD-check CRAN_Status_Badge   CRAN Downloads   License 

R client for the ComexStat API — Brazilian foreign trade statistics from the Ministry of Development, Industry, Trade and Services (MDIC).

Features

Installation

# From GitHub
remotes::install_github("StrategicProjects/comexr")

Quick start

library(comexr)

# Top export destinations in January 2024
exports <- comex_export(
  start_period = "2024-01",
  end_period   = "2024-01",
  details      = "country"
)
exports
#> # A tibble: 219 × 4
#>    year  country          metricFOB    metricKG
#>    <chr> <chr>                <dbl>       <dbl>
#>  1 2024  China           7812623070 19868234567
#>  2 2024  United States   3254810234  2547891234
#>  ...

# Imports with CIF value
imports <- comex_import(
  start_period = "2024-01",
  end_period   = "2024-01",
  details      = "country",
  metric_cif   = TRUE
)

# Filter: exports to China (160), grouped by HS4
soy <- comex_export(
  start_period = "2024-01",
  end_period   = "2024-12",
  details      = c("country", "hs4"),
  filters      = list(country = 160),
  month_detail = TRUE
)

Discover available options

# What grouping fields are available?
comex_details("general")

# What filters can I use?
comex_filters("general")

# Look up country codes
comex_countries(search = "China")

# Economic blocs in Portuguese
comex_blocs(language = "pt")

Function overview

Category Functions
Queries comex_query(), comex_export(), comex_import(), comex_query_city(), comex_historical()
Metadata comex_last_update(), comex_available_years(), comex_filters(), comex_filter_values(), comex_details(), comex_metrics()
Geography comex_countries(), comex_country_detail(), comex_blocs(), comex_states(), comex_state_detail(), comex_cities(), comex_city_detail(), comex_transport_modes(), comex_transport_mode_detail(), comex_customs_units(), comex_customs_unit_detail()
Products comex_ncm(), comex_ncm_detail(), comex_nbm(), comex_nbm_detail(), comex_hs()
Classifications comex_cgce(), comex_sitc(), comex_isic()

Documentation

API Reference

This package wraps the official ComexStat API documented at https://api-comexstat.mdic.gov.br/docs.

License

MIT

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.