Agri-food Trade Flows API

Annual exports or imports of food and farm products between countries, from UN Comtrade: value in US dollars, weight and quantity by HS product code, with country and product names instead of numeric codes.

$0.50 per 1,000 records

You pay only for the records you get. Zero records cost zero. 10,000 free records of this API to start (5,000 at the base price of $1 per 1,000), no card.

Try it
Ready-made, maintained by usRecords, 10 fieldsv1.0

Data from comtradeapi.un.org/public/v1/preview/C/A/HS

Get this data

Try it here with a few records, download the sample, fill a Google Sheet, or call it from your own code.

Try it

Reporters
Reporting countries by name, ISO code or UN code (up to 10), for example Canada. One per line, or separated by commas.
Example: Canada
Partnersoptional
Partner countries (up to 10). World totals when empty. One per line, or separated by commas.
Example: World
Hs codesoptional
HS product codes of 2, 4 or 6 digits in chapters 01 to 24, such as 10 (cereals) or 1001 (wheat). All 24 chapters when empty. One per line, or separated by commas.
Example: 10
Yearsoptional
Years such as 2023 (up to 5). The latest complete year, 2023, when empty. One per line, or separated by commas.
Example: 2023
Flowoptional
export or import.

Run it on this page, or call it from your code with the endpoint in the developer section. A free key covers 10,000 records of this API, no card. Create a free key

For developers: the API and MCPThe endpoint, code in curl, JavaScript and Python, every input, and files for your tools
Endpoint
POSThttps://pullrow.dev/v1/apis/un-comtrade-agrifood-trade/run
  • Small runs answer in the same request; longer ones answer 202 with a run to poll.
  • fields returns only the fields you name. The examples send the ones picked on this page.
  • Idempotency-Key is optional. A retry with it is never charged twice.
  • You pay for records returned. Zero records cost zero.

Every run option, explained

Calling it needs a key
10,000 free records of this API to start. No card.
curl
curl -X POST "https://pullrow.dev/v1/apis/un-comtrade-agrifood-trade/run" \
  -H "Authorization: Bearer $PULLROW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":{"reporters":["Canada"]},"max_items":50}'

Inputs

Send them as input in the request body. Leave one out to use its default.

reporterslistrequired
Reporting countries by name, ISO code or UN code (up to 10), for example Canada.
example: Canada
partnerslist
Partner countries (up to 10). World totals when empty.
example: World
hs_codeslist
HS product codes of 2, 4 or 6 digits in chapters 01 to 24, such as 10 (cereals) or 1001 (wheat). All 24 chapters when empty.
example: 10
yearslist
Years such as 2023 (up to 5). The latest complete year, 2023, when empty.
example: 2023
flowtext
export or import.
default: exportexample: exportone of: export, import

What's in each record

10 fields.

Basics

  • Period

    Year of the figures.

    Example 2023

  • Reporter

    Country that reported the trade.

    Example Canada

  • Partner country, or World

    Example World

  • Flow

    export or import.

    Example export

  • Hs code

    Harmonized System product code.

    Example 0201

  • Description

    Name of the product group for the code.

    Example Meat of bovine animals; fresh or chilled

  • Net weight (kg)

    Net weight in kilograms, when reported.

    Example 356,999,709

  • Quantity

    Quantity in the unit given in quantity_unit, when reported.

    Example 356,999,709

  • Quantity unit

    Unit of the quantity, such as kg.

    Example kg

  • Trade value (USD)

    Trade value in US dollars.

    Example 2,918,597,139.755

Technical detailsField names and types for developers

Field names and types

The names your code reads in each record. "Filled" counts how many of the 3 sample records carry the field.

Field nameTypeShown on this page asFilled
periodtextPeriod3 of 3
reportertextReporter3 of 3
partnertextPartner country, or World3 of 3
flowtextFlow3 of 3
hs_codetextHs code3 of 3
descriptiontextDescription3 of 3
net_weight_kgnumberNet weight (kg)2 of 3
quantitynumberQuantity2 of 3
quantity_unittextQuantity unit2 of 3
trade_value_usdnumberTrade value (USD)3 of 3

How it reads the site

Runs on a reader we built and maintain by hand for this site.

Sample records

Sample records
RecordPeriodReporterPartner country, or WorldFlowHs codeDescriptionNet weight (kg)QuantityQuantity unitTrade value (USD)
12023CanadaWorldexport0201Meat of bovine animals; fresh or chilled356,999,709356,999,709kg2,918,597,139.755
22023CanadaWorldexport10Cereals———11,232,212,939.253
32023CanadaWorldexport1001Wheat and meslin25,615,146,610.77525,615,146,610.775kg8,854,972,028.586

Sample records from the example output this API publishes. Email addresses and phone numbers in them are masked. Hover over a column name to see the field name your code reads.

Reliability

Counted from real runs. Our own health checks are left out. A run succeeded when it finished and the site neither blocked it nor broke it.

Incidents and repairs

How it is kept working What a repair can't do

A ready-made API, maintained by us. It is not part of the daily check or the automatic rebuild yet.

  • You pay only for records returned. A run that returns none costs nothing.
Known limits
  • Uses the free UN Comtrade public preview, which returns at most 500 rows per request; a run reads one request for each year, so a wide mix of countries, partners and codes in one year can be cut off at 500 rows. Narrow the inputs to get everything.
  • Annual data only, flow of one direction per run, and HS chapters 01 to 24 (food, live animals, beverages, tobacco).
  • Weight and quantity are empty for whole-chapter (2-digit) totals; they are filled for 4-digit and 6-digit product codes. Some countries report no weight or no quantity.
  • Countries publish with a delay, so the newest year is often missing or partial; asked-for combinations with no reported trade return nothing.
  • The source asks for fair use and its terms limit commercial redistribution of the raw data; credit UN Comtrade and check its terms before republishing. Runs keep about one request every three seconds across all users.

Version history

A run uses the live version unless the request names another one with version.