MARKETS & FINANCE
UN Comtrade Trade Flow Watch
Bilateral commodity trade flows from UN Comtrade's official free API: annual trade records per reporter, partner, HS code and year, with values, weights and quantities, per-pair aggregates…
About this data
Bilateral commodity trade flows from UN Comtrade's official free API: annual trade records per reporter, partner, HS code and year, with values, weights and quantities, per-pair aggregates and change vs previous run. Official UN open data, no key needed. Latest published year per reporter.
From the actor’s Apify Store listing. The per-call endpoint may return a bounded subset; its own description is below.
Buy per call over x402
One endpoint at api.ssh.autos. Each call is one JSON POST, paid in USDC with no account or API key, and answered in the same HTTP response.
UN Comtrade Trade Flows
POST /v1/comtrade/trade
Annual bilateral commodity trade from UN Comtrade's official API for one reporter, partner, HS code and year: imports and exports with trade value in USD, net weight and quantity.
Up to 10 records per call.
Input
Send a JSON body to POST https://api.ssh.autos/v1/comtrade/trade.
| Field | Type | Required | Notes |
|---|---|---|---|
reporter | string | required | 2–60 characters |
partner | string | optional | up to 60 characters; default "world" |
cmdCode | string | optional | pattern ^\d{2,8}$; default "8517" |
period | integer | required | 2010–2100 |
maxResults | integer | optional | 1–10; default 5 |
Returned fields
The answer is JSON: records, a list of up to 10, and summary, the run status and counts. Each record has these 21 fields; a field the source does not publish comes back null.
21 fields per record
| Field | Type | Notes |
|---|---|---|
recordKey | string | Stable unique key: '{period}:{reporterCode}:{flowCode}:{partnerCode}:{cmdCode}:{customsCode}:{motCode}' (motCode 0 = total across transport modes). |
period | string | Reference year as returned by the API ('2024'). |
reporterCode | integer | UN numeric reporter code (Peru=604, China=156, USA=842). |
reporter | string | Reporter name resolved from the static country list. |
flowCode | string | Trade flow: M=import, X=export, RX=re-export, DX=re-import (a pair's response mixes flows). |
partnerCode | integer | UN numeric partner code; 0 = World aggregate. |
partner | string | Partner name resolved from the static country list ('World' for 0). |
cmdCode | string | HS commodity code (as queried, e.g. '8517'). |
primaryValue | number | Trade value in current USD (FOB for exports, CIF for imports). |
netWgt | number | Net weight in kg. |
qty | number | Quantity in the commodity's quantity unit (see qtyUnitAbbr); often 0/-1-coded when unknown. |
qtyUnitAbbr | string | Quantity unit abbreviation as reported. |
cifvalue | number | CIF value in USD (imports only). |
fobvalue | number | FOB value in USD (exports only). |
customsCode | string | Customs procedure code (C00 = total). |
motCode | integer | Mode-of-transport code (0 = total; 1000 sea, 2100 air, etc.). |
isAggregate | boolean | UN flag: row is an aggregate/estimated figure rather than directly reported. |
isReported | boolean | UN flag: figure directly reported by the country. |
pairKey | string | Watch pair this record belongs to: '{reporterCode}:{partnerCode}:{cmdCode}:{period}'. |
sourceQuery | string | Query params this record was fetched with. |
collectedAt | string | UTC ISO-8601 collection timestamp. |
Example call
npx agentcash@latest fetch https://api.ssh.autos/v1/comtrade/trade -m POST -b '{"reporter": "peru", "period": 2024, "maxResults": 3}'
The example values come from the API spec or the actor’s own sample input. Running it is a paid call.
What is and isn’t charged
You pay the call price for
- An answer, including a definitive “not found” or an empty result.
- Confirmed no matches returns records: [] (charged: it is an answer).
Free
- Invalid input (422), busy (503), source failure (502), timeout (504) and calls whose client hung up are never charged.
- Invalid input and source failures are not charged.
Prefer a subscription? Run it on Apify
This data source is a public actor on the Apify Store: UN Comtrade Trade Flow Watch. Run it with your Apify account and plan for larger, scheduled or exported runs; it may offer more input options than the per-call endpoint.
How x402 payment works
- Your client sends the request. The API answers
402 Payment Requiredwith the price and where to pay. - The client pays from its own wallet: USDC on Base or Solana over x402, or over MPP on Tempo. No account, sign-up or API key.
- The client retries with the payment attached and gets the JSON answer in the same call. You are only charged for answers.
The AgentCash CLI in the example does all three steps for you and pays from your AgentCash wallet. Any x402 or MPP client works the same way.
Machine-readable: openapi.json · llms.txt