{
  "openapi": "3.0.1",
  "info": {
    "title": "Comex Stat Brasil — Importação e Exportação por NCM",
    "description": "Importações e exportações oficiais do Brasil (Comex Stat/MDIC) por NCM: país, UF, porto, US$ FOB/CIF, kg, preço médio e variação vs ano anterior.",
    "version": "1.0",
    "x-build-id": "KYn6YKFQfsbUgsmgS"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/kodama-data~comex-stat-brasil-importacao-exportacao/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-kodama-data-comex-stat-brasil-importacao-exportacao",
        "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/kodama-data~comex-stat-brasil-importacao-exportacao/runs": {
      "post": {
        "operationId": "runs-sync-kodama-data-comex-stat-brasil-importacao-exportacao",
        "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/kodama-data~comex-stat-brasil-importacao-exportacao/run-sync": {
      "post": {
        "operationId": "run-sync-kodama-data-comex-stat-brasil-importacao-exportacao",
        "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": {
          "products": {
            "title": "Produtos (códigos NCM / SH)",
            "type": "array",
            "description": "Códigos de produto: 8 dígitos = NCM, 6 = SH6, 4 = SH4 (posição), 2 = capítulo. Pontos são ignorados (\"8517.13.00\" = \"85171300\"). Ex.: 85171300 (smartphones), 0901 (café), 8476 (máquinas de venda automática). Vazio e sem busca = pauta completa por capítulo.",
            "items": {
              "type": "string"
            }
          },
          "productSearch": {
            "title": "Buscar NCM por palavra",
            "type": "array",
            "description": "Opcional: termos para achar NCMs pelo nome, com acentos (ex.: \"café\", \"máquinas automáticas de venda\", \"pneus\"). As NCMs encontradas entram na consulta.",
            "items": {
              "type": "string"
            }
          },
          "maxSearchNcms": {
            "title": "Máx. NCMs por busca",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "Limite de NCMs usadas de cada termo de busca (a busca oficial pode trazer códigos antigos ou parecidos).",
            "default": 15
          },
          "flows": {
            "title": "Fluxo",
            "type": "array",
            "description": "Importação, exportação ou ambos.",
            "items": {
              "type": "string",
              "enum": [
                "import",
                "export"
              ],
              "enumTitles": [
                "Importação",
                "Exportação"
              ]
            },
            "default": [
              "import"
            ]
          },
          "periodFrom": {
            "title": "Período — de (AAAA-MM)",
            "pattern": "^$|^\\d{4}-\\d{2}$",
            "type": "string",
            "description": "Mês inicial. Vazio = últimos 12 meses publicados. Períodos que cruzam o ano são suportados (a API oficial não aceita; o actor junta)."
          },
          "periodTo": {
            "title": "Período — até (AAAA-MM)",
            "pattern": "^$|^\\d{4}-\\d{2}$",
            "type": "string",
            "description": "Mês final. Vazio = último mês publicado pelo MDIC."
          },
          "monthly": {
            "title": "Detalhar por mês",
            "type": "boolean",
            "description": "Uma linha por mês (série histórica). Desligado = total do período.",
            "default": false
          },
          "breakdownBy": {
            "title": "Quebrar por",
            "type": "array",
            "description": "Dimensões de cada linha: país, bloco econômico, UF do produto (origem na exportação / destino na importação), via de transporte e URF (porto/aeroporto/recinto de despacho).",
            "items": {
              "type": "string",
              "enum": [
                "country",
                "economicBlock",
                "state",
                "via",
                "urf"
              ],
              "enumTitles": [
                "País",
                "Bloco econômico",
                "UF",
                "Via",
                "URF (porto/aeroporto)"
              ]
            },
            "default": [
              "country"
            ]
          },
          "countries": {
            "title": "Somente países",
            "type": "array",
            "description": "Filtra por país (nome em português ou inglês, ou código do Comex Stat). Ex.: [\"China\",\"Estados Unidos\"], [\"Germany\"], [\"160\"].",
            "items": {
              "type": "string"
            }
          },
          "ufs": {
            "title": "Somente UFs",
            "type": "array",
            "description": "Siglas de UF. Ex.: [\"SP\",\"SC\",\"PR\"].",
            "items": {
              "type": "string"
            }
          },
          "compareWithPreviousYear": {
            "title": "Comparar com o mesmo período do ano anterior",
            "type": "boolean",
            "description": "Acrescenta valores do ano anterior e variação % de US$ FOB, kg e preço médio US$/kg.",
            "default": true
          },
          "minFobUsd": {
            "title": "Valor mínimo por linha (US$ FOB)",
            "minimum": 0,
            "type": "integer",
            "description": "Descarta linhas pequenas (ex.: 10000 tira remessas irrelevantes).",
            "default": 0
          },
          "maxRows": {
            "title": "Máximo de linhas",
            "minimum": 1,
            "type": "integer",
            "description": "Teto de linhas no dataset (mantém as de maior valor). Controla o custo.",
            "default": 5000
          },
          "language": {
            "title": "Idioma dos nomes",
            "enum": [
              "pt",
              "en"
            ],
            "type": "string",
            "description": "Idioma dos nomes de produtos, países e blocos.",
            "default": "pt"
          },
          "onlyIfNewMonth": {
            "title": "Modo alerta: só quando sair mês novo",
            "type": "boolean",
            "description": "Agende diário/semanal: o actor só entrega dados quando o MDIC publicar uma nova competência (mensal). Nas outras execuções não grava linhas (custo mínimo).",
            "default": false
          },
          "stateKey": {
            "title": "Nome do alerta",
            "type": "string",
            "description": "Identifica o alerta (guarda o último mês entregue). Use um nome por consulta agendada.",
            "default": "padrao"
          }
        }
      },
      "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}