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

# WebRouter Extract

> Read pages you have URLs for, as markdown, HTML, or text, on Nimble or any extract provider

> [!NOTE]
>
> **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/).

WebRouter **Extract** reads pages you already have URLs for and returns their content, as markdown by default. Send up to 20 URLs in one call. Nimble picks the provider.

Extract reads pages. It does not find them. Pass URLs from [Search](https://docs.nimbleway.com/nimble-sdk/web-router/search.md), from your users, or from a page you read. For Nimble's own extract API, with rendering, browser actions, and parsing, see [Extract](https://docs.nimbleway.com/nimble-sdk/web-tools/extract/quickstart.md).

## Quick Start

### Example Request

```python Python theme={"system"}
import requests

response = requests.post(
    "https://sdk.nimbleway.com/v2/web-router/extract",
    headers={"Authorization": "Bearer YOUR-API-KEY"},
    json={"urls": ["https://example.com"]},
)

for document in response.json()["result"]["documents"]:
    print(document["url"], document["content"][:200])
```

```typescript TypeScript theme={"system"}
const response = await fetch("https://sdk.nimbleway.com/v2/web-router/extract", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR-API-KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ urls: ["https://example.com"] }),
});

const { result } = await response.json();
for (const document of result.documents) {
  console.log(document.url, document.content.slice(0, 200));
}
```

```bash cURL theme={"system"}
curl -X POST 'https://sdk.nimbleway.com/v2/web-router/extract' \
--header 'Authorization: Bearer <YOUR-API-KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "urls": ["https://example.com"]
}'
```

### Example Response

```json theme={"system"}
{
  "meta": { "tool": "extract" },
  "result": {
    "provider": "nimble_selection",
    "byok": false,
    "documents": [
      {
        "url": "https://example.com/",
        "title": "",
        "content": "This domain is for use in documentation examples without needing permission...",
        "format": "markdown",
        "status_code": 200,
        "published_date": null,
        "warnings": [],
        "extra": {}
      }
    ],
    "failures": []
  }
}
```

## How it works

**1. You send URLs**

Up to 20 absolute `http` or `https` URLs. A URL sent twice, with or without
a trailing slash, is fetched once.

**2. Nimble picks the provider**

Your own provider keys first, then Nimble's. A provider that cannot return the `format` asked for
is skipped. A provider that fails, or returns only blank pages, falls through to the next.

**3. Documents come back in order**

Each page that was read is in `documents`, in the order of `urls`. Each URL
that could not be read is in `failures`, with the reason.

> [!NOTE]
>
> Several URLs can partly succeed. Check `failures` as well as `documents`. A call
> where no URL could be read returns an error instead.

## Parameters

> [accordion] urls - Required
>
> **urls** `array of strings` *required*
>
> The URLs to read, as absolute `http` or `https` URLs. From 1 to 20.
>
> **Example:** `["https://example.com"]`

> [accordion] format
>
> **format** `string`
>
> Which representation of each page to return. Unset is markdown wherever the provider has it. `document.format` names the one returned.
>
> **Options:** `markdown`, `html`, `text`

> [accordion] optimized\_for
>
> **optimized\_for** `string` (default: balanced)
>
> What Nimble favors when it picks the provider.
>
> **Options:** `speed`, `cost`, `coverage`, `balanced`

## Response fields

| Field | Description |
| - | - |
| `documents[].url` | The page's URL |
| `documents[].title` | The page title, when the provider returned one |
| `documents[].content` | The page body, in `format` |
| `documents[].status_code` | The page's HTTP status, when reported |
| `documents[].warnings` | What looked off about the page, such as a near-empty body |
| `documents[].extra` | Provider-specific fields |
| `failures[].url` | A URL that could not be read |
| `failures[].error` | Why it could not be read |
| `failures[].code` | The provider's own error code, when it gave one |
| `failures[].details` | The rest of the provider's error, such as a link to act on |

## Next Steps

> [card] [Search](https://docs.nimbleway.com/nimble-sdk/web-router/search.md)
>
> Find pages to extract

> [card] [API Reference](https://docs.nimbleway.com/api-reference/webrouter/extract.md)
>
> Every field of the request and response


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