{
  "openapi": "3.0.1",
  "info": {
    "title": "UN Comtrade Trade Data Scraper",
    "description": "[💰 $0.02 / 1K] Extract official UN Comtrade import/export statistics — trade values, quantities, net weight and CIF/FOB — across 255 reporting countries and 300+ partners. Goods (HS, SITC, BEC) and services (EBOPS), annual or monthly, from 1988 to today. Search by country name or ISO code.",
    "version": "1.0",
    "x-build-id": "eSuiHyWxLcpc5TTFA"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/solidcode~un-comtrade-trade-data-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-solidcode-un-comtrade-trade-data-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/solidcode~un-comtrade-trade-data-scraper/runs": {
      "post": {
        "operationId": "runs-sync-solidcode-un-comtrade-trade-data-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/solidcode~un-comtrade-trade-data-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-solidcode-un-comtrade-trade-data-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "dataset": {
            "title": "Dataset & classification",
            "enum": [
              "goods_hs",
              "goods_sitc",
              "goods_bec",
              "services_eb02",
              "services_eb10"
            ],
            "type": "string",
            "description": "Which trade dataset to pull, and how commodities are classified. HS (Harmonized System) is the standard choice for merchandise trade and is what most reports and tariff schedules use. Pick a Services option to get trade in services instead of physical goods."
          },
          "reporters": {
            "title": "Reporting countries",
            "type": "array",
            "description": "The countries whose customs authorities reported the trade. Enter country names (Germany, Japan, Brazil), ISO codes (USA, DEU, JP), or UN numeric codes (842, 276). Around 255 reporters are available. Example: [\"USA\", \"China\", \"Germany\"].",
            "items": {
              "type": "string"
            }
          },
          "partners": {
            "title": "Partner countries",
            "type": "array",
            "description": "The countries traded with. Use \"World\" to get each reporter's overall totals — this is the fastest option and what most analyses need. Enter names, ISO codes, or UN numeric codes. Leave empty to return every partner country individually, which returns far more rows.",
            "items": {
              "type": "string"
            }
          },
          "tradeFlows": {
            "title": "Trade direction",
            "uniqueItems": true,
            "type": "array",
            "description": "Which direction of trade to return. Imports and exports are published by nearly every country. Re-imports, re-exports and domestic exports are only published by some countries, so those three may come back empty depending on the reporter you pick — for example the United States publishes re-exports and domestic exports but not re-imports, while China and Brazil publish re-imports but not re-exports.",
            "items": {
              "type": "string",
              "enum": [
                "M",
                "X",
                "RM",
                "RX",
                "DX"
              ],
              "enumTitles": [
                "Imports",
                "Exports",
                "Re-imports",
                "Re-exports",
                "Domestic exports"
              ]
            }
          },
          "commodityCodes": {
            "title": "Commodity codes",
            "type": "array",
            "description": "Which products to return. Use \"TOTAL\" for all-commodity totals, a 2-digit HS chapter such as \"84\" (machinery), a 4-digit heading such as \"8703\" (cars), or a 6-digit line such as \"870380\". You can also use \"AG2\", \"AG4\" or \"AG6\" to return every code at that level of detail. For Services datasets leave this empty to return all service categories, or use \"200\" for the all-services total — \"TOTAL\" is a goods-only code and returns nothing for services. Codes that do not exist simply return no rows, so double-check any code you type by hand.",
            "items": {
              "type": "string"
            }
          },
          "frequency": {
            "title": "Frequency",
            "enum": [
              "A",
              "M"
            ],
            "type": "string",
            "description": "Annual data gives one figure per year. Monthly data is more granular but is only published by a subset of countries."
          },
          "periods": {
            "title": "Periods",
            "type": "array",
            "description": "Years for annual data, written as \"2023\". For monthly data use year and month together, written as \"202301\" for January 2023. How far back the data goes depends on the dataset you picked: Goods HS reaches back to 1988 (and covers most countries from 1991), Goods SITC Revision 4 starts in 2007, Goods BEC Revision 5 starts in 2017, both Services datasets start around 2000, and monthly data starts in 2000. The most recent year is always partial — countries report on their own schedules, and services figures typically lag goods by about a year. Leave empty and the most recent period that is normally published in full is used. Example: [\"2023\", \"2022\", \"2021\"].",
            "items": {
              "type": "string"
            }
          },
          "recordDetail": {
            "title": "Level of detail",
            "enum": [
              "totals",
              "breakdowns"
            ],
            "type": "string",
            "description": "Headline totals give you one clean figure per country, partner, product and period — this is what almost everyone wants. Full breakdowns additionally split each figure by customs procedure, mode of transport and country of origin, which can multiply the number of rows by several hundred for countries that report at that depth (most EU members do)."
          },
          "maxResults": {
            "title": "Maximum results",
            "minimum": 0,
            "type": "integer",
            "description": "Stop the run once this many trade records have been collected. If left blank, 1,000 is used. Set to 0 to remove the limit. Records arrive from the data source in batches of up to 500, and a batch already on its way is always finished and kept rather than thrown away, so a run can return up to about 500 records more than the number you ask for. It will never return fewer than are available. Every run also has a built-in safety limit of 4,000 queries to the data source, whatever you set here — a run that reaches it stops early and says so in its final status, and you can collect the rest by narrowing the query and running again. Broad queries — many countries, every partner, or full breakdowns — can produce very large result sets, so keep a limit in place unless you specifically want everything."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}