Get Top Trading Partners
comtrade_get_top_partnersRank trading partners for a reporter by trade value for a given commodity and flow direction. Returns the top N partners sorted by descending value — answers "who does country X mainly export product Y to?" or "where does country X mainly import product Z from?" for a single period. Fetches a disaggregated breakdown across all partners then sorts locally. Takes an HS or SITC code in the selected classification; omit cmd_code to rank partners for total trade.
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_partners"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of top partners to return; totalPartners counts every partner retrieved. | |
| period | Yes | Single period: annual YYYY or monthly YYYYMM, month 01–12; frequency is inferred. | |
| cmd_code | No | Single goods code in the selected classification: HS (e.g. "84", "8471") or SITC (e.g. "071"). Omit or pass "TOTAL" to rank partners for total merchandise trade. | |
| flow_code | Yes | Trade flow: M=imports, X=exports. | |
| reporter_code | Yes | M49 numeric code of the reporting country (0–999). | |
| classification | No | Goods classification: HS as reported, H0–H6 with authenticated access, or SITC S1–S4/SS. | HS |
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. | |
| period | No | Period queried. | |
| cmdCode | No | Commodity code queried (TOTAL when omitted). | |
| flowCode | No | Flow direction queried. | |
| partners | No | Top partners sorted by descending trade value. | |
| truncated | No | True when API returned 500 records and results may be incomplete. | |
| reporterCode | No | M49 reporter code. | |
| reporterDesc | No | Reporter country name. | |
| totalPartners | No | Partners retrieved before the limit, excluding the World (0) aggregate. | |
| totalValueUsd | No | Sum of primary values across all returned partners (before limit truncation). | |
| classification | No | Goods classification the commodity code was read in. | |
| referenceNotice | No | Reference descriptions unavailable; codes and values retained. |