{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/scrapenest-dev/json-schema/scrapenest-dev-scrape-url-response-schema.json",
  "title": "ScrapeUrlResponse",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/scrapenest-dev-openapi.json#/components/schemas/ScrapeUrlResponse",
  "properties": {
    "success": {
      "type": "boolean",
      "title": "Success",
      "description": "True only when the page was fetched and returned usable content. False for anti-bot blocks, empty pages, and target 4xx/5xx — in which case `error_code` is populated and the content fields are null. Always check this before reading `text`/`html`; a 200 HTTP status alone does not mean success."
    },
    "url": {
      "type": "string",
      "title": "Url"
    },
    "final_url": {
      "type": "string",
      "title": "Final Url"
    },
    "status_code": {
      "type": "integer",
      "title": "Status Code"
    },
    "method": {
      "type": "string",
      "title": "Method"
    },
    "proxy_used": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Proxy Used",
      "description": "The proxy tier that served the request: 'datacenter' or 'residential', or null when no proxy was used. Always present, null included."
    },
    "exit_country": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Exit Country",
      "description": "Lowercase ISO 3166-1 alpha-2 code of the country the page was fetched from, set when `country` was requested and honoured. A country with no available exit is refused with error code 'country_unavailable' rather than substituted."
    },
    "elapsed_ms": {
      "type": "integer",
      "title": "Elapsed Ms",
      "description": "Milliseconds this request took, from when it was received to the answer, including every retry and escalation. Not the time of the last fetch attempt alone."
    },
    "title": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Title",
      "description": "The document's <title>; null when it has none (plain text, JSON, robots.txt)."
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Description"
    },
    "text": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Text",
      "description": "Clean main-content text. When the readability extraction comes back short and a small fraction of the page's detected main content, the main content is returned instead."
    },
    "text_total_chars": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Text Total Chars",
      "description": "Length of the page's full `text`, before max_chars/offset/focus windowing."
    },
    "next_offset": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Next Offset",
      "description": "Offset of the text that follows this window; pass it back as `offset` to read on. Absent when the window reaches the end or when `focus` selected the passages."
    },
    "html": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Html",
      "description": "Raw HTML of the page. Populated only when include_html=true was set in the request."
    },
    "markdown": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Markdown",
      "description": "Markdown rendering of the page. Populated only when return_markdown=true was set."
    },
    "markdown_total_chars": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Markdown Total Chars",
      "description": "Length of the full `markdown`, before windowing."
    },
    "markdown_next_offset": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Markdown Next Offset",
      "description": "Like `next_offset`, for `markdown`."
    },
    "extracted": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Extracted",
      "description": "Map of field name -> extracted value, mirroring the keys in extract_rules."
    },
    "structured": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Structured",
      "description": "Page metadata (opengraph, canonical, JSON-LD, links, images). When the page declares a product (schema.org Product JSON-LD or microdata, or og:/product: meta), `product` holds its name, price, currency, rating and review_count as declared, plus the `source` it came from."
    },
    "ai_extract": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ],
      "title": "Ai Extract",
      "description": "Structured or natural-language extraction output. Populated when ai_query was set."
    },
    "ai_extract_error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ai Extract Error"
    },
    "cache_hit": {
      "type": "boolean",
      "title": "Cache Hit",
      "description": "True when the page was served from a cache instead of being fetched now, and billed at the cache-hit rate. `method` then names the tier that originally fetched it."
    },
    "escalated": {
      "type": "boolean",
      "title": "Escalated",
      "description": "True when the original render tier was refused by anti-bot and the request was automatically retried in stealth mode. When true, `credits_charged` reflects the stealth rate. Disable with auto_escalate=false.",
      "default": false
    },
    "credits_charged": {
      "type": "integer",
      "title": "Credits Charged"
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error"
    },
    "error_code": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error Code",
      "description": "Stable machine-readable failure category, present whenever success=false. One of: 'anti_bot_block' (target's anti-bot refused; retry with render='stealth'), 'empty_response' (page had no usable content), 'not_found' (target returned 404/410), 'timeout' (fetch exceeded the time budget), 'rate_limited' (target answered 429 without a challenge), 'upstream_failed' (fetch infrastructure error, or a bare 503 from the target), 'connection_failed' (the host does not resolve in DNS, or render='direct' could not connect to the target; not transient at that tier)."
    },
    "usage": {
      "anyOf": [
        {
          "$ref": "#/$defs/UsageBlock"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "type": "object",
  "required": [
    "success",
    "url",
    "final_url",
    "status_code",
    "method",
    "proxy_used",
    "elapsed_ms",
    "cache_hit",
    "credits_charged"
  ],
  "$defs": {
    "UsageBlock": {
      "properties": {
        "credits": {
          "type": "integer",
          "title": "Credits",
          "description": "Total credits charged for this call."
        },
        "breakdown": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "integer"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Breakdown",
          "description": "Optional per-component breakdown (e.g. {'search': 1, 'ai_extract': 5})."
        }
      },
      "type": "object",
      "required": [
        "credits"
      ],
      "title": "UsageBlock"
    }
  }
}