{
  "openapi": "3.0.1",
  "info": {
    "title": "TheCrawler — validated extraction contracts for AI agents",
    "description": "Validated extraction contracts for AI agents: crawl pages, diagnose readiness before LLM calls, and extract typed JSON with validation evidence. Markdown, structured errors, PDF/DOCX.",
    "version": "0.1",
    "x-build-id": "edDDhY8gx5z5fR1La"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/accurate_pouch~the-crawler/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-accurate_pouch-the-crawler",
        "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/accurate_pouch~the-crawler/runs": {
      "post": {
        "operationId": "runs-sync-accurate_pouch-the-crawler",
        "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/accurate_pouch~the-crawler/run-sync": {
      "post": {
        "operationId": "run-sync-accurate_pouch-the-crawler",
        "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": [
          "urls"
        ],
        "properties": {
          "urls": {
            "title": "URLs to Scrape",
            "type": "array",
            "description": "List of URLs to scrape.",
            "items": {
              "type": "string"
            }
          },
          "extractText": {
            "title": "Extract Text",
            "type": "boolean",
            "description": "Extract visible text content (scripts/styles removed).",
            "default": true
          },
          "extractLinks": {
            "title": "Extract Links",
            "type": "boolean",
            "description": "Extract all links with href, anchor text, and internal/external flag.",
            "default": true
          },
          "extractImages": {
            "title": "Extract Images",
            "type": "boolean",
            "description": "Extract all images with src, alt text, dimensions.",
            "default": true
          },
          "extractMeta": {
            "title": "Extract Meta Tags",
            "type": "boolean",
            "description": "Extract all meta tags (description, og:title, keywords, etc).",
            "default": true
          },
          "extractHeadings": {
            "title": "Extract Headings",
            "type": "boolean",
            "description": "Extract all h1-h6 headings with their level.",
            "default": true
          },
          "extractTables": {
            "title": "Extract Tables",
            "type": "boolean",
            "description": "Extract HTML tables as structured data (headers + rows).",
            "default": true
          },
          "extractStructuredData": {
            "title": "Extract JSON-LD",
            "type": "boolean",
            "description": "Extract JSON-LD structured data (schema.org).",
            "default": true
          },
          "extractEmails": {
            "title": "Extract Emails",
            "type": "boolean",
            "description": "Find email addresses in the page HTML.",
            "default": true
          },
          "extractPhones": {
            "title": "Extract Phone Numbers",
            "type": "boolean",
            "description": "Find phone numbers in the page HTML.",
            "default": true
          },
          "cssSelector": {
            "title": "CSS Selector",
            "type": "string",
            "description": "Target specific content. Returns matching text in selectedContent field. Example: .product-price, #main-content, article"
          },
          "maxDepth": {
            "title": "Crawl Depth",
            "minimum": 0,
            "maximum": 5,
            "type": "integer",
            "description": "0 = scrape listed URLs only. 1+ = follow internal links to that depth.",
            "default": 0
          },
          "maxPages": {
            "title": "Max Pages",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Maximum total pages to scrape (including followed links).",
            "default": 100
          },
          "usePlaywright": {
            "title": "Enable JS Rendering (Playwright)",
            "type": "boolean",
            "description": "Render JavaScript with a real browser. Required for SPAs (React, Vue, Angular), dynamic content, and sites that load data via JS. Uses more compute than default Cheerio mode.",
            "default": false
          },
          "waitForSelector": {
            "title": "Wait for Selector",
            "type": "string",
            "description": "CSS selector to wait for before extracting. Only works with Playwright enabled. Example: .product-list, #content-loaded"
          },
          "waitForMs": {
            "title": "Wait (ms)",
            "minimum": 0,
            "maximum": 30000,
            "type": "integer",
            "description": "Milliseconds to wait after page load before extracting. Only works with Playwright enabled. Useful for lazy-loading content.",
            "default": 0
          },
          "extractMarkdown": {
            "title": "Extract Markdown",
            "type": "boolean",
            "description": "Convert page content to clean Markdown. Strips navigation, footers, and boilerplate when stripBoilerplate is enabled. Ideal for LLM/RAG pipelines.",
            "default": false
          },
          "stripBoilerplate": {
            "title": "Strip Boilerplate",
            "type": "boolean",
            "description": "Remove nav, header, footer, sidebar, and ads before markdown conversion. Keeps only main content.",
            "default": true
          },
          "chunkSize": {
            "title": "Chunk Size (chars)",
            "minimum": 0,
            "maximum": 50000,
            "type": "integer",
            "description": "Split markdown into chunks of this size. Each chunk includes section heading, index, and content hash. Set to 0 to disable chunking.",
            "default": 0
          },
          "chunkOverlap": {
            "title": "Chunk Overlap (chars)",
            "minimum": 0,
            "maximum": 5000,
            "type": "integer",
            "description": "Character overlap between consecutive chunks. Prevents losing context at chunk boundaries. Typical: 10-20% of chunk size.",
            "default": 200
          },
          "includeGlobs": {
            "title": "Include URL Patterns",
            "type": "array",
            "description": "Only follow links matching these glob patterns when crawling. Example: https://example.com/blog/**",
            "items": {
              "type": "string"
            }
          },
          "excludeGlobs": {
            "title": "Exclude URL Patterns",
            "type": "array",
            "description": "Skip links matching these glob patterns. Example: **/login/**, **/admin/**",
            "items": {
              "type": "string"
            }
          },
          "proxyUrl": {
            "title": "Proxy URL",
            "type": "string",
            "description": "HTTP/SOCKS proxy URL for requests. Format: http://user:pass@host:port or socks5://user:pass@host:port. Use Apify Proxy or your own."
          },
          "searchQuery": {
            "title": "Search Query",
            "type": "string",
            "description": "Search Google and scrape the top results. Leave URLs empty to use search mode. Example: 'best project management tools 2026'"
          },
          "searchLimit": {
            "title": "Search Results Limit",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "Maximum number of search results to scrape (default: 10).",
            "default": 10
          },
          "actions": {
            "title": "Browser Actions (Playwright only)",
            "type": "array",
            "description": "Actions to perform before extraction. Requires Playwright enabled. JSON array. Types: click (selector), fill (selector + value), scroll (pixels), wait (ms), screenshot. Example: [{\"type\":\"click\",\"selector\":\".load-more\"},{\"type\":\"scroll\",\"pixels\":2000}]"
          },
          "dryRun": {
            "title": "Dry Run",
            "type": "boolean",
            "description": "Scrape pages but don't charge.",
            "default": false
          },
          "requestRetries": {
            "title": "Request Retries",
            "minimum": 0,
            "maximum": 10,
            "type": "integer",
            "description": "Retry transient failures (5xx, network, timeout) this many times before marking the page failed. Permanent failures (404, parse) are not retried.",
            "default": 3
          },
          "requestTimeoutSecs": {
            "title": "Request Timeout (seconds)",
            "minimum": 5,
            "maximum": 300,
            "type": "integer",
            "description": "Per-request timeout in seconds.",
            "default": 30
          },
          "rotateUserAgent": {
            "title": "Rotate User-Agent",
            "type": "boolean",
            "description": "Rotate User-Agent from a real-browser pool (Chrome / Firefox / Safari) per request. Reduces basic anti-bot WAF detection.",
            "default": true
          },
          "cacheEnabled": {
            "title": "Cache Results (5min TTL)",
            "type": "boolean",
            "description": "Cache page results in-memory keyed by (URL + extract-flags). Same URL within 5 minutes returns cached data with fromCache:true. Useful when the same URLs may appear multiple times in one run (e.g., recursive crawl with shared external pages).",
            "default": false
          },
          "diagnoseMode": {
            "title": "Diagnostic Mode (no LLM)",
            "type": "boolean",
            "description": "Run a contract-readiness diagnostic before LLM extraction. The actor crawls each URL, scores source readiness, and returns verdicts, blockers, warnings, and a recommended next step. Requires urls[].",
            "default": false
          },
          "extractContract": {
            "title": "Extraction Contract",
            "enum": [
              "real-estate-listing"
            ],
            "type": "string",
            "description": "Built-in contract name for diagnostic or extract mode. Current option: real-estate-listing. In extractMode this supplies the schema and validation rules; in diagnoseMode it supplies the readiness signals.",
            "default": "real-estate-listing"
          },
          "diagnosticReport": {
            "title": "Save Diagnostic Report",
            "type": "boolean",
            "description": "When diagnoseMode=true, also save a buyer-readable Markdown report to the run's key-value store as contract-diagnostic-report.",
            "default": false
          },
          "extractMode": {
            "title": "Extract Mode (LLM-powered structured extraction)",
            "type": "boolean",
            "description": "Switch from plain crawl to LLM-powered structured extraction. The actor crawls each URL, cleans to markdown, and asks an OpenAI-compatible LLM to return ONLY a JSON object matching your schema/prompt or the selected extraction contract. Output is parsed typed data per URL; contract mode also adds validation.valid and missingRequiredFields. Requires llmBaseUrl + llmModel (or matching Actor environment variables).",
            "default": false
          },
          "extractJsonSchema": {
            "title": "Extract: JSON Schema",
            "type": "object",
            "description": "JSON Schema describing the desired typed output. The LLM is instructed to return JSON matching this. Either this or extractPrompt is required when extractMode=true. Example: {\"type\":\"object\",\"properties\":{\"productName\":{\"type\":\"string\"},\"price\":{\"type\":\"number\"}},\"required\":[\"productName\"]}"
          },
          "extractPrompt": {
            "title": "Extract: Natural-language Instruction",
            "type": "string",
            "description": "Natural-language extraction instruction (e.g., 'Extract the product name, price, currency, availability'). Used alongside or instead of the JSON schema."
          },
          "llmBaseUrl": {
            "title": "LLM Endpoint URL",
            "type": "string",
            "description": "OpenAI-compatible chat-completions URL. Examples: https://api.openai.com/v1/chat/completions, http://your-llm-host:8080/v1/chat/completions. If left blank, the actor reads THECRAWLER_LLM_BASEURL from the Actor environment variables."
          },
          "llmModel": {
            "title": "LLM Model",
            "type": "string",
            "description": "Model name string the endpoint expects (e.g., gpt-4o-mini, or a .gguf filename for llama.cpp). If blank, reads THECRAWLER_LLM_MODEL env var. The LLM API key (if any) is read from THECRAWLER_LLM_API_KEY Actor env var, never from input — keeps secrets out of run history."
          },
          "llmTemperature": {
            "title": "LLM Temperature",
            "type": "string",
            "description": "Inference temperature as a decimal string ('0', '0.7', '1.0'). 0 is recommended for deterministic extraction. (String editor used because Apify input fields don't natively support floats with custom precision.)",
            "default": "0"
          },
          "llmMaxTokens": {
            "title": "LLM Max Output Tokens",
            "minimum": 100,
            "maximum": 32000,
            "type": "integer",
            "description": "Maximum tokens the LLM may return in the JSON response.",
            "default": 4000
          },
          "llmMarkdownCharLimit": {
            "title": "Markdown Character Limit Sent to LLM",
            "minimum": 1000,
            "maximum": 200000,
            "type": "integer",
            "description": "How much of the page markdown to send to the LLM. Default 30000 chars (≈7.5k tokens). Bigger = more context but slower and more $$ on hosted APIs.",
            "default": 30000
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}