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

# Scraper API

> Extract a single web page as markdown, HTML, or a screenshot.

## Overview

Use the Scraper API when you already have a URL and need page content. It supports:

* `markdown` for LLM-ready text
* `html` for raw rendered markup
* `screenshot` for a base64 PNG capture

PDF URLs are not scraped by this endpoint. Use the [PDF Content API](/scrape-pdf) for PDF text extraction.

## Endpoint

`POST /api/v2/scrape`

## Quickstart

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { LLMLayerClient } from 'llmlayer';

  const client = new LLMLayerClient({
    apiKey: process.env.LLMLAYER_API_KEY,
  });

  const page = await client.scrape('https://www.ycombinator.com/blog', {
    formats: ['markdown'],
    mainContentOnly: true,
  });

  console.log(page.title);
  console.log(page.markdown);
  console.log(page.statusCode);
  ```

  ```python Python theme={null}
  from llmlayer import LLMLayerClient

  client = LLMLayerClient(api_key="YOUR_LLMLAYER_API_KEY")

  page = client.scrape(
      "https://www.ycombinator.com/blog",
      formats=["markdown"],
      main_content_only=True,
  )

  print(page.title)
  print(page.markdown)
  print(page.statusCode)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.llmlayer.dev/api/v2/scrape \
    -H "Authorization: Bearer YOUR_LLMLAYER_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://www.ycombinator.com/blog",
      "formats": ["markdown"],
      "main_content_only": true
    }'
  ```
</CodeGroup>

## Formats

| Format       | Response field | Best for                        | Cost     |
| ------------ | -------------- | ------------------------------- | -------- |
| `markdown`   | `markdown`     | LLM input, summaries, retrieval | `$0.001` |
| `html`       | `html`         | Archival or custom parsing      | `$0.001` |
| `screenshot` | `screenshot`   | Visual verification             | `$0.001` |

You can request multiple formats in one call:

```typescript theme={null}
const page = await client.scrape({
  url: 'https://www.ycombinator.com',
  formats: ['markdown', 'html', 'screenshot'],
});
```

<Warning>
  `pdf` is accepted by some clients for backward compatibility, but this endpoint does not generate PDF output. Direct PDF URLs return a validation error. Use `/api/v2/get_pdf_content`.
</Warning>

## Request Parameters

| Parameter           | Type       | Required | Default                | Description                             |
| ------------------- | ---------- | -------- | ---------------------- | --------------------------------------- |
| `url`               | `string`   | Yes      | -                      | Public `http` or `https` page URL       |
| `formats`           | `string[]` | Yes      | `["markdown"]` in SDKs | Any of `markdown`, `html`, `screenshot` |
| `include_images`    | `boolean`  | No       | `true`                 | Include image references in markdown    |
| `include_links`     | `boolean`  | No       | `true`                 | Include links in markdown               |
| `advanced_proxy`    | `boolean`  | No       | `false`                | Use for heavily protected sites         |
| `main_content_only` | `boolean`  | No       | `false`                | Reduce navigation and boilerplate       |

<Note>
  HTTP requests use `snake_case`. The TypeScript SDK uses `camelCase`, for example `advancedProxy` and `mainContentOnly`.
</Note>

## Response

```json theme={null}
{
  "markdown": "# Article title\n\nArticle body...",
  "html": null,
  "screenshot": null,
  "pdf": null,
  "url": "https://www.ycombinator.com/blog",
  "title": "Article title",
  "statusCode": 200,
  "cost": 0.001,
  "metadata": {
    "description": "..."
  }
}
```

| Field        | Type             | Description                               |
| ------------ | ---------------- | ----------------------------------------- |
| `markdown`   | `string \| null` | Markdown content when available/requested |
| `html`       | `string \| null` | HTML content when requested               |
| `screenshot` | `string \| null` | Base64 PNG when requested                 |
| `pdf`        | `string \| null` | Legacy field; normally `null`             |
| `url`        | `string`         | Final URL after redirects                 |
| `title`      | `string \| null` | Page title                                |
| `statusCode` | `integer`        | Target status code                        |
| `cost`       | `number \| null` | Billed cost                               |
| `metadata`   | `object \| null` | Extracted metadata                        |

## Pricing

Base cost is `$0.001` per requested supported format. Advanced proxy adds `$0.004` when enabled.

```text theme={null}
markdown only:                 $0.001
markdown + screenshot:         $0.002
markdown + html + screenshot:  $0.003
markdown + proxy:              $0.005
```

## Errors

| Status | Meaning                                                                  |
| ------ | ------------------------------------------------------------------------ |
| `400`  | Invalid URL, unsupported scheme, DNS failure, or PDF URL sent to Scraper |
| `401`  | Missing or invalid LLMLayer API key                                      |
| `403`  | Blocked private/unsafe target                                            |
| `500`  | Upstream scrape failure                                                  |

See [Errors & Refunds](/errors) for the shared error format.

## More Examples

<CardGroup cols={2}>
  <Card title="Search + Scrape Pipeline" icon="diagram-project" href="/examples/search-scrape">
    Search the web, scrape pages, and answer from collected context.
  </Card>

  <Card title="Extract API" icon="wand-magic-sparkles" href="/extract">
    Use structured extraction when you need schema-shaped data.
  </Card>
</CardGroup>
