# Templates

> Each recipe has a prompt to paste into your agent, the same call as cURL, and what it costs. Add `"dry_run": true` to any paid call to see the price first.

Canonical page: https://clawifi.dev/templates

## Answer from a page, with sources

Ask a page a question and get back only the passages that answer it, each with its heading, instead of the whole page.

> With Clawifi, call fetch_url on https://docs.python.org/3/library/asyncio-task.html with query "how do I put a timeout on a task" and top_k 3. Answer only from the passages it returns and quote the heading of each one you use.

**cURL**

```sh
curl -X POST https://api.clawifi.dev/fetch \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://docs.python.org/3/library/asyncio-task.html","query":"how do I put a timeout on a task","top_k":3}'
```

**Cost:** 1 credit (3 if the page needs the browser). Asking a question adds nothing; a page with nothing to read costs 0.

## Read a PDF

A PDF comes back as Markdown with page markers and ruled tables, so an agent can cite the page.

> With Clawifi, call fetch_url on https://arxiv.org/pdf/1706.03762 and summarize the paper in five bullet points, each with the page it comes from.

**cURL**

```sh
curl -X POST https://api.clawifi.dev/fetch \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://arxiv.org/pdf/1706.03762"}'
```

**Cost:** 2 credits for 1 to 50 pages, 4 for 51 to 100, in place of the base call.

## Search many engines as one

The Clawifi Index and free web engines, asked at once and merged by rank, each result with the source that found it. Domain, time, country and language filters are optional.

> With Clawifi, call search_free for "MCP authorization" limited to modelcontextprotocol.io, then read the best result with fetch_url and tell me how a client finds the authorization server.

**cURL**

```sh
curl -X POST https://api.clawifi.dev/search/free \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"MCP authorization","max_results":5,"include_domains":["modelcontextprotocol.io"]}'
```

**Cost:** 1 credit; a search with no results costs 0.

## Turn a docs site into Markdown

Map a site from its sitemaps, robots.txt, feeds and links, then crawl the part you need into Markdown for a knowledge base.

> With Clawifi, call map_site on https://docs.python.org/3/ with search "asyncio", show me the URLs it finds, then crawl the asyncio section (at most 20 pages) and give me one Markdown file per page.

**Map**

```sh
curl -X POST https://api.clawifi.dev/map \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://docs.python.org/3/","search":"asyncio","max_urls":100}'
```

**Crawl**

```sh
curl -X POST https://api.clawifi.dev/crawl \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"seed_url":"https://docs.python.org/3/library/asyncio.html","max_pages":20,"max_depth":1}'
```

**Cost:** Map: 1 credit per started 10 URLs returned. Crawl: 1 credit per page, 2 more for a page that needed JavaScript.

## Watch a competitor's pricing page

A monitor checks a page on a schedule (from every 5 minutes to once a month) and keeps every check and every change. include_selectors limits it to one part of the page; notify_email mails you when it changes; a webhook endpoint gets a POST.

> With the Clawifi API, create a monitor named "Competitor pricing" for https://example.com/pricing that checks once a day, compares only the main element, and emails me when it changes. Then show me how to read its changes.

**Price first**

```sh
curl -X POST https://api.clawifi.dev/monitors/estimate \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Competitor pricing","url":"https://example.com/pricing","schedule":{"interval_seconds":86400}}'
```

**Create**

```sh
curl -X POST https://api.clawifi.dev/monitors \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Competitor pricing","url":"https://example.com/pricing","schedule":{"interval_seconds":86400},"formats":["markdown"],"diff_modes":["text"],"include_selectors":["main"],"notify_email":true}'
```

**Read changes**

```sh
curl https://api.clawifi.dev/monitors/$MONITOR_ID/diffs \
  -H "Authorization: Bearer $CLAWIFI_API_KEY"
```

**Webhook (optional)**

```sh
curl -X POST https://api.clawifi.dev/webhooks/endpoints \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://your-app.example/hooks/clawifi","secret":"a-long-random-secret","event_types":["monitor.change.detected"]}'
```

**Cost:** 1 credit per check, 3 when it needs the browser. Once a day is 30 credits a month (the estimate call is free). Manage monitors in the [console](https://clawifi.dev/monitors).

## Get told about new search results

A search monitor runs a query on a schedule (hourly at most) and reports only results it has never seen before, so you hear about a new paper, release or article once.

> With the Clawifi API, create a search monitor named "Agent memory papers" for the query "agent memory benchmark" limited to arxiv.org, checked every 6 hours, that emails me new results.

**Create**

```sh
curl -X POST https://api.clawifi.dev/monitors \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Agent memory papers","kind":"search","query":"agent memory benchmark","search":{"include_domains":["arxiv.org"],"max_results":10},"schedule":{"interval_seconds":21600},"notify_email":true}'
```

**New results**

```sh
curl https://api.clawifi.dev/monitors/$MONITOR_ID/diffs \
  -H "Authorization: Bearer $CLAWIFI_API_KEY"
```

**Cost:** 1 credit per check; a check where every search engine failed costs 0. Every 6 hours is 120 credits a month.

## Research brief with sources

One call searches several lanes and reads the best pages, then returns the sources it used. Check the price first: it is the most expensive call.

> With Clawifi, first estimate a research call on "state of open-source web crawlers for AI agents", tell me the cost, and only run it if I agree.

**Price first**

```sh
curl -X POST https://api.clawifi.dev/research \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"state of open-source web crawlers for AI agents","dry_run":true}'
```

**Run**

```sh
curl -X POST https://api.clawifi.dev/research \
  -H "Authorization: Bearer $CLAWIFI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"state of open-source web crawlers for AI agents"}'
```

**Cost:** 5 credits per source searched plus 10 per page read: at least 30, at most 300. The dry run is free.

## Starter: Python

Install Clawifi, keep the key in `CLAWIFI_API_KEY`, and call a public URL.

**Python**

```python
from clawifi import Clawifi

client = Clawifi()
page = client.fetch("https://example.com")
results = client.search_free("Model Context Protocol")
print(client.credits())
```

Adding Clawifi to an MCP client is one line: [Install](https://clawifi.dev/install).
