Fetch does not use credits.
api.fetch.tinyfish.ai is the public Fetch API endpoint.
Before You Start
Get your API key
Visit agent.tinyfish.ai/api-keys and create a key. Store it in your environment:
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 thetext field with the format parameter. When omitted, the default is markdown.
- html
- markdown
- json
Semantic HTML.
Cache Freshness
By default, Fetch may serve an existing cached entry for the URL when one is available. Passttl to set a freshness preference in seconds.
- Omit
ttlto accept any cached entry. - Set
ttlto0when you want a live fetch. - Set
ttlto 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. Setinclude_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_matchandif_modified_sinceare single-URL only — combining either with a batch of URLs returns a400.- When the origin confirms nothing changed, the result comes back with
not_modified: trueso you can skip re-processing. - Fetch persists nothing — you own storing and replaying the validators.
CSS Selector Scoping
Extract only the part of the page you care about. Passinclude_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_selectorsis applied first, theninclude_selectorsscopes 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 withselector_not_matchedinerrors[], carryingunmatched_selectorspluscandidate_selectorsretry hints — agents can retry withinclude_selectorsdrawn from that list.exclude_selectorsentries that match nothing are a no-op.
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 optionalpurpose 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.
purposeis 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.
Read Next
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