Skip to main content
Fetch does not use credits.
The TinyFish Fetch API fetches web pages, renders JavaScript-heavy pages when needed, and returns clean extracted text in your preferred format. Submit a URL, get back structured content.
api.fetch.tinyfish.ai is the public Fetch API endpoint.

Before You Start

1

Get your API key

Visit agent.tinyfish.ai/api-keys and create a key. Store it in your environment:
All requests require the X-API-Key header. See Authentication for the full setup and troubleshooting guide.

Your First Request

What Success Looks Like

When to Use Fetch vs the Other APIs

  • Use Fetch when you already know the URL and need clean extracted page content.
  • Use Search when you need help finding the right URLs first.
  • Use Agent when TinyFish should perform a multi-step workflow on the site.
  • Use Browser when you need direct browser control from your own code.

Fetching Multiple URLs

Submit up to 10 URLs in a single request. Each URL is processed independently — one failure doesn’t affect the others.
Per-URL failures (timeouts, DNS errors, anti-bot blocks) appear in errors[] alongside a 200 response — they do not cause the entire request to fail.

Output Formats

Control the format of the text field with the format parameter. When omitted, the default is markdown.
Semantic HTML.

Cache Freshness

By default, Fetch may serve an existing cached entry for the URL when one is available. Pass ttl to set a freshness preference in seconds.
  • Omit ttl to accept any cached entry.
  • Set ttl to 0 when you want a live fetch.
  • Set ttl to a positive integer to accept cached entries younger than that many seconds.

Conditional Requests

Skip reprocessing pages that haven’t changed since your last fetch. Set include_etag_and_last_modified: true to get etag / last_modified validators back on each result, save them, then replay the etag as if_none_match (or the last_modified as if_modified_since) the next time you fetch that URL.
  • if_none_match and if_modified_since are single-URL only — combining either with a batch of URLs returns a 400.
  • When the origin confirms nothing changed, the result comes back with not_modified: true so you can skip re-processing.
  • Fetch persists nothing — you own storing and replaying the validators.
See the full reference and a worked example.

CSS Selector Scoping

Extract only the part of the page you care about. Pass include_selectors (an array of CSS selectors, max 20) to scope extracted content to elements matching any entry, and/or exclude_selectors to strip matching elements before extraction.
  • Selected content is returned verbatim in your requested format — automatic boilerplate removal is bypassed. Page-level metadata (title, description, etc.) still comes from the full document.
  • exclude_selectors is applied first, then include_selectors scopes what remains.
  • If some entries match and others don’t, the URL still succeeds and the misses are listed in the result’s unmatched_selectors. If no entry matches anything, that URL fails with selector_not_matched in errors[], carrying unmatched_selectors plus candidate_selectors retry hints — agents can retry with include_selectors drawn from that list. exclude_selectors entries that match nothing are a no-op.
See the full reference and a worked example.

Supported Content Types

The Fetch API handles more than just HTML. See the full content types table in the reference — highlights: PDF text extraction works, JSON endpoints return raw JSON, but binary files (images, video) return an error.

Fetch Intent

The optional purpose parameter lets you state why you are fetching — the underlying goal or task the content will be used for. A URL alone says nothing about what you need from the page. Passing purpose gives us additional signal to further inform and deliver better-quality results. It works the same way as the Search API’s purpose parameter.
  • purpose is always optional. Omitting it leaves fetch behaviour unchanged.
  • Keep it to a short phrase or sentence (maximum 2000 characters), for example Compare pricing tiers across vendors for a procurement report.

API Reference

Full request and response schema

Authentication

API key setup

Fetch Examples

Common Fetch request patterns

For coding agents

One page that routes an agent to the right TinyFish API