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

# Crawl

> Start a crawl: follow links from a URL and read every page. The crawl runs in the background; check it with `GET /crawl/{id}`. Credits for `limit` pages are reserved when it starts, and what wasn't used is given back when it ends.

Start a crawl. It runs in the background: keep the `id` and check it with [Get Crawl Status](/api-reference/endpoint/crawl-get.md). For a guide with examples, see [Crawl](/features/crawl.md).


## OpenAPI

````yaml /api-reference/openapi.json POST /crawl
openapi: 3.1.0
info:
  title: ScreenshotRender API
  version: v1
  description: >-
    Screenshot any website, search the web, and turn any page or document into
    clean Markdown or structured data.
servers:
  - url: https://www.screenshotrender.com/api/v1
security:
  - bearerAuth: []
paths:
  /crawl:
    post:
      tags:
        - Crawl
      summary: Crawl
      description: >-
        Start a crawl: follow links from a URL and read every page. The crawl
        runs in the background; check it with `GET /crawl/{id}`. Credits for
        `limit` pages are reserved when it starts, and what wasn't used is given
        back when it ends.
      operationId: crawl
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CrawlRequest'
      responses:
        '200':
          description: The crawl started.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrawlStarted'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/InvalidApiKey'
        '402':
          $ref: '#/components/responses/InsufficientCredits'
        '429':
          $ref: '#/components/responses/Busy'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -s -X POST "https://www.screenshotrender.com/api/v1/crawl" \
              -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "url": "https://docs.python.org/3/tutorial/",
                "limit": 3,
                "scrapeOptions": { "formats": ["markdown"] }
              }'
        - lang: javascript
          label: Node
          source: >-
            import ScreenshotRender from "screenshotrender";


            const screenshotrender = new ScreenshotRender({ apiKey:
            "sr-YOUR-API-KEY" });


            const job = await
            screenshotrender.startCrawl("https://docs.python.org/3/tutorial/", {
            limit: 3 });

            console.log(job.id);
        - lang: python
          label: Python
          source: >-
            from screenshotrender import ScreenshotRender


            screenshotrender = ScreenshotRender(api_key="sr-YOUR-API-KEY")


            job =
            screenshotrender.start_crawl("https://docs.python.org/3/tutorial/",
            limit=3)

            print(job.id)
components:
  schemas:
    CrawlRequest:
      type: object
      properties:
        url:
          type: string
          example: https://docs.python.org/3/tutorial/
        limit:
          type: integer
          description: Most pages to read.
          default: 10
          maximum: 10000
        includePaths:
          type: array
          items:
            type: string
          description: Only follow URL paths that match these regular expressions.
        maxDiscoveryDepth:
          type: integer
          description: How many links deep to go from the start URL.
        scrapeOptions:
          $ref: '#/components/schemas/PageOptions'
          description: Options for every page. Defaults to Markdown.
      required:
        - url
    CrawlStarted:
      type: object
      properties:
        success:
          type: boolean
          example: true
        id:
          type: string
          description: The crawl's id.
        url:
          type: string
          description: 'Where to check the crawl: `GET /crawl/{id}`.'
        creditsReserved:
          type: integer
          description: Credits held for the crawl until it ends.
    PageOptions:
      type: object
      properties:
        formats:
          type: array
          description: The formats to return. Defaults to Markdown.
          items:
            $ref: '#/components/schemas/Format'
        onlyMainContent:
          type: boolean
          description: >-
            Leave out the parts of the page around its main content. On by
            default.
          default: true
        includeTags:
          type: array
          items:
            type: string
          description: >-
            Only keep these elements: tag names, classes or ids, like `h1`,
            `.article` or `#main`.
        excludeTags:
          type: array
          items:
            type: string
          description: 'Drop these elements: tag names, classes or ids.'
        waitFor:
          type: integer
          description: Extra time to wait after the page loads, in milliseconds.
        timeout:
          type: integer
          description: How long the page may take, in milliseconds.
        mobile:
          type: boolean
          description: Load the page as a phone would.
        location:
          type: object
          description: Load the page from this country.
          properties:
            country:
              type: string
              description: An ISO country code, like `US` or `DE`.
            languages:
              type: array
              items:
                type: string
              description: Preferred languages, like `de-DE`.
        maxAge:
          type: integer
          description: >-
            Accept a cached copy of the page up to this old, in milliseconds.
            `0` always loads a fresh copy.
        headers:
          type: object
          additionalProperties:
            type: string
          description: Extra HTTP headers to send to the page.
        blockAds:
          type: boolean
          description: Hide ads and cookie banners before the page is read.
        actions:
          type: array
          description: >-
            Browser steps to run before the page is read, such as `wait`,
            `click` and `screenshot`.
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - wait
                  - click
                  - screenshot
              milliseconds:
                type: integer
                description: For `wait`.
              selector:
                type: string
                description: 'For `click`: a CSS selector.'
            required:
              - type
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: What went wrong, in words.
        code:
          type: string
          description: A stable code to branch on, such as `invalid_request`.
        field:
          type: string
          description: The request field the error is about, when there is one.
      required:
        - success
        - error
        - code
    Format:
      description: >-
        An output format: a name, or an object for the formats that take
        settings.
      oneOf:
        - title: Name
          type: string
          enum:
            - markdown
            - summary
            - html
            - rawHtml
            - links
            - images
            - screenshot
            - branding
        - title: Screenshot
          type: object
          properties:
            type:
              type: string
              const: screenshot
            fullPage:
              type: boolean
              description: Capture the whole page, not just the browser window.
              default: false
            viewport:
              type: object
              description: The browser window's size in pixels.
              properties:
                width:
                  type: integer
                height:
                  type: integer
              required:
                - width
                - height
          required:
            - type
        - title: JSON
          type: object
          description: Structured data extracted with AI. +4 credits per page.
          properties:
            type:
              type: string
              const: json
            prompt:
              type: string
              description: What to extract, in plain words.
            schema:
              type: object
              description: A JSON Schema the result must follow.
          required:
            - type
        - title: Question
          type: object
          description: >-
            A short answer to a question about the page, in `answer`. +4 credits
            per page.
          properties:
            type:
              type: string
              const: question
            question:
              type: string
          required:
            - type
            - question
        - title: Highlights
          type: object
          description: The passages of the page that match a query. +4 credits per page.
          properties:
            type:
              type: string
              const: highlights
            query:
              type: string
          required:
            - type
            - query
  responses:
    InvalidRequest:
      description: Something in the request isn't valid. `field` names it, when known.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: url is required.
            code: invalid_request
            field: url
    InvalidApiKey:
      description: The API key doesn't match an account.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: Invalid API key.
            code: invalid_api_key
    InsufficientCredits:
      description: The balance can't cover the request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: >-
              This crawl can use up to 10000 credits (10000 pages at 1 credit
              each) and your balance is 773. Lower the page limit or add
              credits.
            code: insufficient_credits
    Busy:
      description: >-
        Too many requests right now. Wait for `Retry-After` seconds and send it
        again.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Your API key from the dashboard. It starts with `sr-`.

````