---
name: tinyfish
description: Use when building web automation workflows, extracting data from
  websites, filling forms, handling authenticated sessions, or integrating
  browser automation into applications. Reach for this skill when you need to
  automate browser interactions using natural language goals instead of CSS
  selectors or XPath.
metadata:
  mintlify-proj: tinyfish
  version: "1.0"
---

# TinyFish Skill

## Product Summary

TinyFish is a web automation API that executes natural-language goals in a real browser. Instead of writing CSS selectors or XPath, you describe what you want done ("Extract all product names and prices") and TinyFish handles the clicks, typing, scrolling, and data extraction. The platform includes six APIs: **TinyAgent** (goal-based automation), TinyResearch (source-backed reports), TinySearch (web search), TinyFetch (page content extraction), TinyBrowser (remote browser sessions), and TinyMonitor (website monitoring).

**Key endpoints:**
- Agent: `https://agent.tinyfish.ai/v1/automation/run`, `/run-async`, `/run-sse`, `/run-batch`
- Search: `https://api.search.tinyfish.ai`
- Fetch: `https://api.fetch.tinyfish.ai`
- Browser: `https://api.browser.tinyfish.ai`

**SDKs:** Python (`pip install tinyfish`), TypeScript (`npm i @tiny-fish/sdk`), CLI (`npm install -g @tiny-fish/cli`), REST API with `X-API-Key` header.

**Authentication:** Set `TINYFISH_API_KEY` environment variable (get from https://agent.tinyfish.ai/api-keys). Both SDKs read it automatically.

## When to Use

Use TinyFish when:
- **Extracting data** from websites without writing selectors (product prices, reviews, job listings)
- **Filling forms** across multiple pages with structured input
- **Handling authentication** — use TinyProfiles for saved login state or Vault for credentials
- **Navigating multi-step workflows** in a single goal (login → navigate → extract)
- **Working with bot-protected sites** — enable stealth mode and proxies
- **Building recurring automations** — save browser state in TinyProfiles, repair stale sessions with Vault
- **Integrating with AI agents** — use MCP server for Claude, Cursor, ChatGPT, or other compatible hosts
- **Monitoring websites** for changes over time (TinyMonitor)
- **Searching the web** and getting ranked results (TinySearch)

Do not use TinyFish for:
- Tasks that require JavaScript execution beyond what a browser does (use Playwright/Puppeteer directly)
- Real-time bidirectional communication (WebSocket interactions)
- Tasks where you need pixel-perfect control over timing

## Quick Reference

### Endpoint Selection

| Endpoint | Pattern | Use When |
|----------|---------|----------|
| `/run` | Sync: send → wait → result | Quick tasks under 30s, simple integrations |
| `/run-async` | Async: send → get ID → poll | Long tasks, fire-and-forget, one task at a time |
| `/run-batch` | Batch: send many → get IDs → poll | 1–100 runs in one call, many URLs/goals |
| `/run-sse` | Stream: send → event stream | Real-time progress, user-facing apps, debugging |

### Run Statuses

| Status | Meaning | Final? | Action |
|--------|---------|--------|--------|
| `PENDING` | Queued, waiting for browser | No | Poll or wait |
| `RUNNING` | Browser working on goal | No | Poll or watch `streaming_url` |
| `COMPLETED` | Run finished, check `result` | Yes | Inspect result for success/failure |
| `FAILED` | Error occurred, check `error` | Yes | Read `error.category` to decide retry |
| `CANCELLED` | Stopped by cancel request or billing | Yes | Check `error.category` (BILLING_FAILURE vs UNKNOWN) |

**Critical:** `COMPLETED` does not mean the goal succeeded. Always check `result` for a `status` field or error signals like "captcha", "blocked", "auth required".

### Common Request Fields

```json
{
  "url": "https://example.com",
  "goal": "Extract product names and prices. Return as JSON.",
  "browser_profile": "lite",
  "use_profile": true,
  "use_vault": true,
  "proxy_config": { "enabled": true, "country_code": "US" },
  "output_schema": { "type": "object", "properties": { "products": { "type": "array" } } },
  "agent_config": { "max_steps": 50, "max_duration_seconds": 300 }
}
```

### Error Categories

| Category | Meaning | Action |
|----------|---------|--------|
| `SYSTEM_FAILURE` | TinyFish issue (SERVICE_BUSY, TIMEOUT) | Retry after `retry_after` seconds |
| `AGENT_FAILURE` | Run couldn't do task (SITE_BLOCKED, TASK_FAILED) | Change input, enable stealth/proxy, add profile |
| `BILLING_FAILURE` | Insufficient credits | Add funds at agent.tinyfish.ai/wallet (min $10) |
| `UNKNOWN` | Unclassified | Treat as retryable |

## Decision Guidance

### When to Use Each Endpoint

| Scenario | Endpoint | Why |
|----------|----------|-----|
| Single product page, quick extraction | `/run` | Simplest, no polling overhead |
| Scraping 100 product pages | `/run-batch` | One request/response pair instead of 100 |
| Long multi-page workflow (30+ steps) | `/run-async` + polling | Avoids timeout, allows cancellation |
| Dashboard showing live progress to user | `/run-sse` | Real-time events, streaming URL for live view |

### When to Use TinyProfile vs Vault vs Goal-Embedded Credentials

| Approach | Use When | Pros | Cons |
|----------|----------|------|------|
| **TinyProfile** | Recurring authenticated workflows | Reuses saved cookies, MFA state, trusted devices | Requires setup once per site |
| **Vault** (1Password/Bitwarden) | One-off logins or credential repair | Secure, no passwords in logs, auto-repair stale sessions | Requires password manager connection |
| **Goal-embedded** | Testing, one-time tasks | No setup | Passwords visible in logs, less secure |

**Best practice:** Use TinyProfile + Vault together. Profile keeps you logged in; Vault repairs stale sessions.

### When to Use Stealth Mode and Proxies

| Condition | Action |
|-----------|--------|
| Standard website (no bot protection) | `browser_profile: "lite"` (default) |
| Cloudflare, DataDome, or CAPTCHA | Add `browser_profile: "stealth"` + `proxy_config: { enabled: true }` |
| Geo-restricted content | Add `proxy_config: { country_code: "IN" }` (ISO 3166-1 alpha-2) |
| Repeated blocks despite stealth | Create TinyProfile with saved login state |

## Workflow

### 1. Understand the Task
- What data do you need? (product names, prices, reviews)
- Is the page behind a login? (plan TinyProfile or Vault)
- Does it have bot protection? (plan stealth + proxy)
- Is it a one-time task or recurring? (affects profile/vault choice)

### 2. Check Existing Runs
Before starting a new run, verify you're not duplicating work:
```bash
tinyfish runs list --limit 10
# or via API: GET /v1/runs
```

### 3. Write the Goal
Be explicit about output format and edge cases:
```
Extract product name, price, and availability status.
Return as JSON array: [{"name": "...", "price": "...", "available": true/false}]
If a product is out of stock, set available to false.
```

### 4. Choose Endpoint and Run
For a quick test:
```python
from tinyfish import TinyFish, RunStatus

client = TinyFish()
run = client.agent.run(
    url="https://example.com/products",
    goal="Extract first 3 product names and prices. Return as JSON."
)
if run.status == RunStatus.COMPLETED:
    print(run.result)
else:
    print(f"Failed: {run.error.message}")
```

For long tasks or many URLs:
```python
# Start async
queued = client.agent.queue(url="...", goal="...")
run_id = queued.run_id

# Poll later
import time
while True:
    run = client.runs.get(run_id)
    if run.status in ("COMPLETED", "FAILED", "CANCELLED"):
        break
    time.sleep(2)
```

### 5. Inspect the Result
Always check the status field in result, not just the run status:
```python
if run.status == RunStatus.COMPLETED:
    outcome = run.result or {}
    if outcome.get("status") == "success":
        print("Goal met:", outcome.get("data"))
    else:
        print("Goal not met:", outcome.get("reason"))
```

### 6. Handle Failures
```python
if run.status == RunStatus.FAILED:
    category = run.error.category
    if category == "SYSTEM_FAILURE":
        # Retry after delay
        pass
    elif category == "AGENT_FAILURE":
        # Change goal, enable stealth, add profile
        pass
    elif category == "BILLING_FAILURE":
        # Add credits
        pass
```

## Common Gotchas

- **`COMPLETED` ≠ success.** A run can be `COMPLETED` with an empty result if it hit a login wall or bot check. Always inspect `result` for a `status` field or error signals.

- **Passwords in goals are logged.** Never put credentials directly in the goal string. Use Vault or TinyProfile instead.

- **Sync `/run` cannot be cancelled.** If you need cancellation, use `/run-async`, `/run-batch`, or `/run-sse`.

- **Batch requests are not idempotent.** If a `/run-batch` request times out on your side, check `GET /v1/runs` before retrying — you may have already created the runs.

- **Max steps/duration overshoot by one.** A run with `max_steps: 3` reports `num_of_steps: 4`. The agent takes one extra step to write up what it has.

- **Streaming URL expires.** The `streaming_url` (live browser view) is valid while the run is active. After it finishes, use `video_url` (recording), which expires after 15 minutes.

- **TypeScript needs `"type": "module"`** in `package.json` for top-level `await`. The SDK is ESM-only.

- **Vault credentials must match the domain.** If you have multiple accounts on the same site, use `credential_item_ids` to scope which one to use.

- **TinyProfile and browser_profile are different.** `use_profile: true` loads saved browser state (cookies, MFA). `browser_profile: "stealth"` is a runtime mode for anti-detection.

- **Proxy country codes are ISO 3166-1 alpha-2.** Use "US", "IN", "GB", not full names.

- **Free tier limits.** Search and Fetch have daily allowances; Agent and Browser draw from wallet. Check balance with `client.wallet.get()`.

## Verification Checklist

Before submitting a run or integration:

- [ ] Goal is explicit about output format (JSON structure, field names)
- [ ] Goal includes edge cases ("if out of stock, set available: false")
- [ ] Output schema matches the goal (if using structured output)
- [ ] Credentials are in Vault or TinyProfile, not in the goal
- [ ] Endpoint choice matches the task (sync for quick, async for long, batch for many)
- [ ] Error handling checks `error.category`, not just `status`
- [ ] Result inspection checks `result.status` or similar, not just `run.status`
- [ ] Timeout is set appropriately (120s for sync Agent, 150s for Fetch)
- [ ] API key is in environment, not hardcoded
- [ ] Wallet balance is sufficient (check with `client.wallet.get()`)

## Resources

**Comprehensive navigation:** https://docs.tinyfish.ai/llms.txt (page index) and https://docs.tinyfish.ai/llms-full.txt (full API reference, 218KB)

**Critical docs:**
- [TinyAgent API Reference](https://docs.tinyfish.ai/tinyagent/api) — Endpoints, request/response schema, runs lifecycle
- [Runs: Lifecycle and Statuses](https://docs.tinyfish.ai/tinyagent/explanation/runs) — How to interpret COMPLETED, FAILED, CANCELLED and what they mean
- [Goal Prompting Guide](https://docs.tinyfish.ai/prompting-guide) — Patterns for reliable goals, task-specific examples, production templates

---

> For additional documentation and navigation, see: https://docs.tinyfish.ai/llms.txt