Choose the right way to call TinyFish Web Agent based on your use case
TinyFish Web Agent offers three ways to run automations. Each endpoint serves a different need. Pick the one that matches how you want to handle the request and response.
Pattern: Send request → Wait → Get resultThe simplest approach. You call the API, it blocks until the automation completes, then returns the result.
Copy
const response = await fetch("https://agent.tinyfish.ai/v1/automation/run", { method: "POST", headers: { "X-API-Key": process.env.TINYFISH_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ url: "https://example.com", goal: "Extract the page title", }),});const run = await response.json();console.log(run.result); // Your data
Runs created via /runcannot be cancelled. The request blocks until the automation completes, so there is no window to issue a cancellation. If you need the ability to cancel runs, use /run-async or /run-sse instead.
Pattern: Send request → Get run ID → Poll for resultThe request returns immediately with a run_id. You then poll a separate endpoint to check status and get the result when ready.1. Start the automation
Pattern: Send request → Receive event stream → Process events as they arriveUses Server-Sent Events (SSE) to push updates to you in real-time. You’ll receive events for each action the browser takes, plus a streaming URL you can embed in an iframe to watch the automation live.1. Start the automation