通过 TinyFish Fetch API 获取网页,返回干净的 Markdown、HTML 或截图,支持 JS 渲染和代理。适用于需要读取特定页面的场景。
Fetch one or more URLs via the TinyFish Fetch API. Returns rendered page content (markdown by default), optionally with screenshots, behind an optional proxy.
Requires: TINYFISH_API_KEY environment variable.
Before calling the API, verify the key is present:
bash
[ -n "$TINYFISH_API_KEY" ] && echo "TINYFISH_API_KEY is set" || echo "TINYFISH_API_KEY is NOT set"
If the key is not set, stop and ask the user to add it. Get one at https://agent.tinyfish.ai/api-keys. Do NOT fall back to other fetch tools.
bash
curl -X POST "https://api.fetch.tinyfish.ai" \
-H "X-API-Key: $TINYFISH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"urls": ["https://example.com"],
"format": "markdown"
}'
format accepts markdown (default), html, or screenshot.
bash
curl -X POST "https://api.fetch.tinyfish.ai" \
-H "X-API-Key: $TINYFISH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"urls": [
"https://example.com",
"https://example.org"
],
"format": "markdown"
}'
bash
curl -X POST "https://api.fetch.tinyfish.ai" \
-H "X-API-Key: $TINYFISH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"urls": ["https://example.com"],
"format": "markdown",
"proxy_config": { "country": "US" }
}'
scripts/fetch.sh <url> [<url> ...] [--format markdown|html|screenshot] [--country CC] wraps the curl call:
bash
scripts/fetch.sh https://example.com
scripts/fetch.sh https://example.com https://example.org --format html
scripts/fetch.sh https://example.com --format markdown --country US
json
{
"results": [
{
"url": "https://example.com",
"status": 200,
"content": "# Example Domain\n\nThis domain is for use…",
"format": "markdown"
}
]
}
Read results[].content for the rendered page. Screenshot format returns base64-encoded PNG data.