Package: comexr 0.3.1

Andre Leite

comexr: Client for the Brazilian Foreign Trade Statistics API ('ComexStat')

Interface to the 'ComexStat' API <https://comexstat.mdic.gov.br/> from the Brazilian Ministry of Development, Industry, Trade and Services (MDIC). Provides access to detailed export and import data, including general trade statistics (1997-present), city-level data, historical data (1989-1996), and auxiliary tables with product codes (NCM - Nomenclatura Comum do Mercosul, NBM - Nomenclatura Brasileira de Mercadorias, HS - Harmonized System), countries, economic classifications (CGCE - Classificacao por Grandes Categorias Economicas, SITC - Standard International Trade Classification, ISIC - International Standard Industrial Classification), and other categories. Uses only 'httr2' for HTTP requests and 'cli' for console messages.

Authors:Andre Leite [aut, cre], Marcos Wasilew [aut], Hugo Vasconcelos [aut], Carlos Amorim [aut], Diogo Bezerra [aut]

comexr_0.3.1.tar.gz
comexr_0.3.1.zip(r-4.7)comexr_0.3.1.zip(r-4.6)comexr_0.3.1.zip(r-4.5)
comexr_0.3.1.tgz(r-4.6-any)comexr_0.3.1.tgz(r-4.5-any)
comexr_0.3.1.tar.gz(r-4.7-any)comexr_0.3.1.tar.gz(r-4.6-any)
comexr_0.3.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
comexr/json (API)

# Install 'comexr' in R:
install.packages('comexr', repos = c('https://strategicprojects.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/strategicprojects/comexr/issues

Pkgdown/docs site:https://strategicprojects.github.io

On CRAN:

Conda:

5.78 score 30 scripts 456 downloads 30 exports 14 dependencies

Last updated from:0781586666. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK131
source / vignettesOK178
linux-release-x86_64OK135
macos-release-arm64OK93
macos-oldrel-arm64OK89
windows-develOK93
windows-releaseOK67
windows-oldrelOK108
wasm-releaseOK114

Exports:comex_available_yearscomex_blocscomex_cgcecomex_citiescomex_city_detailcomex_countriescomex_country_detailcomex_customs_unit_detailcomex_customs_unitscomex_detailscomex_exportcomex_filter_valuescomex_filterscomex_historicalcomex_hscomex_importcomex_isiccomex_last_updatecomex_metricscomex_nbmcomex_nbm_detailcomex_ncmcomex_ncm_detailcomex_querycomex_query_citycomex_sitccomex_state_detailcomex_statescomex_transport_mode_detailcomex_transport_modes

Dependencies:askpassclicurlgluehttr2lifecyclemagrittropensslR6rappdirsrlangsysvctrswithr

Full state trade profile (Pernambuco example)
1. Look up the state code | 2. Build the query parameters | 3. Fetch exports and imports | 4. Cast metrics and add a date column | 5. Monthly trade balance | 6. Top municipalities by flow | 7. Top products (HS4) | 8. Top trading partners (countries) | 9. Cross-cuts (country × product, city × product) | 10. Year-over-year comparison | 11. Adapt to any state

Last update: 2026-05-21
Started: 2026-05-21

Auxiliary Tables & Lookups
Countries and economic blocs | Countries | Economic blocs | Geographic tables | States (UF) | Cities | Transport modes | Customs units (URF) | Product nomenclatures | NCM — Mercosur Common Nomenclature (1997–present) | NBM — Brazilian Nomenclature of Goods (historical, 1989–1996) | HS — Harmonized System | Classification tables | CGCE — Classification by Broad Economic Categories (BEC) | SITC — Standard International Trade Classification (CUCI) | ISIC — International Standard Industrial Classification | Using table codes in queries | Pagination | Runtime discovery

Last update: 2026-05-21
Started: 2026-02-18

Building a city trade profile (replicating the ComexStat municipality page)
What the city endpoint exposes | 1. Headline totals (FOB and net weight) | 2. Top trading partners | 3. Top economic blocs | 4. Top products (HS4 / heading) | 5. Monthly time series | 6. Year-over-year comparison | 7. Cross-cutting query: top destinations by product | Looking up the city code from a name | Tips

Last update: 2026-05-21
Started: 2026-05-21

Getting Started with comex
Overview | Installation | Quick start | 1. Check what data is available | 2. Run a simple export query | 3. Add filters and multiple details | 4. Look up auxiliary tables | Available detail names | Language support | Next steps

Last update: 2026-05-21
Started: 2026-02-18

Querying Trade Data
Basic queries | Exports by country | Imports with CIF value | Monthly breakdown | Multiple grouping fields | Applying filters | The generic comex_query() | City-level queries | Historical data (1989–1996) | Working with results | Tips and best practices

Last update: 2026-05-21
Started: 2026-02-18