> ## 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.

# Parse

> Turns one document into Markdown, and into JSON when you send a `prompt` or `schema`. Send exactly one source: a link in `url`, an upload in `file` (multipart), or the `fileId` of a document you've already sent. PDF, Word, Excel, PowerPoint, OpenDocument, RTF, EPUB, CSV and HTML files work. See [List formats](/api-reference/parse/parse-formats) and the [Parse guide](/parse).

The request waits up to 20 seconds. If the document is done by then, you get the result with `200`. If not, or if you send `wait: false`, you get `202` with a `jobId` to poll at [Get a parse job](/api-reference/parse/parse-status). A document that can't be parsed answers `200` with `status: "failed"` and the reason in `error`.

Uploads and links can be up to 50 MB. For bigger files, up to 500 MB, use [Prepare a large upload](/api-reference/parse/parse-uploads). One request parses up to 2,000 pages; use `pages` or `maxPages` for longer PDFs. Every document is stored for 24 hours under its `fileId`, so you can parse it again with other options, then deleted.

**Credits:** 1 per page parsed, plus AI credits for the tokens used when you send a `prompt` or `schema`. Formats without pages count one page per 3,000 characters of text. Pages that can't be read and failed documents cost nothing. `dryRun: true` tells you the cost for free. See [How credits work](/billing/how-credits-work).

**Rate limits:** 60 parse requests a minute, shared with `POST /parse/batch` and `POST /parse/uploads`.




## OpenAPI

````yaml POST /parse
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` or `x-api-key: YOUR_API_KEY`; both work
    on every endpoint.
servers:
  - url: https://api.spidra.io/api
security:
  - BearerAuth: []
  - ApiKeyAuth: []
paths:
  /parse:
    post:
      tags:
        - Parse
      summary: Parse
      description: >
        Turns one document into Markdown, and into JSON when you send a `prompt`
        or `schema`. Send exactly one source: a link in `url`, an upload in
        `file` (multipart), or the `fileId` of a document you've already sent.
        PDF, Word, Excel, PowerPoint, OpenDocument, RTF, EPUB, CSV and HTML
        files work. See [List formats](/api-reference/parse/parse-formats) and
        the [Parse guide](/parse).


        The request waits up to 20 seconds. If the document is done by then, you
        get the result with `200`. If not, or if you send `wait: false`, you get
        `202` with a `jobId` to poll at [Get a parse
        job](/api-reference/parse/parse-status). A document that can't be parsed
        answers `200` with `status: "failed"` and the reason in `error`.


        Uploads and links can be up to 50 MB. For bigger files, up to 500 MB,
        use [Prepare a large upload](/api-reference/parse/parse-uploads). One
        request parses up to 2,000 pages; use `pages` or `maxPages` for longer
        PDFs. Every document is stored for 24 hours under its `fileId`, so you
        can parse it again with other options, then deleted.


        **Credits:** 1 per page parsed, plus AI credits for the tokens used when
        you send a `prompt` or `schema`. Formats without pages count one page
        per 3,000 characters of text. Pages that can't be read and failed
        documents cost nothing. `dryRun: true` tells you the cost for free. See
        [How credits work](/billing/how-credits-work).


        **Rate limits:** 60 parse requests a minute, shared with `POST
        /parse/batch` and `POST /parse/uploads`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  properties:
                    url:
                      type: string
                      format: uri
                      description: >-
                        A link to the document, starting with `http://` or
                        `https://`. Links to private or internal addresses
                        aren't allowed. Send this, `fileId` or a `file` upload,
                        not more than one.
                      example: https://arxiv.org/pdf/1706.03762
                    fileId:
                      type: string
                      format: uuid
                      description: >-
                        The `fileId` of a document you parsed, estimated or
                        uploaded in the last 24 hours. It isn't downloaded or
                        uploaded again.
                      example: 0b007010-b3f6-4398-a3ba-e5c2518839c8
                - $ref: '#/components/schemas/ParseOptions'
            examples:
              link:
                summary: Parse a link
                value:
                  url: https://arxiv.org/pdf/1706.03762
                  maxPages: 3
              extract:
                summary: Extract fields with a schema
                value:
                  fileId: 614b6cf9-baab-440a-a1d8-422ce676bb5d
                  pages: '1'
                  prompt: The paper's title and the authors' names
                  schema:
                    type: object
                    properties:
                      title:
                        type: string
                      authors:
                        type: array
                        items:
                          type: string
              estimate:
                summary: Estimate the cost first
                value:
                  url: https://arxiv.org/pdf/1706.03762
                  pages: 2-3
                  dryRun: true
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: The document, up to 50 MB.
                options:
                  type: string
                  description: >-
                    All the options as one JSON string, such as
                    `{"pages":"1-5"}`. You can send each option as its own form
                    field instead.
                mode:
                  type: string
                  enum:
                    - auto
                    - fast
                    - ocr
                  default: auto
                  description: How pages are read. See `mode` in the JSON body.
                pages:
                  type: string
                  description: PDF pages to parse, such as `1-5,9`.
                maxPages:
                  type: integer
                  description: Parse at most this many pages.
                includePages:
                  type: boolean
                  description: Adds `pages` to the result.
                pageMarkers:
                  type: boolean
                  description: Puts a `<!-- page N -->` line before each page.
                prompt:
                  type: string
                  description: What to extract, in plain English.
                schema:
                  type: string
                  description: A JSON Schema for the extracted data, as a JSON string.
                dryRun:
                  type: boolean
                  description: Returns the cost without parsing.
                wait:
                  type: boolean
                  description: Set to `false` to get a job to poll straight away.
            examples:
              upload:
                summary: Upload a file
                value:
                  file: 1706.03762.pdf
                  options: '{"pages":"1-3"}'
      responses:
        '200':
          description: >-
            The document finished within 20 seconds (`status` is `completed` or
            `failed`), or `dryRun` was `true` and this is the estimate.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ParseJob'
                  - $ref: '#/components/schemas/ParseEstimate'
              examples:
                completed:
                  summary: Finished
                  value:
                    jobId: c5a8d5a2-b10e-44f5-8c9e-dbbd334d19d1
                    status: completed
                    fileName: '1706.03762'
                    sourceUrl: https://arxiv.org/pdf/1706.03762
                    fileId: 29273629-c557-4ac8-9e36-14fb96b1018d
                    format: PDF
                    totalPages: 15
                    pagesParsed: 3
                    creditsUsed: 3
                    markdown: >-
                      ### Provided proper attribution is provided, Google hereby
                      grants permission to


                      reproduce the tables and figures in this paper solely for
                      use in journalistic or scholarly works.


                      ## Attention Is All You Need


                      ...
                    warnings: []
                    metadata:
                      fileName: '1706.03762'
                      sourceUrl: https://arxiv.org/pdf/1706.03762
                      format: pdf
                      totalPages: 15
                      pagesParsed: 3
                      ocrPages: 0
                    durationMs: 1005
                extracted:
                  summary: Finished, with extraction
                  value:
                    jobId: 58eaa06c-d540-4d28-aadf-3c2722b20ab6
                    status: completed
                    fileName: '1706.03762'
                    sourceUrl: https://arxiv.org/pdf/1706.03762
                    fileId: 614b6cf9-baab-440a-a1d8-422ce676bb5d
                    format: PDF
                    totalPages: 15
                    pagesParsed: 1
                    creditsUsed: 2
                    markdown: >-
                      ### Provided proper attribution is provided, Google hereby
                      grants permission to


                      ...
                    json:
                      title: Attention Is All You Need
                      authors:
                        - Ashish Vaswani
                        - Noam Shazeer
                        - Niki Parmar
                        - ...
                    warnings: []
                    metadata:
                      fileName: '1706.03762'
                      sourceUrl: https://arxiv.org/pdf/1706.03762
                      format: pdf
                      totalPages: 15
                      pagesParsed: 1
                      ocrPages: 0
                    durationMs: 1289
                estimate:
                  summary: Estimate (dryRun)
                  value:
                    status: estimate
                    fileId: 614b6cf9-baab-440a-a1d8-422ce676bb5d
                    fileName: '1706.03762'
                    format: PDF
                    totalPages: 15
                    pagesToParse: 2
                    credits: 2
        '202':
          description: >-
            The document is still being parsed after 20 seconds, or you sent
            `wait: false`. Poll `GET /parse/{jobId}` for the result.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ParseJob'
                  - type: object
                    properties:
                      message:
                        type: string
                        description: How many pages are being parsed and where to poll.
              example:
                jobId: 65245c0c-3f99-4805-bfe1-6a1c91b45478
                status: queued
                fileName: '1706.03762'
                sourceUrl: https://arxiv.org/pdf/1706.03762
                fileId: df4dd604-5f72-4f54-9873-5fd1b90b66cd
                format: PDF
                totalPages: 15
                pagesParsed: null
                creditsUsed: 0
                message: >-
                  Parsing 1 page. Poll
                  /api/parse/65245c0c-3f99-4805-bfe1-6a1c91b45478 for the
                  result.
        '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.
                code: PAYMENT_OVERDUE
        '403':
          description: >-
            The account doesn't have enough credits for the pages to parse.
            `creditsNeeded` says how many it would take. Parse fewer pages, or
            top up and send the request again.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ErrorResponse'
                  - type: object
                    properties:
                      creditsNeeded:
                        type: integer
                        description: The page credits this parse needs.
              example:
                status: error
                message: You don't have enough credits to parse this document.
                creditsNeeded: 15
        '404':
          description: >-
            The `fileId` doesn't exist on your account, or it's more than 24
            hours old or was deleted. Send the document again as a `url` or
            `file`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  No file with that fileId. Files can be parsed again for 24
                  hours after upload.
        '409':
          description: >-
            The `fileId` comes from a prepared upload whose bytes haven't been
            sent yet, or the file was replaced after it was counted. `PUT` the
            file to the `uploadUrl` first, or parse it again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_uploaded:
                  summary: Bytes not uploaded yet
                  value:
                    status: error
                    message: >-
                      The file hasn't been uploaded yet. PUT it to the uploadUrl
                      first.
                changed:
                  summary: File replaced after it was checked
                  value:
                    status: error
                    message: The file changed after it was checked. Parse it again.
        '413':
          description: >-
            The upload or the linked document is over 50 MB. Use [Prepare a
            large upload](/api-reference/parse/parse-uploads) for files up to
            500 MB.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                upload:
                  summary: Upload over 50 MB
                  value:
                    status: error
                    message: >-
                      The file is larger than 50 MB. Use POST /api/parse/uploads
                      for files up to 500 MB.
                link:
                  summary: Linked document over 50 MB
                  value:
                    status: error
                    message: The document is larger than 50 MB.
        '415':
          description: >-
            The file isn't a supported document type. The format is worked out
            from the file's content first and its name second.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  This file type isn't supported. Supported: pdf, docx, doc,
                  xlsx, pptx, ppt, odt, ods, odp, rtf, epub, csv, html, htm.
        '422':
          description: >
            The request can't be parsed as sent. `message` says what to fix.
            This covers:


            - no source, or more than one;

            - an option with a wrong value (`mode`, `pages`, `maxPages`,
            `prompt`, `schema`, or `options` that isn't valid JSON);

            - page ranges that don't exist in the PDF, or more than 2,000 pages
            to parse;

            - a link that's private, unreachable, empty, or answers with an HTTP
            error;

            - a document that can't be opened at all. These also carry a `code`:
            `encrypted`, `malformed`, `empty` or `unsupported`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                no_source:
                  summary: No source, or more than one
                  value:
                    status: error
                    message: Send exactly one of "file", "url" or "fileId".
                bad_mode:
                  summary: Unknown mode
                  value:
                    status: error
                    message: '"mode" must be "auto", "fast" or "ocr".'
                no_pages:
                  summary: Requested pages don't exist
                  value:
                    status: error
                    message: This PDF has 15 pages; none of the requested pages exist.
                too_many_pages:
                  summary: More than 2,000 pages
                  value:
                    status: error
                    message: >-
                      This document has 2,400 pages. Parse up to 2,000 at a time
                      with "pages" or "maxPages".
                link_error:
                  summary: The link answered with an error
                  value:
                    status: error
                    message: The link returned HTTP 404.
                private_url:
                  summary: A private address
                  value:
                    status: error
                    message: Private and internal URLs are not allowed.
        '429':
          description: >-
            More than 60 parse requests in a minute. Wait, then send the request
            again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: >-
                  Too many parse requests. Please slow down and try again
                  shortly.
components:
  schemas:
    ParseOptions:
      type: object
      description: >-
        How to parse a document. The same options apply to `POST /parse` and to
        every document in `POST /parse/batch`.
      properties:
        mode:
          type: string
          enum:
            - auto
            - fast
            - ocr
          default: auto
          description: >
            How pages are read.


            - `auto`: reads each page's text, and uses AI only on pages that are
            scans or images.

            - `fast`: reads text only. Scanned pages come back empty with an
            `error` and aren't charged.

            - `ocr`: reads every page with AI. Slower, and best for scans and
            handwriting.
        pages:
          type: string
          maxLength: 500
          description: >-
            PDF pages to parse, as pages and ranges separated by commas. `"10-"`
            means page 10 to the end. Pages past the end are skipped. Other
            formats ignore this and are parsed whole, with a warning.
          example: 1-5,9
        maxPages:
          type: integer
          minimum: 1
          description: >-
            Parse at most this many pages, counted from the start of `pages` (or
            of the document). PDFs only.
          example: 3
        includePages:
          type: boolean
          default: false
          description: >-
            Adds `pages` to the result, with each page's Markdown on its own.
            `perPage` is accepted as another name for this field. Only applies
            when the result comes back inline; when polling, use `?pages=true`
            instead.
        pageMarkers:
          type: boolean
          default: false
          description: Puts a `<!-- page N -->` line before each page in `markdown`.
        prompt:
          type: string
          maxLength: 5000
          description: >-
            What to extract from the document, in plain English, such as `"The
            paper's title and the authors' names"`. The answer is in `json`.
            Costs AI credits on top of the page credits.
        schema:
          type: object
          description: >-
            A JSON Schema for the extracted data. The answer is in `json` and
            follows this shape. Can be sent with or without a `prompt`. In a
            multipart request, send it as a JSON string.
        dryRun:
          type: boolean
          default: false
          description: >-
            Returns the page count and the credits the parse would cost, without
            parsing or charging anything. The document is still stored, so you
            can parse it next with the returned `fileId`.
        wait:
          type: boolean
          default: true
          description: >-
            Waits up to 20 seconds for the result and returns it inline. Set to
            `false` to get a job to poll straight away. `POST /parse` only; a
            batch never waits.
    ParseJob:
      type: object
      description: A parse job, with its result once it has finished.
      properties:
        jobId:
          type: string
          format: uuid
          description: The job's ID. Use it with `GET /parse/{jobId}`.
        status:
          type: string
          enum:
            - queued
            - running
            - completed
            - failed
          description: >
            - `queued`: waiting to start.

            - `running`: being parsed. `progress` says how far it has got.

            - `completed`: finished. The result is in `markdown`, and `json`
            when you asked for extraction.

            - `failed`: couldn't be parsed. `error` says why, and you aren't
            charged.
        fileName:
          type: string
          description: The document's file name, or the last part of the link it came from.
        sourceUrl:
          type:
            - string
            - 'null'
          description: >-
            The link the document was downloaded from, after redirects. `null`
            for uploads.
        fileId:
          type: string
          format: uuid
          description: >-
            The stored document's ID. Send it as `fileId` to parse the same
            document again for 24 hours without uploading or downloading it
            again.
        format:
          type:
            - string
            - 'null'
          description: >-
            The document's format, such as `PDF`, `Word`, `Excel` or
            `PowerPoint`.
        totalPages:
          type:
            - integer
            - 'null'
          description: >-
            How many pages the document has. For formats without pages, an
            estimate of one page per 3,000 characters of text.
        pagesParsed:
          type:
            - integer
            - 'null'
          description: How many pages were read and charged. `null` until the job finishes.
        creditsUsed:
          type: integer
          description: >-
            Credits charged for this job, including AI credits for extraction.
            `0` until the job has completed, and for a failed job.
        error:
          type: string
          description: >-
            Only when `status` is `failed`. Why the document couldn't be parsed,
            such as `"This PDF is password protected. Remove the password and
            try again."`
        progress:
          type: object
          description: >-
            Only while the job is `queued` or `running`, once it has started
            reading pages.
          properties:
            message:
              type: string
              description: What the job is doing, such as `"Reading page 3 of 12"`.
            done:
              type: integer
              description: Pages read so far.
            total:
              type: integer
              description: Pages to read in all.
        markdown:
          type: string
          description: >-
            Once completed. The whole document as Markdown, pages joined by
            blank lines.
        pages:
          type: array
          items:
            $ref: '#/components/schemas/ParsePage'
          description: >-
            Only when you asked for it (`includePages`, or `?pages=true` when
            polling). Each page on its own.
        json:
          description: Only when you sent a `prompt` or `schema`. The extracted data.
        warnings:
          type: array
          items:
            type: string
          description: >-
            Once completed. Anything worth knowing about the result, such as `"2
            of 15 pages couldn't be read and aren't charged."` or that page
            selection was ignored for a non-PDF document. Empty when there's
            nothing to report.
        metadata:
          type: object
          description: Once completed. Facts about the parsed document.
          properties:
            fileName:
              type:
                - string
                - 'null'
              description: The document's file name.
            sourceUrl:
              type:
                - string
                - 'null'
              description: The link it was downloaded from, or `null` for uploads.
            format:
              type: string
              description: The format as a lowercase extension, such as `pdf` or `docx`.
            totalPages:
              type: integer
              description: How many pages the document has.
            pagesParsed:
              type: integer
              description: How many pages were read and charged.
            ocrPages:
              type: integer
              description: How many of those pages were read with AI.
        durationMs:
          type:
            - integer
            - 'null'
          description: Once completed. How long parsing took, in milliseconds.
    ParseEstimate:
      type: object
      description: >-
        What a parse would cost, returned with `dryRun: true`. Nothing is parsed
        or charged.
      properties:
        status:
          type: string
          enum:
            - estimate
        fileId:
          type: string
          format: uuid
          description: >-
            The stored document's ID. Send it as `fileId` to parse the document
            without fetching it again.
        fileName:
          type: string
          description: The document's file name.
        format:
          type: string
          description: The document's format, such as `PDF` or `Word`.
        totalPages:
          type: integer
          description: How many pages the document has.
        pagesToParse:
          type: integer
          description: How many pages would be parsed, after `pages` and `maxPages`.
        credits:
          type: integer
          description: Page credits the parse would cost.
        creditsNote:
          type: string
          description: >-
            Only when you sent a `prompt` or `schema`. Says that AI credits for
            the extraction come on top.
    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.
    ParsePage:
      type: object
      description: One page of a parsed document.
      properties:
        pageNumber:
          type: integer
          description: >-
            The page number, starting at 1. A non-PDF document comes back as a
            single page 1.
        markdown:
          type: string
          description: The page as Markdown. Empty when the page couldn't be read.
        method:
          type: string
          enum:
            - text
            - ocr
          description: >-
            `text` when the page's text was read directly, `ocr` when it was
            read with AI.
        error:
          type: string
          description: >-
            Only when the page couldn't be read, such as `"This page is a scan
            or image. Use auto or OCR mode to read it."` Pages with an error
            aren't charged.
  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
  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.