Get Top Trade Commodities
comtrade_get_top_commoditiesRank HS chapters (2-digit) or headings (4-digit) by trade value for one reporter, flow, and annual or monthly period. Set parent_code and a deeper aggr_level to rank headings or subheadings within one chapter or heading. The tool uses matching TOTAL to identify the HS edition and queries explicit commodity codes in chunks, subdividing capped chunks. Shares use matching TOTAL or the reported parent value for a drill-down. Incomplete coverage returns available categories without ranks or shares and identifies unresolved codes. Defaults to World; optionally select one bilateral partner. Counterpart to comtrade_get_top_partners.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"reporter_code": "<reporter_code>",
"flow_code": "<flow_code>",
"period": "<period>"
},
"name": "comtrade_get_top_commodities"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of top commodity categories to return; totalCommodities counts every category retrieved. | |
| period | Yes | Single period: annual (YYYY) or monthly (YYYYMM, month 01–12). | |
| flow_code | Yes | Trade flow: M=imports, X=exports. | |
| aggr_level | No | HS aggregation level: 2 = chapter, 4 = heading, 6 = subheading. Level 6 requires parent_code. | |
| parent_code | No | Two-digit HS chapter or four-digit heading. Supply a deeper aggr_level. Blank is treated as omitted. | |
| partner_code | No | M49 partner code (0–999) for a bilateral relationship; omit for World aggregate (0). | |
| reporter_code | Yes | M49 numeric code of the reporting country (0–999). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Present when the call failed. Absent on success. | |
| notice | No | Recovery hint when no data is returned, naming the code to query instead of a partner-only reporter_code (250 → 251, 158 → 490) or of a partner_code with a reporter-valid counterpart (840 → 842, 158 → 490); or what a residual row holds when it is on the returned page. | |
| period | No | Period queried. | |
| flowCode | No | Flow direction queried. | |
| aggrLevel | No | HS aggregation level used. | |
| truncated | No | True when complete commodity-code coverage could not be established. | |
| parentCode | No | HS chapter or heading selected for the drill-down. | |
| commodities | No | Top commodity categories sorted by descending trade value. | |
| missingCodes | No | Codes whose retrieval failed, remained capped, or did not fit the call's time budget; empty when the code universe is unavailable. | |
| reporterCode | No | M49 reporter code. | |
| reporterDesc | No | Reporter country name. | |
| totalValueUsd | No | Sum of primary values across all returned categories (before limit). | |
| coverageNotice | No | Explanation of coverage and ranking availability. | |
| coverageComplete | No | Whether complete coverage was established for the matching HS edition and requested scope. | |
| totalCommodities | No | Total commodity categories returned by API. | |
| classificationCode | No | HS edition identified by matching TOTAL. | |
| denominatorValueUsd | No | Matching parent or TOTAL value used as the share denominator, separate from the retrieved-category sum. |