Skip to content

Restriction Manager

Manages the request rate limitations to the Bitrix24 API. It tracks the request rate separately for each Bitrix24 account and considers the IP address from which the request is made.

TIP

You can test working with the Restriction Manager in this example.

RestrictionManager Class

Integrated into the Http class.

By default, RestrictionManagerParamsBase are used.

For Bitrix24 Enterprise editions, it is recommended to use RestrictionManagerParamsForEnterprise.

ts
import {
    B24Hook,
    RestrictionManagerParamsForEnterprise
} from '@bitrix24/b24jssdk'

const $b24 = new B24Hook({
    b24Url: 'https://your_domain.bitrix24.com',
    userId: 123,
    secret: 'k32t88gf3azpmwv3',
})

$b24.getHttpClient().setRestrictionManagerParams(
    RestrictionManagerParamsForEnterprise
)
ts
import {
    B24Hook
} from '@bitrix24/b24jssdk'

const $b24 = new B24Hook({
    b24Url: 'https://your_domain.bitrix24.com',
    userId: 123,
    secret: 'k32t88gf3azpmwv3',
})

$b24.getHttpClient().setRestrictionManagerParams({
    sleep: 600,
    speed: 0.01,
    amount: 30 * 5
})

Methods

check

ts
check(hash: string = ''): Promise<null>

Checks the possibility of executing a request without exceeding limits. If limits are exceeded, it waits.

ParameterTypeDescription
hashstringHash for logging (optional).

Constants

RestrictionManagerParamsBase

ts
import { RestrictionManagerParamsBase } from '@bitrix24/b24jssdk'

Base parameters for the restriction manager.

  • sleep: 1_000 (waiting time in milliseconds)
  • speed: 0.001 (processing speed)
  • amount: 30 (number of processed items)

RestrictionManagerParamsForEnterprise

ts
import { RestrictionManagerParamsForEnterprise } from '@bitrix24/b24jssdk'

Parameters for the restriction manager intended for use in Bitrix24 Enterprise editions.

  • sleep: 600 (waiting time in milliseconds)
  • speed: 0.01 (processing speed)
  • amount: 150 (number of processed items)

Released under the MIT License.