BatchBuilder
Executes multiple API requests in a single HTTP call.
Example
const results = await api.batch(
api.workspaceUsers.getUserById(123, 456, { batch: true }),
api.workspaceUsers.getUserById(123, 789, { batch: true })
)
Extends
BaseClient
Constructors
Constructor
new BatchBuilder(config: ClientConfig): BatchBuilder;
Parameters
| Parameter | Type |
|---|---|
config | ClientConfig |
Returns
BatchBuilder
Inherited from
BaseClient.constructor
Properties
| Property | Modifier | Type |
|---|---|---|
apiToken | readonly | string |
baseUrl? | readonly | string |
customFetch? | readonly | CustomFetch |
defaultVersion | readonly | ApiVersion |
Methods
execute()
execute<T>(requests: T): Promise<BatchResponseArray<T>>;
Executes multiple API requests with automatic chunking and parallel execution. Transparently handles the 10-request API limitation by splitting large batches into smaller chunks and executing them concurrently.
Type Parameters
| Type Parameter |
|---|
T extends readonly BatchRequestDescriptor<unknown>[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
requests | T | Array of batch request descriptors |
Returns
Promise<BatchResponseArray<T>>
Array of BatchResponse objects with processed data in original order
Throws
If any batch chunk fails completely
getBaseUri()
protected getBaseUri(version?: ApiVersion): string;
Gets the base URI for API requests with proper trailing slash handling. This method fixes the trailing slash bug that occurred when using custom baseUrl.
Parameters
| Parameter | Type | Description |
|---|---|---|
version? | ApiVersion | Optional API version override. Defaults to the configured version or 'v3' |
Returns
string
Base URI with guaranteed trailing slash for proper URL resolution
Inherited from
BaseClient.getBaseUri