B24Hook.callFastListMethod
B24Hook.callFastListMethod() to quickly fetch all list items from the Bitrix24 REST API. The method automatically performs all necessary requests to retrieve the complete dataset using an optimized approach that does not count the total number of items, significantly speeding up the process when working with large data volumes. Works only in server environment.B24Hook object is intended exclusively for use on the server.- A webhook contains a secret access key, which MUST NOT be used in client-side code (browser, mobile app).
- For the client side, use
B24Frame.
B24Hook.callListMethod() method is deprecated. Use the B24Hook.callFastListMethod() method instead.Quick Overview
Use callFastListMethod to quickly fetch all data from methods that return lists. The method uses an optimized approach without counting the total number of items, which significantly speeds up request execution when working with large data volumes.
The method returns a Promise that resolves to a Result object containing the complete array of retrieved data.
// Basic usage
import { B24Hook } from '@bitrix24/b24jssdk'
const $b24 = B24Hook.fromWebhookUrl('https://your_domain.bitrix24.com/rest/1/webhook_code/')
const response = await $b24.callFastListMethod('crm.item.list', {
entityTypeId: 2, // Entity type ID (e.g., 2 for Company)
select: ['id', 'title']
}, 'id', 'items')
Method Signature
callFastListMethod<T = unknown>(
method: string,
params?: {
order?: any
filter?: any
[key: string]: any
},
idKey?: string,
customKeyForResult?: string | null
): Promise<Result<T[]>>
Parameters
Return Value
Promise<Result<T[]>> — a promise that resolves to a Result object containing the complete array of items of type T. This object provides:
.getData(): T[]— returns the complete array of all retrieved data..isSuccess: boolean— a flag indicating the successful execution of all requests..getErrorMessages(): string[]— an array of error messages.
Key Concepts
Optimized pagination without counting
callFastListMethod uses a special optimization for quickly retrieving large data volumes:
- Disabling total count: Uses the
start: -1parameter, which disables the calculation of the total number of items, significantly speeding up request execution. - Filtering by ID: After receiving each page of data, the method updates the filter, adding a condition
'>ID': lastIdto get the next batch of data. - Automatic completion: The process continues until an empty response is received.
Important Limitations
- Mandatory sorting by ID: The method requires that the sorting order by the ID field be specified in the parameters (e.g.,
order: { id: 'asc' }). This is necessary for the filtering to work correctly.
Error Handling
Always check the result using isSuccess and handle errors.
const response = await $b24.callFastListMethod('some.method', {}, 'id', 'items')
if (!response.isSuccess) {
// Handling API error
console.error(new Error(`API Error: ${response.getErrorMessages().join('; ')}`))
return
}
// Working with a successful result
const data = response.getData()
Examples
Getting all companies with filtering
Retrieving all deals with a specific stage and stage change date
Getting all tasks and grouping them by responsible person
Alternatives and Recommendations
- For step-by-step streaming processing of very large lists: Use
fetchListMethod. Returns an async generator that yields data page by page, allowing processing to start before the entire list is loaded and saving memory. - For batch operations: Use
callBatchto execute up to 50 commands in a single request. - For working with the legacy
callListMethod: Migrate tocallFastListMethod, as it is more optimized and the recommended replacement. - When you need the total item count: Use the regular
callMethodwith manual pagination, ascallFastListMethoddoes not count the total. - On the client (browser): Use the built-in
B24Frameobject instead ofB24Hook.
References
- Result — Documentation for the result object.
- Official Bitrix24 REST API Documentation — Reference for all available methods.
- Working with Large Volumes of Data — Recommendations for optimizing code to retrieve large data.
callMethod
The primary method for executing Bitrix24 REST API calls via webhook. Allows calling any REST API method with specified parameters. Works only in a server environment. Works only in server environment.
fetchListMethod
Use `B24Hook.fetchListMethod()` for step-by-step stream processing of very large data lists. It returns an asynchronous generator that fetches data page by page, allowing processing to begin before the entire list has finished loading and conserving memory. It doesn