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

# Extract

> **WebRouter is in closed beta.** It's available to selected accounts, and the API may still change. To get access, [talk to the Nimble team](https://nimbleway.com/contact-general/).

Read pages you already have URLs for, as markdown where the provider has it, unless `format` asks otherwise. Usually answers within seconds for a few URLs. It reads pages, it does not find them: pass URLs from `POST /v2/web-router/search`, from the user, or from a page you read. Several URLs can partly succeed: each one that could not be read is in `failures`, with why. Nimble picks the provider: your own keys first. `optimized_for` sets what Nimble favors when it picks the provider. Answers `{meta, result}`: the tool, and the extract's own answer.



## OpenAPI

````yaml /api-reference/web-router-openapi.json post /v2/web-router/extract
openapi: 3.1.0
info:
  title: WebRouter API
  version: 1.0.0
  description: >-
    Closed beta. One API to search, extract, research and browse the web, on
    Nimble or any provider your account may use. `route` picks the tool and
    provider for a query and runs it in one call. Search and extract answer
    within the call. Research and browse are jobs: start one, then poll it by
    `job_id` until `state` is `completed`, `failed` or `cancelled`. Authenticate
    with `Authorization: Bearer YOUR_API_KEY`.
servers:
  - url: https://sdk.nimbleway.com
security: []
paths:
  /v2/web-router/extract:
    post:
      tags:
        - WebRouter
      summary: Extract
      description: >-
        **WebRouter is in closed beta.** It's available to selected accounts,
        and the API may still change. To get access, [talk to the Nimble
        team](https://nimbleway.com/contact-general/).


        Read pages you already have URLs for, as markdown where the provider has
        it, unless `format` asks otherwise. Usually answers within seconds for a
        few URLs. It reads pages, it does not find them: pass URLs from `POST
        /v2/web-router/search`, from the user, or from a page you read. Several
        URLs can partly succeed: each one that could not be read is in
        `failures`, with why. Nimble picks the provider: your own keys first.
        `optimized_for` sets what Nimble favors when it picks the provider.
        Answers `{meta, result}`: the tool, and the extract's own answer.
      operationId: extract
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExtractRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtractToolResponse'
        '401':
          description: Missing or invalid API key, or Nimble refused your account.
        '402':
          description: 'Nimble refused your account: out of credits.'
        '403':
          description: Nimble refused your account, or WebRouter is not enabled for it.
        '422':
          description: The request is invalid, or the provider cannot serve it as asked.
        '502':
          description: The provider failed to serve the request.
        '504':
          description: No provider answered in time.
      security:
        - BearerAuth: []
components:
  schemas:
    ExtractRequest:
      properties:
        format:
          anyOf:
            - type: string
              enum:
                - markdown
                - html
                - text
            - type: 'null'
          title: Format
          description: >-
            Which representation of each page to return. Unset is markdown
            wherever the provider has it.
        optimized_for:
          anyOf:
            - $ref: '#/components/schemas/OptimizedFor'
            - type: 'null'
          description: >-
            What to favour: speed, cost or coverage. Unset or empty is
            `balanced`.
        urls:
          items:
            type: string
            minLength: 1
            pattern: ^[Hh][Tt][Tt][Pp][Ss]?://\S+$
          type: array
          maxItems: 20
          minItems: 1
          title: Urls
          description: >-
            The URLs to fetch, as absolute http(s) URLs, in the order the
            documents come back: at most 20 different ones. A URL asked for
            again, also with or without a trailing slash on its path, is fetched
            once, as first given.
          examples:
            - - https://example.com
      additionalProperties: false
      type: object
      required:
        - urls
      title: ExtractRequest
      description: A extract request.
      examples:
        - urls:
            - https://example.com
    ExtractToolResponse:
      properties:
        meta:
          $ref: '#/components/schemas/ToolMeta'
          description: The tool that ran.
        result:
          $ref: '#/components/schemas/ExtractResponse'
          description: The extract's own answer.
      type: object
      required:
        - meta
        - result
      title: ExtractToolResponse
    OptimizedFor:
      type: string
      enum:
        - speed
        - cost
        - coverage
        - balanced
      title: OptimizedFor
      description: '`balanced` is what a request that sends no `optimized_for` asks for.'
    ToolMeta:
      properties:
        tool:
          $ref: '#/components/schemas/Tool'
          description: The tool that ran.
      type: object
      required:
        - tool
      title: ToolMeta
    ExtractResponse:
      properties:
        provider:
          type: string
          title: Provider
          description: >-
            `nimble_selection` when Nimble picked and served the call. The
            provider's name when your own key served it, with `byok` true.
          examples:
            - nimble_selection
        byok:
          type: boolean
          title: Byok
          description: Whether your own provider key served the call.
        documents:
          items:
            $ref: '#/components/schemas/ExtractedDocument'
          type: array
          title: Documents
        failures:
          items:
            $ref: '#/components/schemas/ExtractFailure'
          type: array
          title: Failures
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Request Id
          description: >-
            The provider's id for the request. Backends that take one URL per
            call issue one id per document; the first is reported here and all
            of them are in `raw`. Only when your own key served the call.
      additionalProperties: false
      type: object
      required:
        - provider
        - byok
      title: ExtractResponse
      description: >-
        The result of one extract call, tagged with the provider that served
        it.  Extracting several URLs can partly succeed: what came back is in
        `documents`, and every URL that did not is in `failures` with the
        reason. A call where *nothing* came back raises instead, so a failure is
        never something you have to go looking for.
    Tool:
      type: string
      enum:
        - search
        - extract
        - extract_template
        - browse
        - research
        - answer
      title: Tool
    ExtractedDocument:
      properties:
        url:
          type: string
          title: Url
        title:
          type: string
          title: Title
          description: The page title, when the provider returned one.
          default: ''
        content:
          type: string
          title: Content
          description: The page body, in the representation `format` names.
          default: ''
        format:
          anyOf:
            - type: string
              enum:
                - markdown
                - html
                - text
            - type: 'null'
          title: Format
          description: >-
            Which representation `content` holds -- the one asked for, or, when
            none was, markdown wherever the provider can return it and its own
            default where it cannot. Never a guess: a provider that cannot
            return the requested format raises instead.
        status_code:
          anyOf:
            - type: integer
            - type: 'null'
          title: Status Code
          description: The fetched page's HTTP status, when reported.
        published_date:
          anyOf:
            - type: string
            - type: 'null'
          title: Published Date
        warnings:
          items:
            type: string
          type: array
          title: Warnings
          description: >-
            What looked off about a page that came back, such as a near-empty
            body.
        extra:
          additionalProperties: true
          type: object
          title: Extra
          description: Provider-specific fields with no normalized equivalent.
      additionalProperties: false
      type: object
      required:
        - url
      title: ExtractedDocument
      description: One fetched page, normalized across providers.
    ExtractFailure:
      properties:
        url:
          type: string
          title: Url
        error:
          type: string
          title: Error
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
          description: The provider's own error code, when it refused this page with one.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: >-
            The rest of the provider's own error for this page, as it gave it: a
            link to act on, say.
      additionalProperties: false
      type: object
      required:
        - url
        - error
      title: ExtractFailure
      description: A URL the provider could not fetch, and why.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

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