Batch Operate

Execute batch operations in parallel while automatically managing browser sessions and windows.

Parameters

urls
BatchOperationUrl[]Required

An array of URLs to process in parallel.

url
stringRequired

The URL to process.

context
Record<string, unknown>

Additional context data to be passed with the URL.

operation
(input: BatchOperationInput) => Promise<BatchOperationResponse<T>>Required

The operation function to execute for each URL.

input
BatchOperationInputRequired

The input provided to the operation function.

sessionId
stringRequired

The ID of the browser session.

windowId
stringRequired

The ID of the browser window.

liveViewUrl
stringRequired

The URL that can be used to view the browser window in real-time.

operationUrl
BatchOperationUrlRequired

The URL being processed, including any context data.

response
BatchOperationResponse<T>Required

The response returned by the operation function.

data
TRequired

Contains the relevant data returned by the operation, which will ultimately be returned in the results array.

shouldHaltBatch
boolean

If set to true, the batch operator will stop processing remaining URLs.

additionalUrls
BatchOperationUrl[]

If set, additional URLs will be processed as part of the same batch operation.

config
BatchOperateConfig

Configuration options for the batch operation.

maxConcurrentSessions
number

Maximum number of concurrent browser sessions. Defaults to 30.

maxWindowsPerSession
number

Maximum number of windows per session. Defaults to 1 (recommended).

sessionConfig
AirtopSessionConfigV1

Configuration for browser sessions.

onError
(error: BatchOperationError) => Promise<void>

Callback function for handling errors.

error.error
Error | stringRequired

The error that occurred.

error.operationUrls
BatchOperationUrl[]Required

The URLs that were being processed when the error occurred.

error.sessionId
string

The ID of the session where the error occurred (if available).

error.windowId
string

The ID of the window where the error occurred (if available).

error.liveViewUrl
string

The live view URL of the window where the error occurred (if available).

Returns

results
T[]Required

An array containing the results from each operation, in the order that the operations were executed. Note that the order of the input URLs does not necessarily match the order of the results.