# Webpage to Markdown

`POST https://api.serpkite.com/v1/webpage` · Credits: 1 per page

Fetch any public URL (HTML or PDF) as clean Markdown and text with its title, description and metadata. Pages that need JavaScript are rendered in a browser.

Fetch any public URL and get clean Markdown and plain text plus metadata (title, description, language, canonical, author, published time). Built for feeding pages to an LLM. This is the one endpoint without a `results` list.

PDFs work too: SerpKite reads the PDF's text layer page by page (`<!-- page N -->` markers in the Markdown) and reports the page count in `metadata.pages`. Scanned PDFs without a text layer come back empty and are not billed.

To fetch the top search results in the same call as the search, use [`include_content`](https://serpkite.com/docs/include-content) on /v1/search instead.

## Request body

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `url` **required** | string |  | Public http(s) URL of an HTML page or a PDF. Required. |
| `format` | string | `json` | `markdown` returns the page Markdown as `text/markdown`. One of: `json`, `markdown`. |
| `country` | string |  | Fetch the page as seen from this country (two-letter ISO code, e.g. `de`) for pages that differ by region. Defaults to `us`. |
| `include_html` | boolean | `false` | Webpage: also return the raw HTML. |
| `include_links` | boolean | `false` | Webpage: also return the page's outbound links (url, text). |
| `include_images` | boolean | `false` | Webpage: also return the page's image URLs. Shopping: `data:` thumbnails on cards with no image URL. |
| `max_age` | integer |  | Accept a cached result up to this many seconds old. Cache hits cost 50% of the credits. |

## Example request

cURL:

```bash
curl https://api.serpkite.com/v1/webpage \
  -H "Authorization: Bearer $SERPKITE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://en.wikipedia.org/wiki/Search_engine_results_page","format":"markdown"}'
```

TypeScript:

```ts
import { SerpKite } from "serpkite";

const sk = new SerpKite(); // reads SERPKITE_API_KEY
const res = await sk.webpage({ url: "https://en.wikipedia.org/wiki/Search_engine_results_page", format: "markdown" });
console.log(res);
```

Python:

```python
from serpkite import SerpKite

sk = SerpKite()  # reads SERPKITE_API_KEY
res = sk.webpage("https://en.wikipedia.org/wiki/Search_engine_results_page", format="markdown")
print(res)
```

## Response fields

| Field | Type | Description |
| --- | --- | --- |
| `request` | object | The normalised request, with defaults filled in: `endpoint`, `engine`, `q`, `country`, `language`, `location`, `num`, `page`, `device`, `autocorrect`… |
| `url` | string | Final URL after redirects. |
| `status_code` | integer | HTTP status of the fetched page. |
| `markdown` | string | Main content as Markdown. |
| `text` | string | Main content as plain text. |
| `html` | string | Raw HTML decoded to UTF-8, only with `include_html: true`. |
| `metadata` | object | `title`, `description`, `language`, `canonical`, `site_name`, `image`, `published_time`, `author`, `content_type` (`text/html`, `application/pdf`…) and, for PDFs, `pages`. |
| `links` | array | Only with `include_links: true`. The page's outbound links (`url`, `text`), absolute, deduplicated, in document order (up to 500). |
| `image_links` | array | Only with `include_images: true`. Image URLs in document order (up to 100). |
| `meta` | object | `request_id`, `credits_used`, `cached`, `cached_at`, `engine` (the provider that answered), `route` (provider attempts, see [Search providers](https://serpkite.com/docs/providers)), `latency_ms`, `parse_quality` (`ok`, `partial`, `empty`), `resolved_urls`, `unresolved_links` (results whose `link` is still a Google redirect); `llm` (`provider`, `model`, `input_tokens`, `output_tokens`) and `warnings` when an AI step ran or failed. |

## Example response

```json
{
  "request": {
    "endpoint": "webpage",
    "engine": "google",
    "url": "https://en.wikipedia.org/wiki/Search_engine_results_page",
    "format": "json"
  },
  "url": "https://en.wikipedia.org/wiki/Search_engine_results_page",
  "status_code": 200,
  "markdown": "# Search engine results page\n\nA **search engine results page** (**SERP**) is a webpage that is displayed by a search engine in response to a query by a user…",
  "text": "Search engine results page. A search engine results page (SERP) is a webpage that is displayed by a search engine in response to a query by a user…",
  "metadata": {
    "title": "Search engine results page - Wikipedia",
    "language": "en",
    "canonical": "https://en.wikipedia.org/wiki/Search_engine_results_page",
    "site_name": "Wikipedia"
  },
  "meta": {
    "request_id": "req_01J8ZK4M6Q2V7",
    "credits_used": 1,
    "cached": false,
    "engine": "google",
    "latency_ms": 1034
  }
}
```

## Errors

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | `invalid_request` | A parameter is missing or invalid. |
| 401 | `unauthorized` | The API key is missing, invalid or revoked. |
| 402 | `insufficient_credits` | Your balance is too low. Buy a pack or wait for the monthly free grant. |
| 429 | `rate_limited` | Too many requests per second for your plan. Retry after the Retry-After header. |
| 503 | `upstream_error` | Google could not be fetched or parsed. Not billed; retry after Retry-After. |

All errors: https://serpkite.com/docs/errors

## Notes

- Only public pages are fetched: no logins, no paywalled content.
- Pages that can't be fetched return `503 upstream_error` and are not billed. Pages and PDFs are read up to 8 MiB; a larger file or a PDF that can't be read gets the same `503 upstream_error`, with the reason in the message.

## Related

- [Page content with search](https://serpkite.com/docs/include-content)
- [RAG pipeline](https://serpkite.com/docs/guides/rag-pipeline)