PyBitrix
PyBitrix is my lightweight implementation of Bitrix 24 REST API wrapper that I use in my own applications/integrations
Requirements
- Python 3.6+
- requests
- aiohttp
Quick start
Install package from pip
pip3 install pybitrix
Then create PyBitrix instance
from pybitrix import PyBitrix
# for webhook usage
webhook = "https://You/hook from/bitrix/developers panel/"
b24 = PyBitrix(inbound_hook=webhook)
# for use as application (with tokens)
domain = "BX DOMAIN (eg. some-stuff.bitrix.ru). Can be taken from bitrix request to your app"
auth_id = "ACCESS_TOKEN_TAKEN_FROM_BITRIX_REQUEST_TO_YOUR_APP"
refresh_id = "REFRESH_TOKEN_TAKEN_FROM_BITRIX_REQUEST_TO_YOUR_APP"
app_id = "APP_ID_FROM_MARKETPLACE_OR_LOCAL_APP_INSTALLATION"
app_secret = "SECRET_KEY_FROM_MARKETPLACE_OR_LOCAL_APP_INSTALLATION"
b24 = PyBitrix(domain=domain, access_token=auth_id, refresh_token=refresh_id, app_id=app_id, app_secret=app_secret)
Make call
bx24.call('crm.contact.list', {
'order': ['DSC'],
'select': ['TITLE', 'DATE_CREATE'],
'filter': {"<ID": 50}
})
Make batch call
batch={
'contacts': 'crm.contact.list',
'deals': 'crm.deal.list'
}
batchParams={
'contacts': [
'select[]=TITLE',
'order[ID]=DSC',
'filter[>ID]=15'
], 'deals' : [
'select[]=TITLE',
'select[]=STAGE_ID'
]
}
response = bx24.callBatch(batch=batch, batchParams=batchParams)
print("CONTACTS: {}".format(response['result']['result']['contacts']))
print("DEALS: {}".format(response['result']['result']['deals']))
Renew tokens
PyBitrix refreshes tokens automatically, but if you want to do this manually, you should call method refresh_tockens()
bx24.refresh_tokens()
asyncio + aiohttp
To use async version, you need to just import PyBitrixAsync
from pybitrix import PyBitrixAsync
b24 = PyBitrixAsync(...)
result = await b24(...)
Todos
- More comfortable batchParams collector
- Fast lists uploading via
'start': -1
License
MIT
Metadata
Release files for PyBitrix 1.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyBitrix-1.2.7.tar.gz | 5.3 kB | Without provenance | Details for PyBitrix-1.2.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyBitrix-1.2.7-py3-none-any.whl | Python 3 | none | any | Details for PyBitrix-1.2.7-py3-none-any.whl |
Total release size: 11.9 kB
Release files / PyBitrix-1.2.7.tar.gz
| Download URL | PyBitrix-1.2.7.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
546713b0b52ccb6f317fd45883a9b84cd82974a46f04dcc63d605dfe1e06ce12
|
|
BLAKE2b-256 checksum How to use checksums |
6bba291e69039cedd608164d2529f4082f64d121fe364db47a6502a0f2b976b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / PyBitrix-1.2.7-py3-none-any.whl
| Download URL | PyBitrix-1.2.7-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c07e5c1d4966ab176fbe2ca44082c9f736fd59ea465967ed3bdbf5e54838a23
|
|
BLAKE2b-256 checksum How to use checksums |
40058a9223d5024e51580cd7e125edb41fed7c7cfd3a0f005e053400c3930e0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Security for PyBitrix 1.2.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.