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

# Fetch for AI agents

> Self-contained integration prompt for coding agents and tool-using LLMs.

This page is structured for direct use as integration context for a coding
agent, or as a function-calling tool definition. Operational guidance is
repeated inline so the page is self-contained.

***

# Linkup `/fetch` integration guide

You are integrating the **Linkup `/fetch` API**: a real-time page content
extractor. Given a URL, it returns clean LLM-ready markdown. Optional
JavaScript rendering is available for client-side-rendered pages, along with
optional raw HTML and image URL extraction.

Limits: pages up to 20 MB, HTML and PDF only. Latency: \~1s.

## When to use it

Use `/fetch` when the URL is already known: typically after `/search` has
narrowed the candidates, or when a user has supplied the URL directly.

Other endpoints in the API:

* [**Search**](/pages/documentation/endpoints/search/overview) (`/search`): when no URL is available and web content must be located.
* [**Research**](/pages/documentation/endpoints/research/overview) (`/research`): autonomous research agent. Async, 2–20 minutes depending on depth.
* [**Tasks**](/pages/documentation/endpoints/tasks/overview) (`/tasks`): asynchronous batch wrapper around **Search**, **Fetch**, and **Research**.

## Setup

```bash theme={"system"}
pip install linkup-sdk            # Python
# or
npm install linkup-sdk            # TypeScript
```

```bash theme={"system"}
export LINKUP_API_KEY="your-api-key"
```

## Example (Python; adapt to the project's language)

```python theme={"system"}
from linkup import LinkupClient

client = LinkupClient(api_key="<YOUR_LINKUP_API_KEY>")

# renderJs: true is the safer default for unknown sites.
# Many modern marketing sites and SPAs require it.
response = client.fetch(
    url="https://docs.linkup.so",
    render_js=True,
)
print(response)
```

## Tool definition (OpenAI function-calling format)

Remove the `"type": "function"` envelope and rename `parameters` to
`input_schema` for the Anthropic format.

```json theme={"system"}
{
  "type": "function",
  "function": {
    "name": "linkup_fetch",
    "description": "Fetches a URL and returns clean LLM-ready markdown. Supports HTML and PDF pages up to 20 MB. Handles JavaScript-rendered HTML pages when renderJs is true. Use whenever the URL is already known.",
    "parameters": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "description": "The URL to fetch. Must be a valid HTTP/HTTPS URL pointing to an HTML or PDF page."
        },
        "renderJs": {
          "type": "boolean",
          "description": "Render the page's JavaScript before extraction. Default false. For agentic pipelines, set to true by default to ensure the full page content is extracted; many modern sites require it. Set to false only after the specific site has been confirmed to render server-side.",
          "default": false
        },
        "includeRawHtml": {
          "type": "boolean",
          "description": "Return the raw HTML alongside the markdown. Default false. Set to true for workflows that need full page HTML, or when complex structure (tables, custom elements) is erased during markdown conversion.",
          "default": false
        },
        "extractImages": {
          "type": "boolean",
          "description": "Extract image URLs alongside the markdown. Default false. Set to true for workflows that consume images (product photos, charts, recipe images).",
          "default": false
        }
      },
      "required": ["url"]
    }
  }
}
```

## Operational guidance (inline)

### `renderJs` selection

For agentic pipelines, set `renderJs` to `true` by default to ensure the full
content of each page is extracted. A page that requires JavaScript rendering
and does not receive it returns near-empty markdown. The cost is $0.001
without rendering and $0.005 with rendering. Set `renderJs` to `false` only
when all the URLs to be accessed have been confirmed to render server-side.

### When to use Fetch

**Fetch** is purpose-built to extract the content of a webpage that has been identified. Linkup's **Fetch** can be used as a stronger alternative to typical fetch tools because it can render JavaScript.

### The Search → Fetch pattern

```python theme={"system"}
search = client.search(
    query="Datadog pricing tiers",
    depth="standard",
    output_type="searchResults",
)

for r in search.results[:3]:
    page = client.fetch(url=r.url, render_js=True)
    # feed page.markdown to your LLM, or extract fields directly
```

Use **Search** to find candidate URLs and **Fetch** to retrieve them in full
when the agent needs to reason over the full page content rather than the
snippets returned by **Search**.

### Constraints

* **Fetch** supports HTML and PDF. Other binary URLs (ZIPs, images, videos) return a `400` error.
* **Fetch** returns a `400` error for pages over 20 MB.
* **Fetch** does not authenticate. It returns the response a logged-out visitor would see.
* Setting `extractImages` to `true` adds latency; enable it for workflows that consume image URLs.
* `includeRawHtml` should be `true` only when the raw HTML is required.

## TypeScript notes

* Import: `import { LinkupClient } from 'linkup-sdk'`.
* Method: `await client.fetch({ url, renderJs })`. Single object argument.
* Field names are camelCase: `renderJs`, `includeRawHtml`, `extractImages`.

## Links

* [Fetch overview](/pages/documentation/endpoints/fetch/overview)
* [Fetch best practices](/pages/documentation/endpoints/fetch/best-practices)
* [API reference](/pages/documentation/endpoints/fetch/reference)
* [OpenAPI spec](https://api.linkup.so/v1/openapi.json)
