API Reference
Complete API reference for the Browserable JavaScript SDK
Class: Browserable
The main SDK class that provides access to all Browserable functionality.
Constructor
Parameters
apiKey
(required): Your Browserable API keybaseURL
(optional): Override the default API base URL
Task Methods
createTask
Create a new automated browser task.
Parameters
task
: Natural language description of what you want to automateagent
: Agent (defaults to'BROWSER_AGENT'
)
listTasks
List all tasks for the authenticated user.
Parameters
listTaskRuns
List all runs for a specific task.
Parameters
getTaskRunStatus
Get the status of a specific task run.
Response Type
getTaskRunResult
Get the results of a specific task run.
Response Type
stopTaskRun
Stop a running task execution.
stopTask
Stop a task from running future executions.
waitForRun
Wait for a task run to complete or error out, with status monitoring.
Parameters
taskId
(required): The ID of the task to monitorrunId
(optional): The specific run ID to monitor. If not provided, monitors the most recent runoptions
(optional): Configuration options for the wait operationpollInterval
: Time in milliseconds between status checks (default: 1000ms)timeout
: Maximum time to wait in milliseconds (default: 5 minutes)onStatusChange
: Callback function for status updates
This method will continuously poll the task status until one of the following occurs:
- The task completes successfully (returns the result)
- The task errors out (returns the error result)
- The timeout is reached (throws an error)
- A network or other error occurs (throws an error)
getTaskRunGifStatus
Get the GIF status and URL for a task run. The GIF is automatically generated from the browser screenshots taken during the task execution.
Parameters
taskId
(required): The ID of the taskrunId
(optional): The specific run ID to get the GIF for. If not provided, returns the GIF status for the most recent run
The GIF generation is an asynchronous process that starts after a task run completes. The status field indicates:
pending
: GIF is being generatedcompleted
: GIF is ready and can be accessed via theurl
fielderror
: GIF generation failed, check theerror
field for details
check
Verify if your API key is valid.
Common Types
ApiResponse
All methods return a Promise that resolves to an ApiResponse
object:
Error Handling
All methods can throw errors in case of network issues or invalid parameters. Always wrap API calls in try-catch blocks:
Rate Limits
The SDK respects the API rate limits. When limits are exceeded, the API will return an error response. Implement appropriate retry logic in your application if needed.