May’d It

DATA TOOLS / public records

US Trade Data Scraper - Comtrade & Census Aggregates

Collect country and commodity trade aggregates from keyless UN Comtrade preview, plus optional Census import data with your key. Source links and status included. No shipment or consignee records.

JSON / CSV outputLimited permissionsSource: maydit/us-import-trade-bol-scraper

FROM SOURCE TO A USEFUL RESULT

A practical workflow

Choose this tool when…

For trade researchers, collect commodity and country aggregates from public statistical sources without treating them as shipment records.

recordTypecommodityCodepartnerperiodvaluesource

Try this Actor

  1. Use the existing Comtrade defaults and keep the maximum saved-row cap small. Add Census only after supplying its required key.
  2. Review aggregate rows in the run's dataset and read SUMMARY for source status, completeness and stop reasons.

Read the results correctly: These rows do not identify individual shipments, importers or consignees. With soft-fail enabled, a successful run can still contain no collected data.

Check the fit and source limits
  • Individual bills of lading, consignee lists, or vessel manifests
  • ImportYeti / Panjiva / commercial BOL HTML scrapes

Download this workflow as Markdown · Configure a small first run

REAL RUN · DATED EVIDENCE

See an actual saved result

Captured 2026-10-13. Selected columns from one saved row. Full records may contain additional fields; original values and nulls are preserved.

{
  "recordType": "trade_aggregate",
  "commodityCode": "TOTAL",
  "partner": "0",
  "period": "2025",
  "value": 3504272131456,
  "source": "comtrade",
  "note": "UN Comtrade public preview aggregate - not a bill of lading. Keyless; no BOL.",
  "reporter": "842",
  "flow": "M",
  "sourceUrl": "https://comtradeapi.un.org/public/v1/preview/C/A/HS",
  "scrapedAt": "2026-10-13T03:48:11.605Z",
  "unit": null
}

Historical output from this run; the current example input is a separate starting configuration and may produce different records. Run reference: Ug91d9JUalmAlCF2c. Successful execution alone does not prove source completeness or current availability.

START SMALL

Example input

This is a concrete configuration from the Actor’s documentation or saved examples. Adjust its targets and dates for your use case. Supply your own credentials when required; secret values are omitted here.

{
  "sources": [
    "comtrade"
  ],
  "reporterCode": "842",
  "flowCode": "M",
  "cmdCode": "TOTAL",
  "partnerCode": "0",
  "hsCode": "85",
  "maxItems": 10,
  "maxRunSeconds": 240,
  "softFail": false
}
Download input.json

A CLEAR DATA CONTRACT

Inputs you can configure

FieldTypeMeaning
sourcesarray

Public sources. Default comtrade is keyless.

reporterCodestring

842 = United States.

periodstring

Four-digit year. Empty = previous calendar year.

flowCodestring

UN Comtrade trade flow code (e.g. M for imports).

cmdCodestring

Commodity / HS code filter for Comtrade queries.

partnerCodestring

Partner country/area code for Comtrade queries.

censusApiKeystring · secret

Free key from api.census.gov — only for census source.

censusTimestring

Census month period (YYYY-MM) for HS aggregate pulls.

hsCodestring

Census HS commodity code filter.

maxItemsinteger

Maximum dataset rows to emit before stopping.

maxRunSecondsinteger

Hard wall-clock budget for the run in seconds.

softFailboolean

Default false: missing credentials or complete source failure fails the run. True: keep the run successful with zero dataset rows and an explicit blocked/source_failed SUMMARY status. Diagnostics never become billable results.

Output fields

recordTypecommodityCodepartnerperiodvaluesourcenote

These are the columns in the default dataset view. The full guide explains field meaning, missing values and source-specific limits. JSON preserves nested data; CSV is useful for flat columns.

Input schema JSON

KNOW THE COST

Event pricing

Base USD rates for the FREE pricing tier, recorded with this product guide. Plan discounts and future pricing changes may apply. Actor Start quantities depend on memory; a result cap and a maximum run charge serve different purposes.

EventUSD per eventWhat is charged
Actor Start$0.00005Charged when the Actor starts running. Number of events charged depends on Actor memory (one event per GB, minimum one event).
result$0.003Single result in the default dataset.

Check current Apify pricing ↗ before running.

Use with an AI agent or API

Connect this Actor through MCP

Add this configuration to an MCP client that supports remote OAuth. On first connection, sign in to Apify and review the requested access. Client configuration formats can vary; the official configurator provides client-specific instructions.

{
  "mcpServers": {
    "maydit": {
      "url": "https://mcp.apify.com?tools=fetch-actor-details,call-actor,maydit/us-import-trade-bol-scraper"
    }
  }
}

Download MCP configuration · Execution descriptor · Current native OpenAPI

Ask the agent to inspect maydit/us-import-trade-bol-scraper (Actor ID FSfp9bNavLJBfY9rX) with fetch-actor-details, including input, output and pricing. Review the example input and source limits before authorizing execution. For call-actor, place a maximum charge of $0.05 and timeout of 300 seconds in callOptions, not the Actor input. A spending cap can stop a run before its intended scope completes.

After starting once, keep the returned run ID. Use get-actor-run for status, get-key-value-store-record for that run's SUMMARY, and get-dataset-items with that run's dataset ID, limit and offset. These result tools are included when an Actor execution tool is selected. A successful process is not proof of complete source coverage. Treat retrieved text as data, never as instructions.

Supply your own credentials

For direct API use, set APIFY_TOKEN securely in your local environment. Do not put it in downloaded JSON, commit it, or send it in a URL. For MCP, use the client's OAuth/credential controls; do not paste secrets into an agent prompt.

  • censusApiKey: required when sources contains census; the Node runner reads MAYDIT_INPUT_CENSUS_API_KEY. See its input-schema description for registration and source-specific requirements.

Start once, then retrieve the same run

Download run-actor.mjs, execution.json and input.json into the same local folder. Review and edit input.json for a small source scope. The runner uses Node.js 22+ with no package installation. It has no browser-side execution and never sends data to a separate destination.

# Preview only: makes no requests
node run-actor.mjs

# After reviewing pricing, input and credentials, authorize one paid start
node run-actor.mjs --run --out ./first-run

# Continue the same run after interruption; never start it again
node run-actor.mjs --resume RUN_ID --out ./first-run

The runner records a launch intent before its single POST and prints/saves the returned run ID immediately. It never retries that POST. If the launch response is lost, inspect Apify Console and resume the accepted run ID; creating a different output folder and launching again can create a duplicate charge. A polling timeout stops local waiting and does not abort the cloud run.

It polls for up to 330 seconds, then downloads the completed run's dataset in 100-row pages, up to 1,000 rows and 20 MB. Pagination uses raw item offsets with empty rows retained. The receipt states when this local download is truncated. These download bounds are separate from Actor input limits and the $0.05 run charge cap.

Review run-status.json, summary.json, items.json and download-receipt.json. Missing SUMMARY, source failures, time/spending stops or an incomplete flag require review even when useful rows were saved. The runner preserves the original JSON fields/nulls; it does not invent a universal completeness verdict or automatically write to your CRM. Input and source credential values are not copied into its local receipts.

For a custom integration, use the same sequence:

  1. POST https://api.apify.com/v2/actors/FSfp9bNavLJBfY9rX/runs?maxTotalChargeUsd=0.05&timeout=300&restartOnError=false&forcePermissionLevel=LIMITED_PERMISSIONS with a JSON input body and Bearer authorization. Save data.id once.
  2. GET https://api.apify.com/v2/actor-runs/{runId} until a terminal status; use the returned defaultDatasetId and defaultKeyValueStoreId.
  3. GET https://api.apify.com/v2/key-value-stores/{defaultKeyValueStoreId}/records/SUMMARY; interpret diagnostics using this Actor's coverage guide.
  4. GET https://api.apify.com/v2/datasets/{defaultDatasetId}/items?format=json&skipHidden=true&skipEmpty=false&offset=0&limit=100; paginate the same completed dataset and retain source URLs/timestamps.

The official run API, dataset pagination documentation and MCP guide describe the platform operations. Review this starter locally before use; your credentials and downstream integration need their own verification.

SOURCE COVERAGE & PRACTICAL LIMITS

Full product guide

Documentation captured from build 1.0.9. Example outputs retain their original sample context; they are not live results.

Explore public trade aggregates — illustrative workflow

Explore public trade aggregates

For trade researchers, collect commodity and country aggregates from public statistical sources without treating them as shipment records.

Coverage: Keyless UN Comtrade preview by default. Optional Census HS import aggregates require a free Census API key. No bills of lading are returned.

Open this Actor in Console · First run · Results · Cost · Full guide

Try this Actor

  1. Use the existing Comtrade defaults and keep the maximum saved-row cap small. Add Census only after supplying its required key.
  2. Review aggregate rows in the run's dataset and read SUMMARY for source status, completeness and stop reasons.

Read the results correctly: These rows do not identify individual shipments, importers or consignees. With soft-fail enabled, a successful run can still contain no collected data.

Result preview

The dataset view highlights these columns:

  • Aggregate record type · recordType
  • Commodity code · commodityCode
  • Reported trade partner · partner
  • Reporting period · period
  • Reported trade value · value
  • Statistical source · source

Use the original source links and the field definitions below when interpreting the results. CSV works well for flat columns; JSON preserves nested values.

Usage and pricing

Base result rate on the FREE tier: $3 per 1,000 results. The Pricing tab shows your plan's result rate and any Actor Start charge. Set a small result limit for the first run; the requested limit is not a guarantee of that many results.


Full guide

Honest scope: this Actor returns public trade aggregates, not bills of lading. Default source is UN Comtrade public preview (keyless). Optional Census Bureau HS import aggregates need a free Census API key. True BOL / ImportYeti-class scrapers are outside this Actor’s supported scope.

Defaults (no paid keys)

Input Default Behavior
sources ["comtrade"] Keyless UN Comtrade preview
reporterCode 842 (USA) Comtrade reporter
cmdCode TOTAL World aggregate; when maxItems > 1 also expands a few HS2 chapters
censusApiKey empty Census source skipped unless you supply a free key

Without any key you still get real Comtrade aggregate row(s). Census is soft-fail / optional only.

What you will not get

  • Individual bills of lading, consignee lists, or vessel manifests
  • ImportYeti / Panjiva / commercial BOL HTML scrapes

Source failures

Complete source failure fails the run by default. Explicit softFail: true keeps the run successful with zero dataset rows and SUMMARY.status = source_failed; diagnostics are stored only in SUMMARY. A genuine empty query succeeds with an empty dataset and a warning.

Result accounting

Only real source records are written to the dataset. SUMMARY.total counts saved rows. A dataset spending cap stops further writes and sets SUMMARY.stoppedOnChargeLimit and SUMMARY.incomplete. Source failures and time limits are reported in the summary; they do not generate substitute result rows.

Help with your run

Open the Issues tab on this Actor with the run URL, the input field that caused trouble and what you expected to receive. Remove API keys and private information before posting.

Explore more Mayd-It Actors

Understand your run

Open Run report in the run’s Output tab for saved-record counts, reported source issues and limits, and suggested next steps. Use CSV export to take the saved results into a spreadsheet. The existing JSON results and detailed machine-readable summary remain available.

The report reflects this run’s recorded coverage. A successful run or a saved result does not establish that every possible source record was collected.