Bitrix24 API
Project description
API client for Bitrix24
Low-level API client with multiple strategies for lists gathering. All methods support retries.
Regular call (any method)
import asyncio
from b24api import Bitrix24
async def main():
async with Bitrix24() as b24:
result = await b24.call({"method": "user.access", "parameters": {"ACCESS": ["G2", "AU"]}})
print(result)
asyncio.run(main())
Batch call (any method, no limit)
import asyncio
from b24api import Bitrix24
async def main():
async with Bitrix24() as b24:
requests = ({"method": "user.update", "parameters": {"ID": u, "UF_SKYPE": ""}} for u in range(1000))
async for result in b24.batch(requests):
print(result)
asyncio.run(main())
Gathering full list (slow)
Applicable to list methods with start=<offset> support.
Fetches list chunks one by one.
import asyncio
from b24api import Bitrix24
async def main():
async with Bitrix24() as b24:
async for item in b24.list_sequential({"method": "user.get"}):
print(item)
asyncio.run(main())
Gathering full list (faster)
Applicable to list methods with start=<offset> support.
Fetches first list chunk with regular call, then fetches other chunks with batch.
Approximately 3 times faster then list_sequential.
import asyncio
from b24api import Bitrix24
async def main():
async with Bitrix24() as b24:
async for item in b24.list_batched({"method": "user.get"}):
print(item)
asyncio.run(main())
Gathering full list (fastest)
Applicable to list methods with filter={<parameters>} support.
Fetches first and last list chunk with batch call, then fetches other chunks with batch. Doesn't use counting (start=-1).
Approximately 2 times faster then list_batched.
import asyncio
from b24api import Bitrix24
async def main():
async with Bitrix24() as b24:
async for item in b24.list_batched_no_count({"method": "user.get"}):
print(item)
asyncio.run(main())
Gathering full list with required reference
Applicable to list methods with select=[<fields>] and filter={<parameters>} support and required filter parameters.
Fetches first and last list chunk with batch call, then fetches other chunks with batch. Doesn't use counting (start=-1).
import asyncio
from b24api import Bitrix24
async def main():
async with Bitrix24() as b24:
deal_ids = [1, 2, 3] # deals IDs (e.g. from "crm.deal.list" call)
filter_updates = ({"=ENTITY_ID": i} for i in deal_ids)
items = b24.reference_batched_no_count(
{"method": "crm.timeline.comment.list", "parameters": {"filter": {"ENTITY_TYPE": "deal"}}},
filter_updates,
)
async for item in items:
print(item)
asyncio.run(main())
Gathering full list with cursor pagination per reference
Applicable to list methods that paginate via a dedicated top-level cursor parameter (LAST_ID, FIRST_ID) per reference instead of the standard >ID filter — e.g. most im.* list methods. Pagination within a single reference is strictly sequential; each round-trip fires up to batch_size requests in parallel, mixing new first-page requests with in-flight continuations as the FIFO queue rotates (so continuations may be served before later-arriving first-pages).
import asyncio
from b24api import Bitrix24
async def main():
async with Bitrix24() as b24:
dialog_ids = ["chat1", "chat2", "chat3"]
references = ({"DIALOG_ID": d} for d in dialog_ids)
items = b24.reference_cursor_no_count(
{"method": "im.dialog.messages.get", "parameters": {}},
references,
cursor_param="LAST_ID", # name of the cursor parameter the API accepts
cursor_field="id", # field in each item that holds its id
cursor_take="min", # "min" = older messages direction; "max" = newer
result_key="messages", # required for multi-key responses
)
async for item in items:
print(item)
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file b24api-1.0.0.tar.gz.
File metadata
- Download URL: b24api-1.0.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb3964b8c5b6c53538ad79040f93c2d56e03a11837ccf5d43028a3716691057f
|
|
| MD5 |
edc60246195ac6e75b240b1a0c4dba85
|
|
| BLAKE2b-256 |
bfd76ae7889074dfe9e8832e1095a80758b8536d81c74d1985805f536c522eba
|
Provenance
The following attestation bundles were made for b24api-1.0.0.tar.gz:
Publisher:
publish-to-pypi.yml on shkarupa-alex/b24api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
b24api-1.0.0.tar.gz -
Subject digest:
fb3964b8c5b6c53538ad79040f93c2d56e03a11837ccf5d43028a3716691057f - Sigstore transparency entry: 1397102543
- Sigstore integration time:
-
Permalink:
shkarupa-alex/b24api@63723bf0bede877bea5eda0ac2047da094e53658 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/shkarupa-alex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@63723bf0bede877bea5eda0ac2047da094e53658 -
Trigger Event:
push
-
Statement type:
File details
Details for the file b24api-1.0.0-py3-none-any.whl.
File metadata
- Download URL: b24api-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
194df175b18b006a9b75193e3b2915621e0aeef4b91cbc88af4857b311a26ead
|
|
| MD5 |
944ba71ba83919817165d9fe1b8a0556
|
|
| BLAKE2b-256 |
d5090f9629a75f9089d326b7b3186da86f891a5e14844148d86fb928bff491d9
|
Provenance
The following attestation bundles were made for b24api-1.0.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on shkarupa-alex/b24api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
b24api-1.0.0-py3-none-any.whl -
Subject digest:
194df175b18b006a9b75193e3b2915621e0aeef4b91cbc88af4857b311a26ead - Sigstore transparency entry: 1397102558
- Sigstore integration time:
-
Permalink:
shkarupa-alex/b24api@63723bf0bede877bea5eda0ac2047da094e53658 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/shkarupa-alex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@63723bf0bede877bea5eda0ac2047da094e53658 -
Trigger Event:
push
-
Statement type: