{
  "openapi": "3.0.1",
  "info": {
    "title": "CNPJ Scraper",
    "description": "Find Brazilian companies by CNAE + state + municipality and enrich with full Receita Federal data. 55M+ companies, municipality iteration past the 20-result cap, BrasilAPI/Minha Receita/OpenCNPJ failover. Keyless, no browser, no proxy.",
    "version": "0.0",
    "x-build-id": "cN0Jc2LZdpi7wSWFW"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/aurenic~cnpj-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-aurenic-cnpj-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/aurenic~cnpj-scraper/runs": {
      "post": {
        "operationId": "runs-sync-aurenic-cnpj-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/aurenic~cnpj-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-aurenic-cnpj-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": {
          "mode": {
            "title": "Mode",
            "enum": [
              "discover",
              "enrich"
            ],
            "type": "string",
            "description": "What to do.",
            "default": "discover"
          },
          "cnaes": {
            "title": "CNAE Codes",
            "type": "array",
            "description": "7-digit CNAE activity codes. Common: 5611201 (restaurants), 6201501 (custom software), 4711301 (supermarkets), 8630504 (medical clinics). Full list at cnae.ibge.gov.br.",
            "items": {
              "type": "string"
            }
          },
          "ufs": {
            "title": "States (UF)",
            "type": "array",
            "description": "Brazilian state codes (SP, RJ, MG, BA, etc.). Leave empty for all Brazil.",
            "items": {
              "type": "string"
            }
          },
          "municipios": {
            "title": "Municipalities",
            "type": "array",
            "description": "Optional specific cities to query. Leave empty to iterate EVERY municipality in each UF automatically (slow for large states — can hit Apify's default 300s run timeout). Default input uses 5 small SP municipalities so the run completes fast.",
            "items": {
              "type": "string"
            }
          },
          "situacao": {
            "title": "Registration Status",
            "enum": [
              "ATIVA",
              "BAIXADA",
              "SUSPENSA",
              "INAPTA",
              "NULA"
            ],
            "type": "string",
            "description": "Filter by cadastral status.",
            "default": "ATIVA"
          },
          "iterateMunicipalities": {
            "title": "Iterate Municipalities",
            "type": "boolean",
            "description": "Automatically iterate every municipality in each UF. This is what turns the 20-results-per-query cap into thousands per CNAE. Municipality list is fetched free from IBGE.",
            "default": true
          },
          "enrich": {
            "title": "Enrich Records",
            "type": "boolean",
            "description": "After discovery, fetch the full Receita Federal record for each CNPJ (phone, email, capital, QSA). Uses BrasilAPI → Minha Receita → OpenCNPJ failover. Adds ~1 request per company.",
            "default": true
          },
          "cnpjs": {
            "title": "CNPJs",
            "type": "array",
            "description": "CNPJ numbers to look up. Used in enrich mode. Digits only or formatted.",
            "items": {
              "type": "string"
            }
          },
          "maxPerMunicipality": {
            "title": "Max per Municipality",
            "minimum": 1,
            "maximum": 20,
            "type": "integer",
            "description": "Companies per municipality query. The public Casa dos Dados endpoint caps at 20.",
            "default": 20
          },
          "maxItems": {
            "title": "Max Items",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Hard cap on records per run. Default 100 keeps test runs under 2 minutes; raise to 10000+ for production bulk extraction.",
            "default": 100
          },
          "requestDelayMs": {
            "title": "Request Delay (ms)",
            "minimum": 100,
            "maximum": 5000,
            "type": "integer",
            "description": "Delay between requests. Free mirrors have no published limit; 300ms is polite.",
            "default": 300
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}