UN Comtrade Trade Data: Best Export Markets per HS Code on the Apify Store →

How to find the best countries to export to with UN Comtrade (by HS code)

Tutorial draft for dev.to, Hashnode, Medium and the Apify blog guest program. Post it with the canonical link set to https://apify.com/rich_minds/export-market-finder-ai and disclose that you built the tool. Every number below comes from a real run: Apify platform runs of 2026-10-23 and 2026-11-21, plus the local AI run of 2026-10-23 where it says so.

The problem: one question, thirty-five queries

Every exporter eventually asks: which countries should I sell this product to, and what do they pay for it?

The answer is public. UN Comtrade publishes what every country imports, by 6-digit HS code, by supplier, with values and weights. But the portal answers one reporter, one partner and one year per query. To rank markets for one product by hand you have to:

  1. pull every country's imports of your HS code from the world, for four years (demand and growth);
  2. pull each market's supplier breakdown (who you compete with, and at what price per kg);
  3. pull your own country's exports to each market (your share, your price);
  4. put it all in a spreadsheet and score it.

For HS 610910 (cotton T-shirts) with India as the exporter, that was 35 API calls and 4,730 Comtrade records for 30 markets, about a day in Excel.

The shortcut: UN Comtrade Export Market Finder

UN Comtrade Trade Data: Best Export Markets per HS Code is an Apify Actor that runs those queries for you. It returns one row per importing country, best opportunity first.

Step 1: run the free demo

Open the Store page and click Try it. The form opens on a free demo with real Comtrade rows for HS 610910 in five markets (USA, Germany, France, UK, Netherlands), India as the exporter. Press Start. On Apify the demo finishes in about 5.5 seconds and nothing is charged.

Step 2: type your own HS code and country

Replace the HS code with yours, or describe the product ("frozen shrimp" → HS 030617; a low-confidence match is flagged hs_guessed). Then pick your country. The live search reads UN Comtrade directly, so it works on any Apify plan with no separate scraper bill.

Measured on Apify: 30 markets for HS 610910 / India in 85 s (2026-10-23), plus about 58 s to add each market's duty from the World Bank's WITS (2026-11-22). A 5-market run with duties took 107 s (2026-11-21).

Step 3: read the Shortlist

Each row carries:

A real row (Germany, HS 610910, India): Germany imported $3.43 B in 2025 (+16.6 % on the year before). India supplied $295.42 M (8.6 % share). Bangladesh led with 44.0 % at $16.90/kg, and the market paid $22.26/kg on average against India's $20.46/kg. The rows above are the rules' figures. The AI tier then wrote this next step (local run, 2026-10-23, own Gemini key): "Compare your unit value of $20.46 per kg directly against Bangladesh's $16.90 per kg before reaching out to German importers."

The AI may cite only the row's own numbers. If a sentence contains an invented figure or a forecast, it is dropped and the rule note takes its place.

Step 4: schedule it

Save the input as a task and schedule it monthly, with your e-mail (or a Telegram / Slack URL) in the notification field. With dedupeAcrossRuns on, a market comes back only when Comtrade publishes a newer year for it. Add your free comtradeKey from comtradedeveloper.un.org for scheduled runs.

What it costs

Worked example: the first real search (30 markets, AI on) costs 25 free + 5 × $0.01 + tokens ≈ $0.14. The next HS code costs ≈ $0.41 with AI, or $0.12 rules only.

Ready-made searches (measured live 2026-10-23, AI off, 10 markets)

Ready searchHSResult
India · cotton T-shirts61091010 qualified, 10 hot
Viet Nam · green coffee09011110 qualified, 10 hot
India · frozen shrimp03061710 qualified, 4 hot
Kenya · cut roses06031110 qualified, 4 hot
Türkiye · shelled hazelnuts08022210 qualified, 2 hot

From code

from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("rich_minds/export-market-finder-ai").call(run_input={
    "hsCodes": ["610910"], "exporterCountry": "IN", "maxQualified": 30, "enableAi": True,
}, timeout_secs=1800)
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["marketCountry"], row["score"], row["exporterSharePct"], row["unitValueUsdPerKg"])

It also works from Claude or ChatGPT through Apify's MCP server, and from n8n, Make or Zapier. The recipes are on the Store page under Integrations.

When not to use it

For a single table you need once, ITC Trade Map and the Comtrade website are free and fine. The Actor is worth it when you rank many HS codes, need the per-supplier price per kg and duties in one sheet, or want the same search re-run every month without doing it by hand.

Try it with your HS code: https://apify.com/rich_minds/export-market-finder-ai. The first 25 markets are free.

Data: UN Comtrade (comtradeplus.un.org) and World Bank WITS. The Actor returns derived figures and names its sources.

UN Comtrade Trade Data: Best Export Markets per HS Code on the Apify Store →