GnistAI GnistAI
Log in

UN Comtrade

International trade statistics — imports, exports, and commodity flows between countries.

Overview   |   MCP Docs   |   API Docs   |   OpenAPI   |   Playground   |   Tutorial   |   Toolkits   |   Home
status: healthy status status healthy healthy tools: 6 tools tools 6 6 Economics

Data source: UN Comtrade

MCP MCP Protocol

Endpoint https://context.gnist.ai/mcp/un-comtrade/
claude_desktop_config.json
{
  "mcpServers": {
    "gnist-un-comtrade": {
      "url": "https://context.gnist.ai/mcp/un-comtrade/",
      "headers": {
        "Gnist-API-Key": "YOUR_API_KEY"
      }
    }
  }
}
Shell
curl -X POST "https://context.gnist.ai/mcp/un-comtrade/" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_trade_flow", "arguments": {"reporter": "example", "partner": "example", "commodity_code": "example"}}}'

API REST API

API Root https://context.gnist.ai/rest/un-comtrade/

6 endpoints available:

Shell
curl "https://context.gnist.ai/rest/un-comtrade/get_trade_flow?reporter=example&partner=example&commodity_code=example" \
  -H "Gnist-API-Key: YOUR_API_KEY"
Python
import httpx

resp = httpx.get(
    "https://context.gnist.ai/rest/un-comtrade/get_trade_flow",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    params={
        "reporter": "example",
        "partner": "example",
        "commodity_code": "example"
},
)
print(resp.json())

OpenAPI Spec  ·  Full API Docs

CLI Command Line

Command gc un-comtrade

CLI documentation will be available when the GnistAI SDK is published.

Install
pip install gnistai

Available Tools (6)

get_trade_flow
Fetch bilateral trade flows between two countries for a commodity.
ParameterTypeRequiredDescription
reporterstringrequiredReporting country name or ISO numeric code (e.g., "Germany", "276").
partnerstringrequiredPartner country name or ISO numeric code (e.g., "China", "156"). Use "World" or "0" for global aggregates.
commodity_codestringrequiredHS commodity code (e.g., "8471" for computers, "27" for fuels, "TOTAL" for all commodities). Use search_commodities to find codes.
year_fromanyoptionalStart year (e.g., 2018). If omitted, returns most recent year.
year_toanyoptionalEnd year (e.g., 2022). If omitted, same as year_from.
flowstringoptionalTrade direction — "M" (imports), "X" (exports), "MX" (both, default). (default: "MX")
top_partners
Rank a country's top trading partners for a given commodity.
ParameterTypeRequiredDescription
reporterstringrequiredReporting country name or ISO numeric code (e.g., "Germany", "276").
commodity_codestringrequiredHS commodity code (e.g., "87" for vehicles). Use "TOTAL" for all trade.
yearintegerrequiredYear (e.g., 2022).
flowstringoptional"X" for exports (default) or "M" for imports. (default: "X")
limitintegeroptionalNumber of top partners to return (1–50, default 10). (default: 10)
top_commodities
Rank the top commodities traded between two countries.
ParameterTypeRequiredDescription
reporterstringrequiredReporting country name or ISO numeric code (e.g., "Germany", "276").
partnerstringrequiredPartner country name or ISO numeric code (e.g., "China", "156").
yearintegerrequiredYear (e.g., 2022).
flowstringoptional"X" for exports (default) or "M" for imports. (default: "X")
limitintegeroptionalNumber of top commodities to return (1–50, default 10). (default: 10)
search_commodities
Search for HS commodity codes by keyword.
ParameterTypeRequiredDescription
querystringrequiredKeyword to search (e.g., "steel", "petroleum", "machinery", "vehicles").
trade_balance
Calculate bilateral trade balance between two countries.
ParameterTypeRequiredDescription
reporterstringrequiredReporting country name or ISO numeric code (e.g., "Germany", "276").
partnerstringrequiredPartner country name or ISO numeric code (e.g., "China", "156").
yearintegerrequiredYear (e.g., 2022).
report_feedback
Report a bug, feature request, or general feedback for this data source.
ParameterTypeRequiredDescription
feedbackstringrequired
feedback_typestringoptional (default: "general")

Related