# Web Fetch API

Extract webpage content as HTML, text, or Markdown with selector and readability options.

This page documents the existing `/v2` Felo APIs, using **Felo account entitlements and Pro-credit rules**. Whether credits are deducted depends on the [operation](https://openapi.felo.ai/docs/faq/billing-and-credits.md#credit-rules-by-v2-capability). For platform-balance calls, choose a supported [Felo OpenAPI endpoint](https://openapi.felo.ai/docs/api-reference/openapi/overview.md); request and response shapes can differ.

The Web Fetch API extracts content from a target URL and returns the result in a format that is easier for agents, RAG systems, and content workflows to process. It can return HTML, plain text, or Markdown, and it supports selectors, readability options, cache control, custom user agents, and request cookies.

## Endpoint

```http
POST https://openapi.felo.ai/v2/web/extract
```

## Authentication

Send your API key in the `Authorization` header:

```http
Authorization: Bearer YOUR_API_KEY
```

See the [Authentication Guide](https://openapi.felo.ai/docs/authentication.md) for details on creating and managing API keys.

## Use with AI Agents

Install the complete `felo-ai` package when you want an Agent to extract webpages alongside every other available Felo Skill. The installer dynamically discovers every package directory containing `SKILL.md`, so it never relies on a fixed list. Install all discovered Skills in Codex `~/.codex/skills`, Claude Code `~/.claude/skills`, OpenClaw `~/.agents/skills`, or Hermes Agent `~/.hermes/skills`. Use the [manual AI Agent setup guide](https://openapi.felo.ai/docs/felo-skills.md) for each platform's safe installation and API key steps.

## Request

### Headers

| Header | Required | Description |
|--------|----------|-------------|
| `Authorization` | Yes | Your API key in the format `Bearer YOUR_API_KEY` |
| `Content-Type` | Yes | Must be `application/json` |

### Body Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `url` | string | Yes | - | The webpage URL to extract. |
| `crawl_mode` | string | No | `fast` | Extraction mode. Use `fast` for a quicker fetch or `fine` for a more precise crawl that may handle richer pages. |
| `output_format` | string | No | `html` | Output format. Supported values: `html`, `text`, `markdown`. |
| `with_readability` | boolean or string | No | - | Enable readability processing to focus on main content and reduce page noise. |
| `with_links_summary` | boolean | No | - | Include a summary of links when supported by the downstream extractor. |
| `with_images_summary` | boolean | No | - | Include a summary of images when supported. |
| `with_images_readability` | boolean | No | - | Apply readability handling to image extraction when supported. |
| `with_images` | boolean | No | - | Include image information in the extracted result. |
| `with_links` | boolean | No | - | Include link information in the extracted result. |
| `ignore_empty_text_image` | boolean | No | - | Ignore images that do not contain useful text when supported. |
| `target_selector` | string | No | - | CSS selector for the target element to extract, such as `article.main-content`. |
| `wait_for_selector` | string | No | - | Wait until a CSS selector appears before extraction. Useful for dynamically rendered pages. |
| `set_cookies` | array | No | - | Cookies to send with the extraction request. |
| `user_agent` | string | No | - | Custom User-Agent string for the extraction request. |
| `timeout` | integer | No | - | Request timeout in milliseconds. |
| `with_cache` | boolean | No | `true` | Whether the downstream extractor may use cache. |
| `with_stypes` | boolean | No | `false` | Include style-type metadata when supported. |

## Response

### Success Response

The response uses a transparent pass-through design. The exact fields inside `data` can vary based on `output_format` and other extraction options.

```json
{
  "status": 200,
  "code": "OK",
  "request_id": "example-request-id",
  "data": {
    "content": "# Example Article\n\nExtracted article content..."
  }
}
```

### Response Fields

| Field | Type | Description |
|-------|------|-------------|
| `status` | integer | HTTP-style status, `200` on success. |
| `code` | string | `OK` on success. |
| `message` | string or null | Additional message. Usually `null` for successful requests. |
| `data` | object | Extracted content and metadata returned by the downstream extraction service. |
| `data.content` | string or object | Extracted content. The shape depends on `output_format` and selected options. |

## Error Responses

| HTTP Status | Error Code | Description | Suggested Action |
|-------------|------------|-------------|------------------|
| 400 | `WEB_EXTRACT_FAILED` | Request validation failed, the URL is invalid, or the downstream extractor returned a client-side error. | Check `url`, selectors, and request parameters. |
| 401 | `UNAUTHORIZED` | API key is missing, invalid, or revoked. | Verify your API key and authorization header. |
| 500 | `WEB_EXTRACT_FAILED` | Internal service error. | Retry the request. Contact support if the issue persists. |

## Examples

### Basic Extraction

```bash
curl -X POST https://openapi.felo.ai/v2/web/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com"
  }'
```

### Extract Markdown With Readability

```bash
curl -X POST https://openapi.felo.ai/v2/web/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/article",
    "output_format": "markdown",
    "with_readability": true
  }'
```

### Extract a Specific CSS Selector

```bash
curl -X POST https://openapi.felo.ai/v2/web/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/article",
    "target_selector": "article.main-content",
    "output_format": "text"
  }'
```

### Wait for Dynamic Content

```bash
curl -X POST https://openapi.felo.ai/v2/web/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/app",
    "crawl_mode": "fine",
    "wait_for_selector": "#loaded-content",
    "output_format": "markdown",
    "timeout": 30000
  }'
```

## Use Cases

- Give an agent webpage context before answering a question.
- Extract article text for RAG ingestion or knowledge-base creation.
- Convert webpages into Markdown for archiving or documentation workflows.
- Pull focused content from a page by using CSS selectors.
- Reduce page noise with readability processing before downstream AI analysis.

## Notes

- The API handles one URL per request.
- `data` is passed through from the downstream extraction service, so additional fields may appear over time.
- `fine` mode may be slower than `fast`, but can be useful when the page needs richer rendering behavior.
- Some pages may block extraction, require cookies, or need a custom `user_agent`.
