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:
[ -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
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.
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"
}'
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 wraps the curl call:
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
{
"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.
共 1 个版本