> For clean Markdown of any page on these docs, append `.md` to the page URL
> Full documentation index: https://you.com/docs/llms.txt
> Search over these docs using a free, read-only MCP server (it is the best way to pick the right API(s) for the job and understand how to use them): https://you.com/docs/_mcp/server
> Access web search, web fetch, and deep research tools using our product MCP server: https://api.you.com/mcp (use `/mcp/research` and `/mcp/finance` paths for Research and Finance Research respectively)
> Call live Web Search for free: append `?profile=free` to the MCP server path
> OpenAPI spec index: https://you.com/docs/openapi.json
> How to authenticate: https://you.com/docs/using-the-api/authentication
> Changelog: https://you.com/docs/changelog
> Full onboarding instructions for agents: https://you.com/SKILL.md

# Webpage and PDF Extraction

The **Extract API** fetches any webpage or PDF and parses it into clean Markdown or HTML, plus page metadata, without a headless browser or an HTML parser on your side. PDF tables keep their rows and columns, so filings and reports arrive ready for an LLM.

---

## What You'll Build

A one-call extractor that fetches a URL and parses it into clean Markdown—title, body, and page metadata in a single response. `full_page.extraction_formats` picks Markdown, HTML, or both, and `timeout` caps the whole request.

---

## Try It Live

Run a live Extract API request from this page. Open the **Try It** panel below, paste your API key, drop in a URL, and send it against the live endpoint.

### Request

POST [https://ydc-index.io/v1/extract](https://ydc-index.io/v1/extract)

```python
import os

import requests

response = requests.post(
    "https://ydc-index.io/v1/extract",
    headers={"X-API-Key": os.environ["YDC_API_KEY"]},
    json={
        "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
        "full_page": {"extraction_formats": ["markdown", "html"]},
    },
)
response.raise_for_status()
page = response.json()

# An empty object means nothing was extracted
if page.get("contents"):
    print(f"Title: {page.get('title')}")
    print(page["contents"]["full_page"]["markdown"][:500])

```

```typescript
const apiKey = process.env.YDC_API_KEY;
if (!apiKey) {
  throw new Error("Set the YDC_API_KEY environment variable");
}

const response = await fetch("https://ydc-index.io/v1/extract", {
  method: "POST",
  headers: {
    "X-API-Key": apiKey,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
    full_page: { extraction_formats: ["markdown", "html"] },
  }),
});

if (!response.ok) {
  throw new Error(`Extract API error ${response.status}: ${await response.text()}`);
}

const result = await response.json();
console.log(result);

```

```javascript
const response = await fetch("https://ydc-index.io/v1/extract", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.YDC_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
    full_page: { extraction_formats: ["markdown", "html"] },
  }),
});

if (!response.ok) {
  throw new Error(`Extract API error ${response.status}: ${await response.text()}`);
}

const result = await response.json();
console.log(result);

```

```curl
curl -X POST https://ydc-index.io/v1/extract \
     -H "X-API-Key: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
  "full_page": {
    "extraction_formats": [
      "markdown",
      "html"
    ]
  }
}'
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://ydc-index.io/v1/extract"

	payload := strings.NewReader("{\n  \"url\": \"https://en.wikipedia.org/wiki/Retrieval-augmented_generation\",\n  \"full_page\": {\n    \"extraction_formats\": [\n      \"markdown\",\n      \"html\"\n    ]\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-API-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://ydc-index.io/v1/extract")
  .header("X-API-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"url\": \"https://en.wikipedia.org/wiki/Retrieval-augmented_generation\",\n  \"full_page\": {\n    \"extraction_formats\": [\n      \"markdown\",\n      \"html\"\n    ]\n  }\n}")
  .asString();
```

```csharp
using RestSharp;

var client = new RestClient("https://ydc-index.io/v1/extract");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"url\": \"https://en.wikipedia.org/wiki/Retrieval-augmented_generation\",\n  \"full_page\": {\n    \"extraction_formats\": [\n      \"markdown\",\n      \"html\"\n    ]\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
  "full_page": ["extraction_formats": ["markdown", "html"]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://ydc-index.io/v1/extract")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Response (200)

```json
{
  "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
  "extraction_source": "blend",
  "title": "Retrieval-augmented generation - Wikipedia",
  "contents": {
    "full_page": {
      "markdown": "# Retrieval-augmented generation\n\n**Retrieval-augmented generation** (**RAG**) is a technique that enables large language models (LLMs) to retrieve and incorporate new information from external data sources...",
      "html": "<h1>Retrieval-augmented generation</h1>\n<p><b>Retrieval-augmented generation</b> (<b>RAG</b>) is a technique that enables large language models (LLMs) to retrieve and incorporate new information from external data sources...</p>"
    }
  },
  "metadata": {
    "site_name": "Wikipedia",
    "favicon_url": "https://api.ydc-index.io/favicon?domain=en.wikipedia.org&size=128"
  }
}
```

---

## Prerequisites

#### [Get a You.com API key](https://you.com/platform)

Sign up at you.com/platform.

Install the Python SDK. `you.extract()` needs version 3.7.0 or later.

```bash
pip install -U youdotcom        # Python ≥ 3.10
```

---

## Walkthrough

#### Python

**`extract.py`**

```python title="extract.py"
"""Extract—fetch clean Markdown from a webpage or PDF via the You.com Extract API."""

import sys

from youdotcom import You

# take URL from command line, or use a default
url = sys.argv[1] if len(sys.argv) > 1 else "https://en.wikipedia.org/wiki/Retrieval-augmented_generation"

with You() as you:
    page = you.extract(
        url=url,
        full_page={"extraction_formats": ["markdown"]},
        timeout=30,
    )

# an empty object means nothing was extracted
if not page.contents:
    sys.exit(f"Nothing extracted from {url}")

# print the title and the first 500 chars of the markdown body
print(page.title)
print(page.url)
print()
print(page.contents.full_page.markdown[:500] + "...")
```

```bash
export YDC_API_KEY="your-api-key-here"
python extract.py "https://en.wikipedia.org/wiki/Retrieval-augmented_generation"
```

#### TypeScript

**`extract.ts`**

```typescript title="extract.ts"
const response = await fetch("https://ydc-index.io/v1/extract", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.YDC_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
    full_page: { extraction_formats: ["markdown"] },
    timeout: 30,
  }),
});

if (!response.ok) {
  throw new Error(`Extract API error ${response.status}: ${await response.text()}`);
}

const page = await response.json();

// an empty object means nothing was extracted
if (page.contents) {
  console.log(page.title);
  console.log(page.url);
  console.log();
  console.log(page.contents.full_page.markdown.slice(0, 500) + "...");
}
```

### Example Output

```markdown
# Retrieval-augmented generation

Retrieval-augmented generation (RAG) is a technique that grants generative
artificial intelligence models information retrieval capabilities. It modifies
interactions with a large language model so that the model responds to user
queries with reference to a specified set of documents…

(Returned alongside title, url, and metadata.site_name = "Wikipedia". Full
Markdown body is ~12,000 chars.)
```

Pass a PDF URL to the same script to extract a document. Add `"parse_effort": "lite"` to the request for text-based PDFs to skip the per-page charge that the default `standard` adds.

---

## Next Steps

#### [Simple Search](/docs/examples/simple-search)

Find the URLs to extract, then feed them to Extract.

#### [Research Agent](/docs/examples/research)

Let the Research API search, read, and synthesize for you.

#### [Extract API Overview](/docs/guides/extract)

Formats, cache control, PDF parse effort, and errors.

---

## Resources

* [Extract API Overview](/docs/guides/extract)
* [Extract API Reference](/docs/api-reference/extract)
* [You.com OSS samples](https://github.com/youdotcom-oss)