Interface with the United Nations Comtrade API
Overview
Interface with and extract data from the United Nations 'Comtrade' API https://comtradeplus.un.org/. 'Comtrade' provides country level shipping data for a variety of commodities, these functions allow for easy API query and data returned as a tidy data frame.
Minor improvements
- Replaced the
poormandependency (scheduled for archival on CRAN) withdplyr. This does not add any new transitive dependencies, as all ofdplyr's dependencies were already required through other imports.
Bug fixes
ct_get_bulk()now validates thefrequencyargument instead of failing with an obscureobject 'date_range' not founderror.- Invalid
partner/partner_2values now produce a readable error message that lists each invalid code once, instead of repeating the message for every code. ct_migrate_cache()no longer fails withargument "message" is missingwhen reporting a failed copy.
Show all changes in 1.0.6Hide the rest of the changes in 1.0.6
- Fixed HTTP 414 "URI Too Long" errors when querying long code lists, e.g.
partner = "all_countries"(#103). The Comtrade API rejects URLs longer than about 2000 characters.ct_get_data()now detects this before performing the request, transparently splits the partner and/or reporter codes into multiple requests and combines the results into a single data.frame. Withprocess = FALSEsplitting is not possible (a single response object is returned) and a warning is issued instead.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-05-28
- ERROR12 OK, 1 ERROR2026-05-27
- OK14 OK2026-04-09
Show 2 earlier changesHide 2 earlier changes
- ERROR11 OK, 3 ERROR2026-04-02
- OK14 OK2026-03-10
Documentation
- Help pages
- 18 (1 internal)includes a package overview page
- Examples that run
- 43%6 run in a plain check (6 of them under a condition) · 8 never run
- Exported functions with examples
- 93%
- Documented parameters
- 100%
- Return-value docs
- 100%
- Help pages citing references
- 0%
- comtradr HTML
- bulk_files HTML
- caching HTML
- large_data HTML
- transition HTML
Downloads
Repository
- PRs merged (all time)
- 94%
- Median days to close, 50 most recently updated closed issues
- 108
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Releases over time
Issues over time
Commits over time
12 development-tooling and community-health practices detected across 9 families in the upstream repository
Checks run against github.com/ropensci/comtradr on 2026-10-18.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
Show all practicesHide 5 practices
Dependencies
Installing comtradr adds 41 packages (26 with compiled code, 23 MB of source tarballs). Heaviest: stringi 11 MB, fs 1.4 MB, openssl 1.1 MB.
Code & Tests
Datasets
People & History
Previously maintained by Chris Muir (0.0.1 to 0.3.0).
Pick two releases to compare their code metrics.
- 1.0.6Latest
- RR 4.6.0 released · 2026-04-24
- 1.0.52025-12-15 · diff ↗
- 1.0.42025-09-27 · diff ↗
- RR 4.5.0 released · 2025-04-11
- 1.0.32024-11-15 · diff ↗
- 1.0.22024-09-20 · diff ↗
- unarchivedReturned to CRAN2024-05-24
- 1.0.1
- archivedRemoved from CRAN2024-05-18policy violation Uses and leaves files/directories behind in the user's cache directory
- 1.0.0
- RR 4.4.0 released · 2024-04-24
- unarchivedReturned to CRAN2024-02-06
- 0.4.0.02024-02-06 · diff ↗ ·
added 4 exports
ct_get_data, ct_get_ref_table, get_primary_comtrade_key, set_primary_comtrade_key - RR 4.3.0 released · 2023-04-21
- archivedRemoved from CRAN2023-04-12the request of the maintainer
Show 15 earlier eventsHide 15 earlier events
- RR 4.2.0 released · 2022-04-22
- 0.3.02022-04-20 · diff ↗
- RR 4.1.0 released · 2021-05-18
- RR 4.0.0 released · 2020-04-24
- RR 3.6.0 released · 2019-04-26
- 0.2.22018-10-05 · diff ↗
- unarchivedReturned to CRAN2018-05-05
- 0.2.12018-05-05 · diff ↗
- RR 3.5.0 released · 2018-04-23
- 0.1.02017-10-24 · diff ↗ ·
removed 4 exports
commodity_lookup, country_lookup, ct_commodities_table, ct_countries_tableadded 8 exports
ct_commodity_db_type, ct_commodity_lookup, ct_country_lookup, ct_get_remaining_hourly_queries, ct_get_reset_time, ct_register_token, ct_update_databases, ct_use_pretty_cols - 0.0.22017-07-04 · diff ↗
- archivedRemoved from CRAN2017-05-30requested by the maintainer <chrismuirRVA@gmail.com>
- RR 3.4.0 released · 2017-04-21
- 0.0.12017-04-05
- RR 3.3.0 released · 2016-05-03
Package metadata
- First published
- 2017-04-05
- Total releases
- 14 / 9 yrs
- License
- GPL-3 OSI
- Minimum R
- ≥ 4.1.0
- Bundled data
- 7.0 KB / 2 files
- Download size
- 3.3 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("comtradr")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-21, which the citation names so these numbers can be found later. More on citing and the projects behind them.