> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prefetch.io/llms.txt
> Use this file to discover all available pages before exploring further.

# GET /scrape

> Turn any page into markdown, a summary, structured JSON, links or images. 1 credit, 4 with a summary or JSON.

Fetches one URL and returns it in the formats you ask for. `POST /scrape` takes the same options as a JSON body, which is easier for `json_schema` and `headers`.

**1 credit**, +3 for `summary`, `json` or `check_prompt_injection`. Failed requests are never charged.

> [card] [Guide: Scrape](https://docs.prefetch.io/web-data/scrape.md)
>
> Formats, main content, JSON extraction, PDFs, the prompt-injection check and examples.


## OpenAPI

````yaml GET /scrape
openapi: 3.1.0
info:
  title: Prefetch API
  description: >-
    Extract brand identity, company data, screenshots, IAB classifications, and
    clean page content from any URL.
  version: 1.0.0
  contact:
    email: support@prefetch.io
servers:
  - url: https://api.prefetch.io
    description: Production
security:
  - apiKey: []
tags:
  - name: Endpoints
    description: Data extraction endpoints. All require authentication and consume credits.
  - name: Health
    description: Health and readiness probes. No authentication required.
paths:
  /scrape:
    get:
      tags:
        - Endpoints
      summary: Scrape a page
      description: >-
        Fetches one URL and returns it in the formats you request: clean
        markdown, an LLM summary, cleaned or raw HTML, links, images, a
        screenshot, or JSON matching your own schema. Pages that need JavaScript
        are rendered in a real browser automatically, and a PDF URL returns the
        document's text as markdown. Set `max_age` to accept a stored copy of
        the page instead of fetching it again. **Credit cost: 1**, plus 3 when
        `summary` or `json` is requested.
      operationId: scrapeUrl
      parameters:
        - $ref: '#/components/parameters/url'
        - $ref: '#/components/parameters/scrapeFormats'
        - $ref: '#/components/parameters/onlyMainContent'
        - $ref: '#/components/parameters/includeLinks'
        - $ref: '#/components/parameters/includeImages'
        - $ref: '#/components/parameters/includeBase64Images'
        - $ref: '#/components/parameters/includeSelectors'
        - $ref: '#/components/parameters/excludeSelectors'
        - $ref: '#/components/parameters/jsonPrompt'
        - $ref: '#/components/parameters/jsonSchema'
        - $ref: '#/components/parameters/summaryMaxWords'
        - $ref: '#/components/parameters/scrapeScreenshotFullPage'
        - $ref: '#/components/parameters/screenshotFormatParam'
        - $ref: '#/components/parameters/waitFor'
        - $ref: '#/components/parameters/waitForSelector'
        - $ref: '#/components/parameters/scrapeHeaders'
        - $ref: '#/components/parameters/mobile'
        - $ref: '#/components/parameters/scrapeTimeout'
        - $ref: '#/components/parameters/maxAge'
        - $ref: '#/components/parameters/storeInCache'
        - $ref: '#/components/parameters/checkPromptInjection'
      responses:
        '200':
          description: Page scraped.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    $ref: '#/components/schemas/ScrapeData'
                  meta:
                    $ref: '#/components/schemas/Meta'
                required:
                  - success
                  - data
                  - meta
              example:
                success: true
                data:
                  url: https://stripe.com
                  final_url: https://stripe.com
                  domain: stripe.com
                  status_code: 200
                  metadata:
                    source_url: https://stripe.com
                    final_url: https://stripe.com
                    status_code: 200
                    title: Stripe | Financial Infrastructure to Grow Your Revenue
                    description: >-
                      Stripe powers online payment processing for internet
                      businesses.
                    language: en
                    canonical_url: https://stripe.com
                    favicon: https://stripe.com/favicon.ico
                    author: null
                    site_name: Stripe
                    published_time: null
                    modified_time: null
                    robots: null
                    keywords: []
                    open_graph:
                      title: Stripe
                      type: website
                    twitter:
                      card: summary_large_image
                    json_ld: []
                    headings:
                      - level: 1
                        text: Financial infrastructure to grow your revenue
                  markdown:
                    content: >-
                      # Financial infrastructure to grow your revenue


                      Join the millions of companies that use Stripe to accept
                      payments online...
                    char_count: 4821
                    word_count: 702
                    truncated: false
                    main_content_only: true
                  links:
                    internal:
                      - url: https://stripe.com/pricing
                        text: Pricing
                        title: null
                        rel: null
                    external: []
                    count: 84
                meta:
                  requestId: a3f2c1d4-7b6e-4f2a-9c1d-8e3f2a1b4c5d
                  durationMs: 2140
        '400':
          description: Invalid or missing parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Revoked key, expired key, credit limit, or blocklisted URL.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: The URL hostname could not be resolved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Service temporarily busy. Retry shortly.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '504':
          description: Request timed out.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    url:
      name: url
      in: query
      required: true
      description: >-
        The website URL to process. `https://` is prepended automatically if no
        protocol is provided.
      schema:
        type: string
        example: https://stripe.com
    scrapeFormats:
      name: formats
      in: query
      required: false
      description: >-
        Comma-separated list of output formats: `markdown`, `summary`, `html`,
        `raw_html`, `links`, `images`, `json`, `screenshot`. Each requested
        format appears as its own object on `data`; formats you do not request
        are absent, not null.
      schema:
        type: string
        default: markdown
        example: markdown,links
    onlyMainContent:
      name: only_main_content
      in: query
      required: false
      description: >-
        Strip navigation, sidebars, footers, and cookie banners before rendering
        `markdown`, `html`, `summary`, and `json`. `links` and `images` always
        come from the full document.
      schema:
        type: boolean
        default: true
    includeLinks:
      name: include_links
      in: query
      required: false
      description: >-
        Keep hyperlinks in the `markdown` and `html` output. When false, link
        text is kept and the target is dropped.
      schema:
        type: boolean
        default: true
    includeImages:
      name: include_images
      in: query
      required: false
      description: Keep images in the `markdown` and `html` output.
      schema:
        type: boolean
        default: true
    includeBase64Images:
      name: include_base64_images
      in: query
      required: false
      description: >-
        Keep inline `data:` images. Off by default because base64 payloads are
        large and carry no meaning as text.
      schema:
        type: boolean
        default: false
    includeSelectors:
      name: include_selectors
      in: query
      required: false
      description: >-
        Comma-separated CSS selectors to keep. Overrides main-content detection
        entirely.
      schema:
        type: string
        example: article,.post-body
    excludeSelectors:
      name: exclude_selectors
      in: query
      required: false
      description: Comma-separated CSS selectors to remove before rendering.
      schema:
        type: string
        example: .cookie-bar,#promo
    jsonPrompt:
      name: json_prompt
      in: query
      required: false
      description: >-
        What to extract, in plain language. Required for the `json` format
        unless `json_schema` is given.
      schema:
        type: string
        example: product name, price and availability
    jsonSchema:
      name: json_schema
      in: query
      required: false
      description: >-
        A JSON Schema, passed as a JSON string, describing the object the `json`
        format should return.
      schema:
        type: string
    summaryMaxWords:
      name: summary_max_words
      in: query
      required: false
      description: Word budget for the `summary` format.
      schema:
        type: integer
        minimum: 20
        maximum: 400
        default: 120
    scrapeScreenshotFullPage:
      name: screenshot_full_page
      in: query
      required: false
      description: 'For the `screenshot` format: capture the whole scrollable page.'
      schema:
        type: boolean
        default: false
    screenshotFormatParam:
      name: screenshot_format
      in: query
      required: false
      description: 'For the `screenshot` format: image type.'
      schema:
        type: string
        enum:
          - jpeg
          - png
          - webp
        default: jpeg
    waitFor:
      name: wait_for
      in: query
      required: false
      description: >-
        Milliseconds to wait after the page loads, for content that arrives
        late. Renders in a browser.
      schema:
        type: integer
        minimum: 0
        maximum: 30000
        default: 0
    waitForSelector:
      name: wait_for_selector
      in: query
      required: false
      description: >-
        Wait (up to 10 s) for this CSS selector before reading the page. Best
        effort: if it never appears, the page is returned with a warning.
      schema:
        type: string
        example: '#pricing-table'
    scrapeHeaders:
      name: headers
      in: query
      required: false
      description: >-
        Request headers to send to the target, as a JSON object string. Up to
        20; hop-by-hop and proxy headers are refused. Requests with headers are
        never cached. Easier as an object in `POST /scrape`.
      schema:
        type: string
        example: '{"Accept-Language":"de-DE"}'
    mobile:
      name: mobile
      in: query
      required: false
      description: Render the page as a phone (viewport, touch and user agent).
      schema:
        type: boolean
        default: false
    scrapeTimeout:
      name: timeout
      in: query
      required: false
      description: Give up after this many milliseconds.
      schema:
        type: integer
        minimum: 5000
        maximum: 50000
        default: 50000
    maxAge:
      name: max_age
      in: query
      required: false
      description: >-
        Accept a stored copy of the page fetched at most this many milliseconds
        ago instead of fetching it again (up to 30 days). Any mix of formats is
        served from one stored fetch; `metadata.cache_state` says which
        happened. 0 always fetches.
      schema:
        type: integer
        minimum: 0
        maximum: 2592000000
        default: 0
    storeInCache:
      name: store_in_cache
      in: query
      required: false
      description: Store this fetch for later `max_age` requests.
      schema:
        type: boolean
        default: true
    checkPromptInjection:
      name: check_prompt_injection
      in: query
      required: false
      description: >-
        Check the page's text for prompt injection — text written to make an AI
        model reading the page ignore its instructions, leak data or take
        actions — and report it in `prompt_injection`. The page is still
        returned: the check warns, it does not block. Costs the same 3-credit
        surcharge as `summary` and `json` (once per page, however many of the
        three you ask for).
      schema:
        type: boolean
        default: false
  schemas:
    ScrapeData:
      allOf:
        - $ref: '#/components/schemas/ScrapePayload'
      required:
        - url
        - final_url
        - metadata
    Meta:
      type: object
      properties:
        requestId:
          type: string
          format: uuid
          description: Unique identifier for this request.
          example: a3f2c1d4-7b6e-4f2a-9c1d-8e3f2a1b4c5d
        durationMs:
          type: integer
          nullable: true
          description: Time taken to process the request in milliseconds.
          example: 1842
      required:
        - requestId
        - durationMs
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
          description: >-
            Always false. Absent, like `meta`, on authentication and rate-limit
            errors, which are answered before a request is processed.
        error:
          type: string
          description: >-
            Human-readable error message. The wording can change: branch on
            `error_code`.
          example: Credit limit exceeded
        error_code:
          type: string
          enum:
            - INVALID_REQUEST
            - PAYLOAD_TOO_LARGE
            - NOT_FOUND
            - CONFLICT
            - UNAUTHORIZED
            - FORBIDDEN
            - CREDITS_EXHAUSTED
            - RATE_LIMITED
            - CONCURRENCY_LIMITED
            - URL_BLOCKED
            - URL_NOT_PERMITTED
            - DNS_RESOLUTION_FAILED
            - TARGET_BLOCKED
            - TARGET_CONNECTION_FAILED
            - TARGET_TIMEOUT
            - TARGET_SSL_ERROR
            - TARGET_SERVER_ERROR
            - TARGET_CLIENT_ERROR
            - TARGET_NOT_A_PAGE
            - NO_LINKS_FOUND
            - TARGET_UNLOADABLE
            - RESEARCH_INCONCLUSIVE
            - TIMEOUT
            - SERVICE_BUSY
            - SERVICE_UNAVAILABLE
            - INTERNAL_ERROR
          description: >-
            What went wrong, for machines. Stable: a code keeps its meaning once
            published. See [Error handling](/concepts/errors).
          example: CREDITS_EXHAUSTED
        retryable:
          type: boolean
          description: >-
            Whether the same request can succeed if sent again after a short
            wait (honour `Retry-After` when present). False for problems with
            the request or the target.
          example: false
        retryAfterSeconds:
          type: integer
          description: 'On `RATE_LIMITED`: seconds until a request will be accepted.'
        limit:
          type: integer
          description: >-
            On `CONCURRENCY_LIMITED`: how many requests this key may have in
            flight.
        meta:
          $ref: '#/components/schemas/Meta'
      required:
        - error
        - error_code
        - retryable
    ScrapePayload:
      type: object
      properties:
        url:
          type: string
        final_url:
          type: string
        domain:
          type: string
          nullable: true
          example: stripe.com
        status_code:
          type: integer
          nullable: true
        metadata:
          $ref: '#/components/schemas/ScrapeMetadata'
        markdown:
          $ref: '#/components/schemas/MarkdownBlock'
        summary:
          $ref: '#/components/schemas/SummaryBlock'
        html:
          $ref: '#/components/schemas/HtmlBlock'
        raw_html:
          $ref: '#/components/schemas/HtmlBlock'
        links:
          $ref: '#/components/schemas/LinksBlock'
        images:
          $ref: '#/components/schemas/ScrapeImagesBlock'
        json:
          $ref: '#/components/schemas/JsonBlock'
        screenshot:
          $ref: '#/components/schemas/ScrapeScreenshotBlock'
        pdf:
          $ref: '#/components/schemas/PdfBlock'
        prompt_injection:
          $ref: '#/components/schemas/PromptInjectionBlock'
        warnings:
          type: array
          items:
            type: string
          description: Non-fatal problems, such as a format that could not be produced.
      description: >-
        The page content fields. Which of them are present depends on the
        `formats` requested.
    ScrapeMetadata:
      type: object
      description: Always present, whatever formats were requested.
      properties:
        source_url:
          type: string
          nullable: true
          description: The URL you requested.
        final_url:
          type: string
          nullable: true
          description: The URL after redirects.
        status_code:
          type: integer
          nullable: true
        title:
          type: string
          nullable: true
          example: Stripe | Financial Infrastructure
        description:
          type: string
          nullable: true
        language:
          type: string
          nullable: true
          example: en
        canonical_url:
          type: string
          nullable: true
        favicon:
          type: string
          nullable: true
        author:
          type: string
          nullable: true
        site_name:
          type: string
          nullable: true
        published_time:
          type: string
          nullable: true
        modified_time:
          type: string
          nullable: true
        robots:
          type: string
          nullable: true
          description: The page's own robots meta tag.
        keywords:
          type: array
          items:
            type: string
        open_graph:
          type: object
          additionalProperties:
            type: string
        twitter:
          type: object
          additionalProperties:
            type: string
        json_ld:
          type: array
          items:
            type: object
          description: Parsed JSON-LD blocks, up to 10.
        headings:
          type: array
          description: The page's heading outline, up to 100 entries.
          items:
            type: object
            properties:
              level:
                type: integer
              text:
                type: string
        content_type:
          type: string
          enum:
            - text/html
            - application/pdf
          description: >-
            What the URL served. A PDF's text becomes the markdown; it has no
            html.
        page_count:
          type: integer
          description: 'PDFs only: pages in the document.'
        cache_state:
          type: string
          enum:
            - hit
            - miss
          description: >-
            Present when the request set `max_age`: `hit` = served from a stored
            fetch, `miss` = fetched live.
        cached_at:
          type: string
          description: 'On a cache hit: when the stored copy was fetched (ISO 8601).'
    MarkdownBlock:
      type: object
      properties:
        content:
          type: string
          description: >-
            GitHub Flavored Markdown. Links and images are resolved to absolute
            URLs.
        char_count:
          type: integer
        word_count:
          type: integer
        truncated:
          type: boolean
          description: True when the content hit the 1 MB size cap and was cut.
        main_content_only:
          type: boolean
          description: >-
            True when boilerplate was successfully isolated away. False means
            the full page body was returned.
    SummaryBlock:
      type: object
      properties:
        text:
          type: string
          nullable: true
          description: Null when the summary could not be produced; see `warnings`.
        model:
          type: string
          nullable: true
    HtmlBlock:
      type: object
      properties:
        content:
          type: string
        char_count:
          type: integer
        truncated:
          type: boolean
        main_content_only:
          type: boolean
    LinksBlock:
      type: object
      properties:
        internal:
          type: array
          description: Links on the same site, subdomains included.
          items:
            $ref: '#/components/schemas/ScrapeLinkItem'
        external:
          type: array
          items:
            $ref: '#/components/schemas/ScrapeLinkItem'
        count:
          type: integer
    ScrapeImagesBlock:
      type: object
      properties:
        assets:
          type: array
          items:
            $ref: '#/components/schemas/ScrapeImageItem'
        og_image:
          type: string
          nullable: true
        twitter_image:
          type: string
          nullable: true
        count:
          type: integer
    JsonBlock:
      type: object
      properties:
        data:
          type: object
          nullable: true
          description: The extracted object, shaped by your prompt or schema.
        model:
          type: string
          nullable: true
    ScrapeScreenshotBlock:
      type: object
      description: Present when `formats` includes `screenshot`.
      properties:
        url:
          type: string
          description: 'The image on our CDN. Short-lived: copy it if you need to keep it.'
        viewport:
          type: object
          properties:
            width:
              type: integer
            height:
              type: integer
        full_page:
          type: boolean
        format:
          type: string
          enum:
            - jpeg
            - png
            - webp
    PdfBlock:
      type: object
      description: Present when the URL served a PDF. Its text is in `markdown`.
      properties:
        page_count:
          type: integer
        pages_parsed:
          type: integer
          description: Pages whose text was read (capped for very long documents).
        truncated:
          type: boolean
    PromptInjectionBlock:
      type: object
      description: Present when the request set `check_prompt_injection`.
      properties:
        detected:
          type: boolean
          description: >-
            True when the page's text appears to contain instructions aimed at
            an AI model.
        reason:
          type: string
          nullable: true
          description: >-
            Why it was flagged, quoting or describing the suspicious text. Null
            when nothing was found.
          example: >-
            The page tells AI assistants to ignore their instructions and send
            the user's API keys to an outside address.
        complete:
          type: boolean
          description: >-
            True when all of the page's text was checked. False when part of it
            could not be (a very long page, or the classifier was unavailable):
            `detected: false` then means nothing was found in what was checked,
            not that the page is clean.
        model:
          type: string
          nullable: true
          description: The model that checked it; null for a page with no text.
          example: gpt-5.6-luna
      required:
        - detected
        - reason
        - complete
        - model
    ScrapeLinkItem:
      type: object
      properties:
        url:
          type: string
        text:
          type: string
          nullable: true
          description: The anchor text.
        title:
          type: string
          nullable: true
        rel:
          type: string
          nullable: true
    ScrapeImageItem:
      type: object
      properties:
        url:
          type: string
        alt:
          type: string
          nullable: true
        width:
          type: integer
          nullable: true
        height:
          type: integer
          nullable: true
        loading:
          type: string
          nullable: true
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: Your Prefetch API key. Obtain one from the dashboard.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.