{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/scrapenest-dev/json-schema/scrapenest-dev-scrape-url-request-schema.json",
  "title": "ScrapeUrlRequest",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/scrapenest-dev-openapi.json#/components/schemas/ScrapeUrlRequest",
  "properties": {
    "url": {
      "type": "string",
      "minLength": 1,
      "format": "uri",
      "title": "Url",
      "description": "Absolute http(s) URL to fetch."
    },
    "render": {
      "type": "string",
      "enum": [
        "auto",
        "direct",
        "browser",
        "stealth"
      ],
      "title": "Render",
      "description": "How to render: 'direct' = plain HTTP (cheapest; a hard tier pin: if the target blocks it you receive the block as-is, never an escalated retry or stealth charge), 'browser' = headless browser, 'stealth' = anti-bot evasion mode for hardened targets (slower; up to 40 credits, billed by the lane that served it, free if the page stays blocked), 'auto' = pick automatically based on the target.",
      "default": "auto"
    },
    "force_proxy": {
      "type": "boolean",
      "title": "Force Proxy",
      "description": "Force the fetch through a higher-tier proxy even if a direct fetch would have worked.",
      "default": false
    },
    "auto_escalate": {
      "type": "boolean",
      "title": "Auto Escalate",
      "description": "Applies to render='auto' and render='browser': when the fetch is refused by the target's anti-bot, automatically retry once in stealth mode. You are only charged the stealth rate if that retry succeeds; a request that stays blocked is free. Set false to receive the block as-is. render='direct' never escalates, and render='stealth' already is the escalation tier.",
      "default": true
    },
    "timeout_seconds": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 120.0,
          "minimum": 1.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Timeout Seconds",
      "description": "Hard time budget for the whole request, including any wait for a render slot and any auto-escalation retry. Lower it (down to 1) to fail fast on hard targets or for quick page reads; raise it for slow stealth solves. Retries that cannot finish inside the remaining budget are skipped. On timeout the response has success=false and error_code='timeout'. Defaults to ~100s."
    },
    "block_assets": {
      "type": "boolean",
      "title": "Block Assets",
      "description": "When rendering with a browser, block images / fonts / media to save bandwidth.",
      "default": true
    },
    "extract": {
      "type": "boolean",
      "title": "Extract",
      "description": "Run readability-style extraction to return cleaned title / description / text / JSON-LD.",
      "default": true
    },
    "cache_ttl_seconds": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 86400.0,
          "minimum": 0.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Cache Ttl Seconds",
      "description": "Override the default cache TTL for this request."
    },
    "ai_query": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ],
      "title": "Ai Query",
      "description": "Natural-language extraction prompt. Example: 'Return the product name, price, and rating'. When set, response includes an ai_extract field with the AI's answer. Adds 5 credits, billed only when the page is delivered and the extraction runs."
    },
    "ai_extract_schema": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ai Extract Schema",
      "description": "JSON Schema constraining the ai_extract output to a typed object. When set with ai_query, the response's ai_extract field is validated against this schema. Max 10 KB serialized."
    },
    "include_usage": {
      "type": "boolean",
      "title": "Include Usage",
      "description": "If true, include a usage block in the response with credit totals and breakdown.",
      "default": false
    },
    "include_html": {
      "type": "boolean",
      "title": "Include Html",
      "description": "If true, the response includes a raw `html` field with the page source as received from the target (before extraction). Useful when you want both clean text and the raw markup in one call. No extra credits.",
      "default": false
    },
    "return_markdown": {
      "type": "boolean",
      "title": "Return Markdown",
      "description": "If true, the response includes a `markdown` field with the page content converted to Markdown. The raw `html` field still needs include_html. No extra credits.",
      "default": false
    },
    "markdown_mode": {
      "type": "string",
      "enum": [
        "main",
        "full"
      ],
      "title": "Markdown Mode",
      "description": "'main' (default) converts only the page's main content: navigation, headers, footers, sidebars, forms and inline data: images are dropped and the article/main region is kept, tables included. 'full' converts the whole page as served. Also decides what ai_query reads.",
      "default": "main"
    },
    "github_api": {
      "type": "boolean",
      "title": "Github Api",
      "description": "For github.com repository URLs, read GitHub's own API and raw file host instead of rendering the HTML page. A repo root returns its metadata (description, stars, forks, language, topics, license, default branch, last push, homepage, archived), top-level file list and README; /tree/{ref}/{path} returns that directory's listing and README; /blob/{ref}/{path} returns the raw file (first 1 MB); /issues/{n} and /pull/{n} return title, state, author, body and the first 30 comments. The content comes back in `text` (and `markdown` when return_markdown is set), structured fields under `structured.github`, `final_url` is the URL you sent and `method` is 'github_api'. Billed as a plain fetch. Any other URL, a private or missing repo, or a GitHub failure falls back to the normal page fetch; when GitHub's API rate limit is hit, metadata and listings are omitted and READMEs and files are still served. Ignored when include_html, extract_rules or ai_query is set.",
      "default": false
    },
    "max_chars": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 2000000.0,
          "minimum": 200.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Max Chars",
      "description": "Return at most this many characters of `text` (and of `markdown`). Longer content comes back as a window: the passages matching `focus` when it is set, otherwise the page from `offset`, with `next_offset` pointing at the rest. Omit for the full text."
    },
    "offset": {
      "type": "integer",
      "minimum": 0.0,
      "title": "Offset",
      "description": "Character offset into `text` (and `markdown`) to start the window at. Pass the `next_offset` of a previous response to read on.",
      "default": 0
    },
    "focus": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 500
        },
        {
          "type": "null"
        }
      ],
      "title": "Focus",
      "description": "What you are looking for on the page: terms, identifiers or a \"quoted phrase\". When the content is longer than max_chars, the best-matching passages are returned in page order, with the skipped spans marked, instead of only the beginning."
    },
    "extract_rules": {
      "anyOf": [
        {
          "additionalProperties": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "additionalProperties": true,
                "type": "object"
              }
            ]
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Extract Rules",
      "description": "Map of field name -> CSS selector for in-response extraction. Each value can be a CSS selector string (returns first match's text) or an object `{\"selector\": \"...\", \"attr\": \"href\", \"all\": true}` for finer control. Result is returned in the `extracted` field. The raw `html` field still needs include_html. Max 50 rules. No extra credits."
    },
    "wait_ms": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 10000.0,
          "minimum": 0.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Wait Ms",
      "description": "Extra wait, in milliseconds, after the page finishes loading and before we read the DOM. Useful for late-loading content. Only applies when the page is rendered with a browser."
    },
    "wait_for_selector": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 300
        },
        {
          "type": "null"
        }
      ],
      "title": "Wait For Selector",
      "description": "CSS selector to wait for before returning. The fetch blocks until this element appears or `wait_for_timeout_ms` elapses. Only applies when the page is rendered with a browser."
    },
    "wait_for_timeout_ms": {
      "type": "integer",
      "maximum": 30000.0,
      "minimum": 100.0,
      "title": "Wait For Timeout Ms",
      "description": "Max ms to wait for `wait_for_selector`. Default 5000.",
      "default": 5000
    },
    "window_width": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 3840.0,
          "minimum": 320.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Window Width",
      "description": "Browser viewport width in pixels (default 1280). Only applies when the page is rendered with a browser."
    },
    "window_height": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 2160.0,
          "minimum": 240.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Window Height",
      "description": "Browser viewport height in pixels (default 720). Only applies when the page is rendered with a browser."
    },
    "country": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2,
          "minLength": 2,
          "pattern": "^[a-zA-Z]{2}$"
        },
        {
          "type": "null"
        }
      ],
      "title": "Country",
      "description": "ISO 3166-1 alpha-2 country code. Routes the fetch through a residential exit in that country (e.g. `de`), billed at the residential tier. Availability follows the live residential pool; a country with no exit right now is refused with 422 country_unavailable (not retryable, not billed) rather than falling back to another country. A successful response reports the exit in `exit_country`."
    },
    "device": {
      "type": "string",
      "enum": [
        "desktop",
        "mobile"
      ],
      "title": "Device",
      "description": "Device profile. `mobile` sets a mobile User-Agent and a 390x844 viewport (iPhone-like); `desktop` is the default. Only matters when the page is rendered with a browser.",
      "default": "desktop"
    },
    "block_ads": {
      "type": "boolean",
      "title": "Block Ads",
      "description": "Block known ad and tracker domains during the fetch (doubleclick, google-analytics, googletagmanager, criteo, taboola, etc.). Speeds up rendering on ad-heavy sites. Only applies when the page is rendered with a browser.",
      "default": false
    },
    "simulate_behavior": {
      "type": "boolean",
      "title": "Simulate Behavior",
      "description": "Sprinkle mouse-move + scroll motion before extraction to fool behavioral bot detectors (PerimeterX, DataDome, Akamai BMP). Adds ~200-600ms. Browser path only.",
      "default": false
    },
    "session_id": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 64,
          "pattern": "^[A-Za-z0-9_.\\-]+$"
        },
        {
          "type": "null"
        }
      ],
      "title": "Session Id",
      "description": "Opaque sticky-session id. Repeated requests with the same id reuse the same residential exit IP for ~10 minutes. Forces a higher-tier proxy. Use for login flows or cart sessions."
    },
    "cookies": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object",
          "maxProperties": 50
        },
        {
          "type": "null"
        }
      ],
      "title": "Cookies",
      "description": "Cookies (name -> value) injected into the request before navigation. Names must be HTTP tokens; values may not contain control characters or ';'. Anything else is refused with 422 validation_error."
    },
    "headers": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object",
          "maxProperties": 30
        },
        {
          "type": "null"
        }
      ],
      "title": "Headers",
      "description": "Extra request headers (name -> value). Use to set User-Agent, Referer, or any custom header. Host, Content-Length, Connection, Transfer-Encoding are stripped. Max 30. Names must be HTTP tokens and values may not contain control characters other than tab; anything else is refused with 422 validation_error."
    }
  },
  "type": "object",
  "required": [
    "url"
  ]
}