Skip to main content

Endpoints

MethodPathDescription
POSThttps://api.browser.tinyfish.aiCreate a browser session
DELETEhttps://api.browser.tinyfish.ai/{session_id}Terminate a browser session
All requests require an X-API-Key header. See Authentication.
The SDKs (tinyfish for Python and @tiny-fish/sdk for TypeScript) target https://agent.tinyfish.ai/v1/browser by default, while the REST host documented here is https://api.browser.tinyfish.ai. Both hosts are supported and behave identically.
Session creation typically takes 10-30 seconds. Set your HTTP client timeout to at least 60 seconds. Direct Browser API sessions are isolated; use Browser Context Profiles when you need reusable cookies or storage.

Request

Parameters

url
string
Target URL the session will navigate to on startup. Bare domains (e.g. tinyfish.ai) are automatically prefixed with https://. Omit to start at about:blank.
timeout_seconds
integer
Inactivity timeout in seconds (5–86400). Defaults to your plan maximum.

Response

On success, returns 201 Created with a JSON body containing session_id, cdp_url, and base_url.
session_id
string
Unique identifier for this session.
cdp_url
string
WebSocket URL for browser connection. Pass this to Playwright’s connect_over_cdp or any CDP client.
base_url
string
HTTPS base URL for the session. Use to access session endpoints such as /pages.

DELETE — Terminate a Session

Terminates the session immediately. If the session is already ended this call is a no-op and still returns 204.

Path Parameters

session_id
string
required
The session_id returned when the session was created.

Response

Returns 204 No Content with an empty body on success.

Error Codes

HTTP StatusError CodeCause
400INVALID_INPUTsession_id is missing or empty.
401MISSING_API_KEY / INVALID_API_KEYMissing or invalid X-API-Key.
404NOT_FOUNDSession does not exist or belongs to a different API key.
502INTERNAL_ERRORBrowser infrastructure failed to terminate the session. Retry.

Debugging — Open DevTools Inspector

Poll GET {base_url}/pages and open the devtoolsFrontendUrl of the first non-blank page to inspect the live browser session.
The page starts at about:blank and navigates asynchronously — skip blank pages when polling to get the correct inspector URL.

Session Lifecycle

BehaviorDetails
Startup navigationIf url was provided at session creation, the browser navigates there immediately. The 201 response is returned before navigation completes — the page may still be loading when you connect.
Inactivity timeoutSessions automatically terminate after the configured inactivity timeout. A session is considered inactive when no CDP commands are being sent.
Explicit terminationSend DELETE https://api.browser.tinyfish.ai/{session_id} to terminate a session immediately. Returns 204 No Content on success. Deleting an already-ended session is idempotent.
Session isolationEach direct Browser API session is isolated. For reusable cookies and storage, use Browser Context Profiles.

SDK Methods


End-to-End Example

Create a session, connect with Playwright, take a screenshot, and extract the page title.

Error Reference

HTTP StatusError CodeCauseResolution
400INVALID_INPUTurl field is not a valid URL.Check the details field in the error response for specifics.
401MISSING_API_KEY / INVALID_API_KEYMissing or invalid X-API-Key header.Verify your API key at the dashboard.
402INSUFFICIENT_CREDITSNo credits or active subscription.Add credits or upgrade your plan.
404NOT_FOUNDBrowser API is not available on your plan.Contact support to enable access.
500INTERNAL_ERRORUnexpected server error.Retry after a brief delay. If persistent, check agent.tinyfish.ai/status.
502INTERNAL_ERRORBrowser infrastructure failed to start the session.Retry — this is usually transient.

Browser Overview

First request, success shape, and product routing

Authentication

API key setup

Browser Context Profiles

Persist login state for future Agent API runs

Error Codes

Full list of API error codes

Key Concepts

Understand where Browser fits in the overall API surface