# Token-efficient web data for AI agents

Raw HTML wastes context windows. FastAF endpoints let an agent choose a compact output for each call: Markdown instead of HTML, named fields instead of whole pages, and a capped number of results. Everything below is in the [API docs](/docs/) and in [llms-full.txt](/llms-full.txt); for the patterns behind it, see [token-aware web scraping for AI agents](/use-cases/token-aware-scraping/).

## How do you get a page as Markdown, not HTML?

`/v1/scrape` takes one public URL and one output format: `html` (default), `markdown`, `links`, `summary` or `images`. With `formats=markdown` the response is the Markdown text itself, not a JSON wrapper. `links` and `images` return JSON lists of page URLs; `summary` is AI-generated.

```
curl --fail-with-body -H "Authorization: Bearer $FASTAF_API_KEY" \
  'https://api.fastaf.co/v1/scrape?url=https%3A%2F%2Fexample.com%2F&formats=markdown'
```

JavaScript rendering is opt-in (`dynamic=true`, 5 credits instead of 1), so static pages stay cheap. See the [web scraping API](/apis/web-scraping-api/).

## How do you ask for fields instead of pages?

*   `ai_query`: a natural-language prompt such as “Return the product price and currency”.
*   `ai_extract_rules`: a JSON-encoded string such as `{"price":"product price","currency":"currency code"}`.
*   `POST /v1/extract`: structured JSON from a page, with a required `url` and a JSON Schema in `schema`, 40 credits per successful call. See the [extract API](/apis/extract-api/).

AI extraction on scrape (`ai_query`, `ai_extract_rules` or `formats=summary`) adds 10 credits to the selected mode, once per request.

## Why use structured endpoints instead of scraping search pages?

SERP, Maps, News, Jobs, eBay and the other structured endpoints return JSON with named fields: a SERP organic result carries `title`, `link`, `snippet` and `rank`, with no page markup around them. See the [Google SERP API](/apis/google-serp-api/) and the [API catalog](/apis/).

## How do you cap the result count?

On SERP, `results` (1 to 100) is the maximum number of organic results FastAF keeps, so a 5-result answer carries 5 organic results; other Google blocks, such as an answer box, can still appear. Google supplies up to 10 per page: use `page` for more, and each page is a separate request (5 credits).

```
curl --fail-with-body -H "Authorization: Bearer $FASTAF_API_KEY" \
  'https://api.fastaf.co/v1/serp?query=standing+desk&results=5'
```

## How do you read public feeds compactly?

`/v1/reddit` returns Markdown with `formats=markdown`; author usernames and profile links are removed.

## How do you track the cost of each call?

Successful MCP tool results report `credits_used` and `credits_remaining`; keyed REST calls return `X-FastAF-Credits-Used`. Failed calls cost nothing. See [credits](/docs/#credits) and [pricing](/pricing/).

## FAQ

### Which format uses the fewest tokens?

For reading a page, `formats=markdown`; for specific values, `ai_query`, `ai_extract_rules` or `/v1/extract`.

### Is Markdown wrapped in JSON?

No. Scrape returns the Markdown text itself.

### Does FastAF crawl a whole site?

No. Scrape handles one URL per request.

### Does JavaScript rendering cost more?

Yes. It is off by default and enabled with `dynamic=true`: 5 credits instead of 1 for a plain page.

### Are failed calls charged?

No. A call that fails costs no credits, and over x402 the payment does not settle.

## Related

[Token-aware web scraping for AI agents](/use-cases/token-aware-scraping/) · [Web page to Markdown for LLMs](/use-cases/web-page-to-markdown-for-llm/) · [MCP server](/docs/#mcp) · [Too many MCP tools?](/how-to/mcp-tool-schema-bloat/)

## Related

*   [Token-aware web scraping for AI agents: get only the content your LLM needs](/use-cases/token-aware-scraping/)
