comtrade.trade.query
Query international merchandise trade statistics from the UN Comtrade database. Returns up to 500 records of imports and/or exports for a specific reporting country, reference period, commodity code, and partner country. Data covers 200+ reporter countries from 1962 (annual) and 2010 (monthly). V...
This record as markdown: /tools/io-github-whiteknightonhorse-apibase/comtrade.trade.query.md
What comtrade.trade.query does on Apibase
AI agents call comtrade.trade.query to retrieve information from Apibase without modifying anything. It is typically the context-gathering step in research, monitoring, and reporting workflows, before the agent takes action elsewhere.
| Parameter | Type | Required | Description |
|---|---|---|---|
period | string | Yes | Reference period to query. Annual: 4-digit year (e.g. "2022"). Monthly: YYYYMM (e.g. "202209" for Sep 2022). Comma-separated for multiple periods (e.g. "2020,20 |
cmd_code | string | — | Commodity code filter. Use HS codes (e.g. "84" for machinery, "27" for petroleum, "TOTAL" for aggregate totals, "AG2" for all 2-digit chapters). Omit to return |
flow_code | string | Yes | Trade flow direction. M=Imports, X=Exports, MX=Both imports and exports, RM=Re-imports, RX=Re-exports. |
freq_code | string | — | Frequency. A=Annual (default), M=Monthly. |
type_code | string | — | Trade data type. C=Commodities (default), S=Services. |
max_records | integer | — | Maximum number of records to return (1–500). Default 100. The public preview API is capped at 500 records per request. |
aggregate_by | string | — | Aggregate results by a dimension. Valid values: "cmdCode", "flowCode", "partnerCode", "reporterCode", "period". Omit to return unaggregated records. |
customs_code | string | — | Customs procedure code filter (e.g. "C00"=all procedures, "C03"=outright export, "C04"=warehousing). Omit for all procedures. |
partner_code | integer | — | UN numeric code for the partner country. 0=World aggregate (all partners combined). Omit to return all individual partners. |
partner2_code | integer | — | Secondary partner code for extended trade flow tracking (consignment country). 0=World aggregate. Omit to use the default world aggregate. |
reporter_code | integer | Yes | UN numeric code for the reporting country (e.g. 276=Germany, 840=USA, 156=China, 826=UK). Use comtrade.reporters to look up codes. |
classification | string | — | Commodity classification system. HS=Harmonized System (default, most common). B4/B5=BEC, EB=EBOPS services, S1-S4/SS=SITC revisions. |
Parameters from the server's own tool schema.
Why comtrade.trade.query is rated Low
Tool retrieves historical trade data from public UN database with no side effects or modifications.
From the tool's definition Query international merchandise trade statistics, returns up to 500 records, retrieves data
Risk signalsHigh parameter count (12 properties)
Attacks that exploit this kind of access
The rule that runs comtrade.trade.query safely
PolicyLayer is an MCP gateway: it sits between your AI agents and Apibase, and checks every tool call against a rule you set before the call runs. Nothing changes on the server itself. For comtrade.trade.query, this is the rule to start with:
comtrade.trade.query is read-only, so it stays allowed. Everything else on the server is denied unless you say otherwise.
The button opens the PolicyLayer dashboard: create your workspace, connect Apibase, apply this rule, and every comtrade.trade.query call is checked against it from then on.
Questions about comtrade.trade.query
Query international merchandise trade statistics from the UN Comtrade database. Returns up to 500 records of imports and/or exports for a specific reporting country, reference period, commodity code, and partner country. Data covers 200+ reporter countries from 1962 (annual) and 2010 (monthly). Values in USD (primary value), CIF for imports, FOB for exports. Commodities classified by Harmonized System (HS) or SITC. Use reporter_code from comtrade.reporters, HS chapter codes (e.g. "84" for machinery, "27" for petroleum, "85" for electronics), and flow_code M=imports, X=exports. Source: UN Comtrade public preview API, no auth, 500 calls/day free. It is categorised as a Read tool in the Apibase MCP Server, which means it retrieves data without modifying state.
comtrade.trade.query accepts 12 parameters: period, cmd_code, flow_code, freq_code, type_code, max_records, aggregate_by, customs_code, partner_code, partner2_code, reporter_code, classification. Required: period, flow_code, reporter_code. The full parameter table on this page comes from the server's own tool schema.
Register the Apibase MCP server in PolicyLayer and add a rule for comtrade.trade.query: allow, deny, rate-limit, or require approval. Point your MCP client at the PolicyLayer proxy URL and the rule is enforced on every call, before it reaches Apibase. Nothing to install.
comtrade.trade.query is a Read tool with low risk. Read-only tools are generally safe to allow by default.
Yes. Add a rate_limit block to the comtrade.trade.query rule in your PolicyLayer policy. For example, setting max: 10 and window: 60 limits the tool to 10 calls per minute. Rate limits are tracked per agent session and reset automatically.
Set action: deny in the PolicyLayer policy for comtrade.trade.query. The AI agent will receive a policy violation error and cannot call the tool. You can also include a reason field to explain why the tool is blocked.
comtrade.trade.query is provided by the Apibase MCP server (apibase-mcp-client). PolicyLayer sits as a proxy in front of this server to enforce policies before tool calls reach the server.
More on Apibase, and thousands of servers like it.
This server
Across the catalogue