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

# Scrape a URL

> Fetch a page and return clean Markdown and HTML.



## OpenAPI

````yaml POST /v1/api/scrape
openapi: 3.1.0
info:
  title: PagePith API
  version: 0.1.0
  description: >-
    Turn any web page into clean, structured content. The API handles
    JavaScript-rendered sites, PDFs, and most bot-protected pages, returning
    readable markdown. Authenticate with your API key as a Bearer token. Usage
    is billed per successful scrape.
servers:
  - url: https://api.pagepith.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Scrape
    description: Fetch and convert web pages
  - name: Video
    description: Transcribe public YouTube, Instagram, and TikTok videos
  - name: Monitoring
    description: Watch public pages for content changes
  - name: Blog
    description: Read published PagePith engineering articles
paths:
  /v1/api/scrape:
    post:
      tags:
        - Scrape
      summary: Scrape a URL (synchronous)
      description: >-
        Fetch a page and return its content. Best for low-latency lookups where
        the caller can wait a few seconds. Each successful scrape is billed
        once.
      operationId: scrapeSync
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScrapeRequest'
            example:
              url: https://example.com
      responses:
        '200':
          description: The scraped page.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScrapeResult'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          description: The page is behind a login wall.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScrapeError'
        '404':
          description: The URL does not exist (dead link / unresolvable).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScrapeError'
        '422':
          description: The page could not be converted to readable content.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScrapeError'
        '502':
          description: The origin site returned a server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScrapeError'
components:
  schemas:
    ScrapeRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: The URL to scrape.
        forceFresh:
          type: boolean
          description: Bypass the cache and fetch a fresh copy.
        timeoutMs:
          type: integer
          minimum: 1000
          maximum: 120000
          description: Per-request timeout in milliseconds.
        waitForSelector:
          type: string
          description: Wait for this CSS selector before extracting dynamic content.
        extraWaitMs:
          type: integer
          minimum: 0
          maximum: 10000
          description: Additional settle time for dynamic content, in milliseconds.
    ScrapeResult:
      type: object
      properties:
        url:
          type: string
        finalUrl:
          type: string
          description: The URL after redirects.
        title:
          type:
            - string
            - 'null'
        markdown:
          type: string
          description: The readable page content as markdown.
        html:
          type: string
        contentLength:
          type: integer
        fetchedAt:
          type: string
          format: date-time
        cached:
          type: boolean
          description: True if served from cache.
      required:
        - url
        - finalUrl
        - markdown
        - contentLength
        - fetchedAt
        - cached
    ScrapeError:
      type: object
      properties:
        error:
          type: string
          description: Machine-readable error code.
          examples:
            - URL_NOT_FOUND
            - AUTH_REQUIRED
            - ORIGIN_ERROR
            - SCRAPE_FAILED
        message:
          type: string
        url:
          type: string
      required:
        - error
        - message
  responses:
    InvalidRequest:
      description: The request body failed validation.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                enum:
                  - invalid_request
              details:
                type: object
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                enum:
                  - unauthorized
              message:
                type: string
    PaymentRequired:
      description: No active subscription or usage allowance remaining.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                enum:
                  - payment_required
              message:
                type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your API key as a Bearer token: `Authorization: Bearer <api-key>`.'

````