Metadata via the CLI¶
The metadata command browses the UN Comtrade reference catalogues.
Five sub-subcommands cover countries, partners, HS codes, search,
and refresh.
Purpose¶
This page covers each metadata sub-subcommand in detail, with
flags, output formats, and shell-composition patterns.
Prerequisites¶
un-comtrade-sdkinstalled.- The
un-comtradescript on yourPATH.
Walkthrough¶
List countries¶
Output (default json):
List partner countries¶
List HS codes at a level¶
un-comtrade metadata hs-codes --level 2 # HS chapters
un-comtrade metadata hs-codes --level 4 # HS headings
un-comtrade metadata hs-codes --level 6 # HS subheadings
Search HS codes by description¶
Refresh the catalogue¶
Forces a re-download of every catalogue. Rate-limited to one HTTP call per second.
Examples¶
A Markdown table of the top-20 countries by population-equivalent rank (the catalogue is sorted by reporter code):
Pipe the country catalogue to jq for filtering:
un-comtrade metadata countries --output-format json \
| jq '[.[] | select(.iso_alpha3 == "IND")]'
# → [{"country_code": 699, "iso_alpha3": "IND", "display_name": "India"}]
Search HS codes for "machinery":
Related Recipes¶
- RECIPE-091 — Drive metadata commands from the CLI.
Related Guides¶
- CLI → Trade — uses the country catalogue to resolve reporter / partner codes.
- Python SDK → Metadata — equivalent Python API.
Next steps¶
- CLI → Trade — apply the catalogue to a real trade query.
- Cookbook → metadata recipes — full executable forms.