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

# Start a scrape

> Starts a job that reads 1 to 3 URLs and returns its `jobId` straight away. Poll [Get a scrape](/api-reference/scraping/scrape-status) until `status` is `completed` or `failed`.

All the URLs in one request go into one result. Without a `prompt` you get each page as Markdown, and with a `prompt` or `schema` you get one answer drawn from all of them. To get a separate result for each URL, or to scrape more than 3, use [Batch scrape](/api-reference/scraping/batch-scrape).

If you send the same URLs again within 5 seconds, you get the first job's `jobId` back with `deduplicated: true` instead of a second job.

**Credits:** 1 per URL, plus AI credits for the tokens used when you send a `prompt` or `schema` (often 1 or 2 for a page), plus 5 per CAPTCHA solved. A URL that can't be read costs nothing. See [How credits work](/billing/how-credits-work).

**Rate limits:** 60 requests a minute, and up to 10 unfinished scrapes at a time. Batch URLs count toward the 10.




## OpenAPI

````yaml POST /scrape
openapi: 3.1.0
info:
  title: Spidra API
  version: 1.0.0
  description: >-
    Public API endpoints for web scraping via Spidra. Authenticate with
    `Authorization: Bearer YOUR_API_KEY`.
servers:
  - url: https://api.spidra.io/api
security:
  - BearerAuth: []
  - ApiKeyAuth: []
paths:
  /scrape:
    post:
      tags:
        - Scraping
      summary: Start a scrape
      description: >
        Starts a job that reads 1 to 3 URLs and returns its `jobId` straight
        away. Poll [Get a scrape](/api-reference/scraping/scrape-status) until
        `status` is `completed` or `failed`.


        All the URLs in one request go into one result. Without a `prompt` you
        get each page as Markdown, and with a `prompt` or `schema` you get one
        answer drawn from all of them. To get a separate result for each URL, or
        to scrape more than 3, use [Batch
        scrape](/api-reference/scraping/batch-scrape).


        If you send the same URLs again within 5 seconds, you get the first
        job's `jobId` back with `deduplicated: true` instead of a second job.


        **Credits:** 1 per URL, plus AI credits for the tokens used when you
        send a `prompt` or `schema` (often 1 or 2 for a page), plus 5 per
        CAPTCHA solved. A URL that can't be read costs nothing. See [How credits
        work](/billing/how-credits-work).


        **Rate limits:** 60 requests a minute, and up to 10 unfinished scrapes
        at a time. Batch URLs count toward the 10.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - urls
              properties:
                urls:
                  type: array
                  minItems: 1
                  maxItems: 3
                  items:
                    $ref: '#/components/schemas/ScrapeUrl'
                  description: >-
                    1 to 3 pages to scrape, each as an object such as `{ "url":
                    "https://example.com" }`. Plain strings aren't accepted
                    here.
                prompt:
                  type: string
                  description: >-
                    What you want from the pages, in plain English, such as
                    `"Return the title and price of every book"`. Without a
                    `schema`, the AI picks the shape of the answer.
                schema:
                  type: object
                  description: >-
                    A [JSON Schema](/options/structured-output) for the answer.
                    You get exactly these fields and types, with `null` for
                    anything the page doesn't show. The root must be `"type":
                    "object"`, at most 5 levels deep and 10 KB. Sending a schema
                    sets `output` to `"json"`.
                output:
                  type: string
                  enum:
                    - markdown
                    - json
                  default: markdown
                  description: >-
                    `markdown` returns the page as Markdown, or the AI's answer
                    as text when you send a `prompt`. `json` returns structured
                    data: on [popular sites](/sites/overview) with no prompt,
                    the page's data; elsewhere, data the AI extracts. Lowercase
                    only.
                scrapeMode:
                  type: string
                  enum:
                    - default
                    - fast
                  default: default
                  description: >-
                    `default` opens every page in a real browser. `fast` fetches
                    the page directly and opens a browser only when the page
                    needs one, which is quicker for static pages. `fast` doesn't
                    run `actions` or take screenshots. `crawlerMode` is accepted
                    as an older name for this field.
                useProxy:
                  type: boolean
                  default: false
                  description: >-
                    Turns on [Stealth Mode](/options/proxies-and-captchas),
                    which sends the request through residential proxies. Billed
                    by bandwidth, not credits.
                proxyCountry:
                  type: string
                  description: >-
                    With `useProxy`, the country to browse from, as a two-letter
                    code such as `us`, `gb` or `de`, or `global`, `eu` or
                    `asia`. See the [country
                    list](/options/proxies-and-captchas).
                  example: gb
                cookies:
                  type: string
                  description: >-
                    Cookies from your own signed-in browser session, to read
                    pages that need an account. Either `name=value;
                    name2=value2` or rows pasted from your browser's DevTools.
                    Never stored. See [Logged-in
                    pages](/options/logged-in-pages).
                screenshot:
                  type: boolean
                  default: false
                  description: Takes a screenshot of the visible part of each page.
                fullPageScreenshot:
                  type: boolean
                  default: false
                  description: >-
                    Takes a screenshot of the whole page, top to bottom. You
                    don't need to set `screenshot` as well.
                extractContentOnly:
                  type: boolean
                  default: false
                  description: >-
                    Removes headers, footers, menus and other page furniture
                    from the Markdown, leaving the main content.
            examples:
              markdown:
                summary: Page as Markdown
                value:
                  urls:
                    - url: https://books.toscrape.com
              prompt:
                summary: Extract with a prompt
                value:
                  urls:
                    - url: https://books.toscrape.com
                  prompt: Return the title and price of every book on the page
                  output: json
              schema:
                summary: Extract with a JSON Schema
                value:
                  urls:
                    - url: >-
                        https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html
                  prompt: Extract the book details
                  schema:
                    type: object
                    required:
                      - title
                      - price
                    properties:
                      title:
                        type: string
                      price:
                        type: number
                      currency:
                        type:
                          - string
                          - 'null'
                      in_stock:
                        type:
                          - boolean
                          - 'null'
                      rating:
                        type:
                          - string
                          - 'null'
              actions:
                summary: Log in with browser actions, then extract
                value:
                  urls:
                    - url: https://quotes.toscrape.com/login
                      actions:
                        - type: type
                          selector: '#username'
                          value: demo
                        - type: type
                          selector: '#password'
                          value: demo
                        - type: click
                          selector: input[type='submit']
                        - type: waitFor
                          selector: a[href='/logout']
                  prompt: List the first 3 quotes with their authors
                  output: json
              popular_site:
                summary: Product data from Amazon
                value:
                  urls:
                    - url: https://www.amazon.com/dp/B0CG1LGWR6
                  output: json
              stealth:
                summary: Stealth Mode from the UK
                value:
                  urls:
                    - url: https://books.toscrape.com
                  useProxy: true
                  proxyCountry: gb
      responses:
        '202':
          description: The job was queued. Poll `GET /scrape/{jobId}` for the result.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - queued
                  jobId:
                    type: string
                    format: uuid
                    description: The job's ID. Use it with `GET /scrape/{jobId}`.
                  message:
                    type: string
                    description: Where to poll for the result.
                  deduplicated:
                    type: boolean
                    description: >-
                      `true` when the same URLs were sent in the last 5 seconds
                      and this is that job's ID.
                  schema_warnings:
                    type: array
                    items:
                      type: string
                    description: >-
                      Only when your `schema` uses keywords that are ignored,
                      such as `anyOf`. The job still runs.
              examples:
                queued:
                  summary: Queued
                  value:
                    status: queued
                    jobId: 1027909f-f231-495b-9f9f-c5e0043c51b1
                    message: >-
                      Scrape job has been queued. Poll
                      /api/scrape/1027909f-f231-495b-9f9f-c5e0043c51b1 to get
                      the result.
                schema_warning:
                  summary: Queued, with a schema keyword ignored
                  value:
                    status: queued
                    jobId: 536b5dd6-84e7-4287-b514-5c7250750695
                    message: >-
                      Scrape job has been queued. Poll
                      /api/scrape/536b5dd6-84e7-4287-b514-5c7250750695 to get
                      the result.
                    schema_warnings:
                      - >-
                        "anyOf" at schema.properties.isbn is not supported and
                        will be ignored
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: >-
            The account's payment is overdue. Update the payment method in the
            dashboard to continue.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  Your payment is overdue. Please update your payment method to
                  continue scraping.
                code: PAYMENT_OVERDUE
        '403':
          $ref: '#/components/responses/CreditLimit'
        '422':
          description: >-
            The request isn't valid. `errors` lists every problem, naming the
            URL and action where it applies.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                too_many_urls:
                  summary: More than 3 URLs
                  value:
                    status: error
                    message: Maximum 3 URLs per request. You provided 4.
                    errors:
                      - Maximum 3 URLs per request. You provided 4.
                bad_output:
                  summary: Unknown output value
                  value:
                    status: error
                    message: >-
                      Request validation failed. Fix the errors below and try
                      again.
                    errors:
                      - '"output" must be "markdown" or "json". You sent "html".'
                private_url:
                  summary: A private address
                  value:
                    status: error
                    message: >-
                      Request validation failed. Fix the errors below and try
                      again.
                    errors:
                      - >-
                        "http://localhost:8080" points to a private or internal
                        address, which is not allowed.
        '429':
          description: >-
            Too many requests. Either more than 60 scrapes in a minute, or 10
            scrapes already unfinished. Wait, then send the request again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                rate_limit:
                  summary: More than 60 a minute
                  value:
                    status: error
                    message: >-
                      Too many job submissions. Please slow down and try again
                      shortly.
                pending:
                  summary: 10 scrapes still running
                  value:
                    status: error
                    message: >-
                      You have too many pending scrape jobs. Please wait for
                      some to complete before submitting more.
                    code: TOO_MANY_PENDING_JOBS
        '503':
          description: >-
            Spidra is at capacity. Wait `retry_after` seconds, then send the
            request again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  The scraping service is currently at capacity. Please retry in
                  a few minutes.
                code: SERVICE_BUSY
                retry_after: 60
components:
  schemas:
    ScrapeUrl:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: >-
            The page to scrape, starting with `http://` or `https://`. Links to
            PDF, Word, Excel and PowerPoint files work too. Tracking parameters
            such as `utm_source`, `gclid` and `fbclid` are removed before the
            page is read.
          example: https://books.toscrape.com
        actions:
          type: array
          maxItems: 50
          items:
            $ref: '#/components/schemas/ScrapeAction'
          description: >-
            Browser steps to run in order before the page is read, such as
            clicking a button or scrolling to the end. Can't be combined with
            `instruction`. See [Browser actions](/options/browser-actions).
        instruction:
          type: string
          maxLength: 2000
          description: >-
            One task in plain English, such as `"Click the Next page link"`,
            carried out before the page is read. Can't be combined with
            `actions`. If it can't be carried out, the job fails and you aren't
            charged.
        useProxy:
          type: boolean
          description: >-
            Turns Stealth Mode on or off for this URL only, overriding the
            request's `useProxy`.
        deliveryZip:
          type: string
          description: >-
            For Amazon and Walmart product pages, the delivery postcode to check
            prices and availability for, such as `"90210"`. If it can't be
            applied, that `data[]` entry has a `warnings` entry saying so.
          example: '90210'
    ErrorResponse:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          description: What went wrong, as a sentence you can show to a person.
        code:
          type: string
          description: >-
            A stable code for the error, when there is one, such as
            `JOB_NOT_FOUND` or `SERVICE_BUSY`. Branch on this rather than on
            `message`.
        errors:
          description: >-
            On validation errors (`422`), every problem with the request.
            Scrape, batch, crawl, map and search return a list of sentences.
            Templates, presets and monitors return `{ field, message }` objects.
          oneOf:
            - type: array
              items:
                type: string
            - type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                  message:
                    type: string
        retry_after:
          type: integer
          description: >-
            On `503 SERVICE_BUSY`, how many seconds to wait before sending the
            request again.
    ScrapeAction:
      type: object
      description: >-
        One browser step. Steps run in order. If a step fails, the job fails
        (and is free) unless the step has optional: true. The type name is
        case-insensitive and a few aliases are accepted (fill for type,
        waitForSelector for waitFor, keypress for press, infiniteScroll for
        scrollUntilEnd, executeJavascript for evaluate). Older field names still
        work: value as the element of click, check, uncheck and hover, text for
        the text to type, duration, timeout or value for the milliseconds of
        wait, and value for the position of scroll. At most 50 actions per URL,
        and the wait durations, waitFor timeouts and scrollUntilEnd pauses can
        add up to 60 seconds. forEach may appear once, as the last action.
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - click
            - type
            - check
            - uncheck
            - hover
            - select
            - press
            - wait
            - waitFor
            - scroll
            - scrollUntilEnd
            - evaluate
            - screenshot
            - forEach
          description: What the step does. Case-insensitive.
        optional:
          type: boolean
          default: false
          description: >-
            If true and the step fails, it is skipped and reported as skipped
            (with a warning) instead of failing the job.
        selector:
          type: string
          maxLength: 500
          description: >-
            The element: a CSS selector, an XPath (starting with //), or a
            plain-English description such as 'the Sign in button', which the AI
            finds on the page. Used by click, check, uncheck, hover, select,
            waitFor, type and press. For type it is optional (the first visible
            text field), and for press it is optional (the key goes to the
            page).
        value:
          type:
            - string
            - number
            - array
          items:
            type: string
          description: >-
            type: the text to type (up to 5,000 characters, never sent to the
            AI). select: the option to choose, by its label or value, or a list
            of them. Older requests also use value as the target of click,
            check, uncheck and hover, as the milliseconds of wait, as the
            position of scroll and as the key of press.
        text:
          type: string
          description: 'type: another name for value.'
        key:
          type: string
          description: >-
            press: the key to press, such as 'Enter', 'Tab', 'Escape',
            'ArrowDown' or 'Control+A'.
        timeout:
          type: number
          minimum: 100
          maximum: 30000
          default: 10000
          description: >-
            Milliseconds an element step waits for its element. For waitFor, how
            long to wait for the state.
        duration:
          type: number
          minimum: 1
          maximum: 30000
          description: 'wait: milliseconds to pause.'
        state:
          type: string
          enum:
            - visible
            - attached
            - hidden
            - detached
          default: visible
          description: 'waitFor: the state to wait for.'
        to:
          type:
            - string
            - number
          description: >-
            scroll: a percentage of the page height (0 to 100, as 80 or '80%'),
            'top', 'bottom', or an element (selector or description) to scroll
            into view.
        pixels:
          type: number
          minimum: -100000
          maximum: 100000
          description: >-
            scroll: scroll by this many pixels from the current position.
            Negative scrolls up. Use it instead of to.
        maxScrolls:
          type: integer
          minimum: 1
          maximum: 30
          default: 10
          description: 'scrollUntilEnd: the most rounds to scroll (or click clickSelector).'
        pause:
          type: number
          minimum: 200
          maximum: 5000
          default: 1500
          description: >-
            scrollUntilEnd: milliseconds to wait after each round for new
            content.
        clickSelector:
          type: string
          maxLength: 500
          description: >-
            scrollUntilEnd: a 'Load more' button (selector or description) to
            click each round while it is visible, instead of scrolling.
        script:
          type: string
          maxLength: 10000
          description: >-
            evaluate: JavaScript to run in the page. An expression is returned
            as is; statements need return. The value comes back in
            actionResults[].result, up to 10,000 characters.
        fullPage:
          type: boolean
          default: false
          description: >-
            screenshot: capture the whole scrollable page instead of the visible
            part. The link comes back in actionResults[].screenshotUrl.
        observe:
          type: string
          maxLength: 500
          description: >-
            forEach: the items to go through, in plain English, such as 'each
            book title link in the product grid'. Required for forEach.
        mode:
          type: string
          enum:
            - click
            - inline
            - navigate
          default: click
          description: >-
            forEach: inline reads each item where it is; navigate opens the page
            each item links to; click clicks each item and reads what opens (if
            the click follows a link, Spidra goes back afterwards).
        captureSelector:
          type: string
          maxLength: 500
          description: >-
            forEach: the part of the page to read for each item (selector or
            description). In inline mode a CSS selector also lists the items
            directly. If it isn't found for an item, that item fails.
        maxItems:
          type: integer
          minimum: 1
          maximum: 50
          default: 50
          description: 'forEach: the most items to process, across all results pages.'
        waitAfterClick:
          type: number
          minimum: 0
          maximum: 10000
          default: 2500
          description: >-
            forEach: milliseconds to wait after clicking or opening an item
            before reading it.
        itemPrompt:
          type: string
          maxLength: 2000
          description: >-
            forEach: an AI prompt run on each item's content. Billed by tokens
            with the job's AI.
        actions:
          type: array
          maxItems: 10
          items:
            $ref: '#/components/schemas/ScrapeAction'
          description: >-
            forEach: up to 10 steps to run on each item after it is clicked or
            opened (click and navigate modes). No forEach inside. A failed step
            fails that item.
        pagination:
          type: object
          description: 'forEach: go on to the next results page after the items on this one.'
          required:
            - nextSelector
          properties:
            nextSelector:
              type: string
              description: The next-page link or button (selector or description).
            maxPages:
              type: integer
              minimum: 1
              maximum: 10
              default: 5
              description: The most results pages to go through, counting the first one.
  responses:
    Unauthorized:
      description: The API key is missing, wrong, or turned off.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missing:
              summary: No key sent
              value:
                status: error
                message: Missing authentication
            invalid:
              summary: Wrong or turned-off key
              value:
                status: error
                message: Invalid token or API key
    CreditLimit:
      description: >-
        Your account doesn't have enough credits left to start this job. Top up
        or upgrade, then send the request again.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: error
            message: You have exceeded your monthly credit limit.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

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