Skip to content

API Reference

The API reference is generated from the SDK's docstrings via mkdocstrings. No manual editing of API pages is permitted; any docstring change propagates to this site on the next build.

Sections

Section Module What it covers
ComtradeClient un_comtrade.client The single public entry point; constructor, properties, context manager.
Metadata un_comtrade.metadata MetadataService and the country / partner / HS-code / unit accessors.
Trade un_comtrade.trade TradeService and the annual / monthly / tariffline accessors.
Analytics un_comtrade.analytics AnalyticsEngine and the country / partner / commodity / time-series / balance / comparison functions.
ETL un_comtrade.etl ETLFacade and the pipeline factory.
Storage un_comtrade.storage StorageRegistry and the four backend writers / readers.
CLI un_comtrade.cli Console script entry points (CLI surface).
Models un_comtrade.models CanonicalDataset, TradeRecord, Country, HSCode, and friends.
Exceptions un_comtrade.exceptions ComtradeError and the typed exception hierarchy.

Public SDK surface

Per protocol §1.2 (Public SDK only), this reference documents only the public surface exported via un_comtrade/__init__.py's __all__, the public submodules, and the documented surface in docs/007_SDK_SPECIFICATION.md. Internal modules (anything starting with _) are excluded by mkdocstrings configuration (filters: ["!^_"]).

Examples

from un_comtrade import ComtradeClient

with ComtradeClient() as client:
    countries = client.metadata.get_countries()       # -> list[Country]
    exports = client.trade.get_exports(699, "2022")   # -> CanonicalDataset
    top = client.analytics.top_partners(exports, by="exports", limit=5)

Next steps