# UN Comtrade Trade Data Scraper API - Imports & Exports (`pink_comic/un-comtrade-import-export-trade-data`) Actor

Search UN Comtrade public preview data by annual/monthly period, reporter, partner, flow, HS commodity, customs procedure, and transport mode. Get normalized quantities, weights, trade values, labels, source links, and bounded-query evidence.

- **URL**: https://apify.com/pink\_comic/un-comtrade-import-export-trade-data.md
- **Developed by:** [Ava Torres](https://apify.com/pink_comic) (community)
- **Categories:** E-commerce, Business, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 un comtrade trade data scraper api - imports & exp evidence items

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## UN Comtrade Trade Data Scraper API – Imports & Exports

Search UN Comtrade public preview aggregate goods-trade data by annual/monthly period, reporter, partner, flow, HS commodity, customs procedure, and transport mode. Output includes normalized labels, quantities, weights, CIF/FOB/primary values, classification evidence, source URLs, timestamps, and explicit outcomes.

### Default input

```json
{}
```

Returns at most one verified 2023 USA wheat-import aggregate. Bounded first-run cost: **$0.0021 maximum** (`$0.0001` start + one `$0.002` item).

```json
{
  "frequency": "M",
  "periods": ["202301", "202302"],
  "reporterCode": "842",
  "partnerCode": "156",
  "flowCode": "X",
  "hsCode": "854231",
  "customsCode": "C00",
  "transportModeCode": "0",
  "maxRecordsPerPage": 50,
  "maxPages": 2,
  "maxResults": 100
}
```

Each period is one source page; `maxPages`, 500-record page cap, and total `maxResults` prevent unbounded runs. Charge budgets can reduce `maxResults` before requests.

### Evidence limits

The public preview endpoint has stricter record, rate, and coverage limits than paid/bulk Comtrade access. Reporter data can be revised, delayed, estimated, suppressed, mirrored, or missing; import/export mirror values may differ. No match is not proof of no trade. Aggregate values do not prove shipment-level transactions, origin, ownership, sanctions screening, tariff treatment, customs compliance, or legal eligibility. Confirm consequential uses with reporting and customs authorities.

# Actor input Schema

## `frequency` (type: `string`):

Optional frequency filter or result-control setting. See the README for exact source semantics, bounds, and examples.

## `periods` (type: `array`):

Annual YYYY or monthly YYYYMM values; maximum 24.

## `reporterCode` (type: `string`):

UN M49 reporter code; 842 is USA.

## `partnerCode` (type: `string`):

0 means World.

## `partner2Code` (type: `string`):

Usually 0 (World).

## `flowCode` (type: `string`):

Optional trade flow filter or result-control setting. See the README for exact source semantics, bounds, and examples.

## `hsCode` (type: `string`):

1-6 digit HS code or TOTAL; 1001 is wheat and meslin.

## `customsCode` (type: `string`):

Comtrade customs code; C00 is total CPC.

## `transportModeCode` (type: `string`):

0 means total mode of transport.

## `maxRecordsPerPage` (type: `integer`):

Bound sent to the public preview endpoint for each period.

## `maxPages` (type: `integer`):

Each requested period is one bounded source page.

## `maxResults` (type: `integer`):

Total paid dataset-item cap across all periods. Default one item costs at most $0.002 plus the $0.0001 start event.

## Actor input object example

```json
{
  "frequency": "A",
  "periods": [
    "2023"
  ],
  "reporterCode": "842",
  "partnerCode": "0",
  "partner2Code": "0",
  "flowCode": "M",
  "hsCode": "1001",
  "customsCode": "C00",
  "transportModeCode": "0",
  "maxRecordsPerPage": 1,
  "maxPages": 1,
  "maxResults": 1
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "frequency": "A",
    "periods": [
        "2023"
    ],
    "reporterCode": "842",
    "partnerCode": "0",
    "flowCode": "M",
    "hsCode": "1001",
    "customsCode": "C00",
    "transportModeCode": "0",
    "maxRecordsPerPage": 1,
    "maxPages": 1,
    "maxResults": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("pink_comic/un-comtrade-import-export-trade-data").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "frequency": "A",
    "periods": ["2023"],
    "reporterCode": "842",
    "partnerCode": "0",
    "flowCode": "M",
    "hsCode": "1001",
    "customsCode": "C00",
    "transportModeCode": "0",
    "maxRecordsPerPage": 1,
    "maxPages": 1,
    "maxResults": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("pink_comic/un-comtrade-import-export-trade-data").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "frequency": "A",
  "periods": [
    "2023"
  ],
  "reporterCode": "842",
  "partnerCode": "0",
  "flowCode": "M",
  "hsCode": "1001",
  "customsCode": "C00",
  "transportModeCode": "0",
  "maxRecordsPerPage": 1,
  "maxPages": 1,
  "maxResults": 1
}' |
apify call pink_comic/un-comtrade-import-export-trade-data --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=pink_comic/un-comtrade-import-export-trade-data",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/vjRsHsbRrPwle5qvm/builds/yYT18TIlyuLKDq21w/openapi.json
