comtrade_trade_data

Pack: comtrade · Endpoint: https://gateway.pipeworx.io/comtrade/mcp

AUTHORITATIVE bilateral trade data between two countries from UN Comtrade — the official international-trade statistics database (every country’s customs filings, harmonized). Returns trade values USD, quantities, and HS commodity-level detail for imports and exports between reporter + partner. Use for “how much X did US import from China in 2024”, “what does Germany export to Brazil”, “Mexico’s top trade partners by commodity”. UN Comtrade reporter/partner codes (842=US — Comtrade uses 842, NOT the ISO 840; 156=China, 276=Germany, 0=World — see comtrade_country_codes). Annual data, lags ~3 months from reporting period.

Parameters

NameTypeRequiredDescription
reporter_codestringyesCountry name (e.g. “USA”, “China”, “Germany”) or UN numeric code (US=842, China=156). Names are resolved automatically.
partner_codestringyesPartner country name (e.g. “China”) or UN code (156=China, 0=World). Optional — defaults to World (0). Names resolved automatically.
yearstringyesTrade year (e.g., “2024”)
hs_codestringnoHS commodity code at 2/4/6 digit level (e.g., “8471” for computers). Optional — omit for all commodities.
flowstringnoTrade flow: “M” for imports, “X” for exports. Optional — defaults to both “M,X”.

Example call

Arguments

{
  "reporter_code": "842",
  "partner_code": "156",
  "year": "2024"
}

curl

curl -X POST https://gateway.pipeworx.io/comtrade/mcp \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"comtrade_trade_data","arguments":{"reporter_code":"842","partner_code":"156","year":"2024"}}}'

TypeScript (@pipeworx/sdk)

import { Pipeworx } from '@pipeworx/sdk';
const pipeworx = new Pipeworx();

const result = await pipeworx.call('comtrade_trade_data', {
  "reporter_code": "842",
  "partner_code": "156",
  "year": "2024"
});

More examples

{
  "reporter_code": "842",
  "partner_code": "156",
  "year": "2023",
  "hs_code": "8471",
  "flow": "M"
}

Response shape

Always returns: count, year, records

FieldTypeDescription
countnumberNumber of trade records returned
yearstringTrade year queried
recordsarray
Full JSON Schema
{
  "type": "object",
  "properties": {
    "count": {
      "type": "number",
      "description": "Number of trade records returned"
    },
    "year": {
      "type": "string",
      "description": "Trade year queried"
    },
    "records": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "reporter": {
            "type": "string",
            "description": "Reporting country name"
          },
          "partner": {
            "type": "string",
            "description": "Partner country name"
          },
          "flow": {
            "type": "string",
            "description": "Trade flow type (Imports, Exports, Re-exports, Re-imports)"
          },
          "commodity_code": {
            "type": "string",
            "description": "HS commodity code"
          },
          "commodity": {
            "type": "string",
            "description": "Commodity description or code"
          },
          "trade_value_usd": {
            "type": "number",
            "description": "Trade value in USD"
          },
          "net_weight_kg": {
            "type": "number",
            "description": "Net weight in kilograms"
          },
          "quantity": {
            "type": "number",
            "description": "Trade quantity"
          },
          "quantity_unit": {
            "type": "string",
            "description": "Unit of quantity measurement"
          }
        }
      }
    }
  },
  "required": [
    "count",
    "year",
    "records"
  ]
}

Connect

Add this to your MCP client config, or use one-click install buttons:

{
  "mcpServers": {
    "comtrade": {
      "url": "https://gateway.pipeworx.io/comtrade/mcp"
    }
  }
}

See Getting Started for client-specific install steps.

Regenerated from source · build July 21, 2026