{
  "openapi": "3.0.1",
  "info": {
    "title": "UN Comtrade Trade Flow Change Report",
    "description": "Monitor bounded official UN Comtrade preview queries for new, changed, or removed trade-flow records and generate source-linked trend reports and exports. Each watch uses one HS product and one period per request; preview results are limited to 500 records and are not comprehensive trade data.",
    "version": "0.1",
    "x-build-id": "1NUxuKWLow3fOvQtM"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/taroyamada~un-comtrade-trade-flow-change-report/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-taroyamada-un-comtrade-trade-flow-change-report",
        "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/taroyamada~un-comtrade-trade-flow-change-report/runs": {
      "post": {
        "operationId": "runs-sync-taroyamada-un-comtrade-trade-flow-change-report",
        "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/taroyamada~un-comtrade-trade-flow-change-report/run-sync": {
      "post": {
        "operationId": "run-sync-taroyamada-un-comtrade-trade-flow-change-report",
        "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",
        "required": [
          "watches"
        ],
        "properties": {
          "watches": {
            "title": "Trade-flow watches",
            "minItems": 1,
            "maxItems": 25,
            "type": "array",
            "description": "Each watch creates at most one official preview API request. Duplicate query dimensions are fetched once and matched to all watch IDs.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "id": {
                  "title": "Watch ID",
                  "description": "Stable label for this watch.",
                  "type": "string",
                  "maxLength": 80
                },
                "reporterCode": {
                  "title": "Reporter M49 code",
                  "description": "Country or area that reports the trade, for example 392 for Japan.",
                  "type": "string",
                  "pattern": "^[0-9]{1,3}$"
                },
                "partnerCode": {
                  "title": "Partner M49 code",
                  "description": "Partner country or area, for example 0 for World.",
                  "type": "string",
                  "pattern": "^[0-9]{1,3}$"
                },
                "hsCode": {
                  "title": "HS product code",
                  "description": "One HS code at 2, 4, or 6 digits per request.",
                  "type": "string",
                  "pattern": "^[0-9]{2}(?:[0-9]{2}|[0-9]{4})?$"
                },
                "flowCode": {
                  "title": "Trade flow",
                  "description": "X for exports or M for imports.",
                  "type": "string",
                  "enum": [
                    "X",
                    "M"
                  ]
                },
                "frequency": {
                  "title": "Frequency",
                  "description": "A for annual or M for monthly.",
                  "type": "string",
                  "enum": [
                    "A",
                    "M"
                  ]
                },
                "period": {
                  "title": "Period",
                  "description": "YYYY for annual watches or YYYYMM for monthly watches.",
                  "type": "string"
                }
              },
              "required": [
                "reporterCode",
                "partnerCode",
                "hsCode",
                "flowCode",
                "frequency",
                "period"
              ]
            },
            "default": []
          },
          "monitorKey": {
            "title": "Monitor key",
            "maxLength": 120,
            "type": "string",
            "description": "Stable isolated state namespace for this recurring watch portfolio.",
            "default": "un-comtrade-trade-flow-watch"
          },
          "initialRunMode": {
            "title": "Initial run mode",
            "enum": [
              "baseline_only",
              "emit_backfill"
            ],
            "type": "string",
            "description": "baseline_only stores the first bounded snapshot with zero rows. emit_backfill emits the current changes for an explicit paid run.",
            "default": "baseline_only"
          },
          "generateReport": {
            "title": "Generate trend report",
            "type": "boolean",
            "description": "Emit one report-first aggregate row when changes are observed.",
            "default": true
          },
          "emitRawRows": {
            "title": "Emit trade-flow rows",
            "type": "boolean",
            "description": "Emit one low-priced normalized row per changed current record. Report and alerts remain the primary output.",
            "default": false
          },
          "emitExport": {
            "title": "Generate export",
            "type": "boolean",
            "description": "Emit a compact source-linked JSON export when changes are observed.",
            "default": false
          },
          "emitUnchanged": {
            "title": "Emit unchanged records",
            "type": "boolean",
            "description": "Accepted for compatibility only. Unchanged runs always emit zero rows and zero charges.",
            "default": false
          },
          "maxChargeUsd": {
            "title": "Maximum charge USD",
            "minimum": 0.006,
            "maximum": 500,
            "type": "number",
            "description": "The complete planned PPE charge is estimated before the first dataset push. The run fails closed if this cap would be exceeded.",
            "default": 35
          },
          "requestTimeoutSeconds": {
            "title": "Request timeout seconds",
            "minimum": 5,
            "maximum": 120,
            "type": "integer",
            "description": "Timeout for each official preview request.",
            "default": 30
          },
          "maxRetries": {
            "title": "Maximum retries",
            "minimum": 0,
            "maximum": 4,
            "type": "integer",
            "description": "Bounded retries for 429 and transient 5xx responses only.",
            "default": 3
          },
          "dryRun": {
            "title": "Dry run",
            "type": "boolean",
            "description": "Return deterministic representative report, alert, row, and export records without API calls, state writes, or charges.",
            "default": false
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}