Skip to main content

Python Library with easy API for Bitrix24 REST

Project description

easy-bitrix

easy-bitrix is a universal Python library for working with the Bitrix24 REST API. It supports asynchronous requests, OAuth authentication, convenient CRM object management, and Pythonic query building for Bitrix24.

Features

  • Asynchronous and synchronous requests to Bitrix24 REST API
  • OAuth authentication support
  • Convenient classes for CRM entities: Deal, Contact, and more
  • Flexible filtering, selection, and ordering
  • Easy integration and extension for your projects

Installation

pip install easy-bitrix

Quick Start

Get a list of deals

Example from main.py:

from easy_bitrix.bitrix import Bitrix24
from easy_bitrix.options import RequestOptions
from easy_bitrix.bitrix_objects import Deal
from easy_bitrix.operations import FilterOperation, OrderOperations

site_name = 'bitrix_portal'
user_id = '1'
webhook = 'webhook'

def main():
    options = RequestOptions(user_id=user_id, webhook_url=webhook, high_level_domain='ru')
    bitrix = Bitrix24(bitrix_address=site_name)
    response = bitrix.request(param=Deal.get_list(
        select=[Deal.ID, Deal.TITLE, Deal.DATE_CREATE],
        filter=[FilterOperation.END_LIKE(Deal.SET_TITLE('_like'))],
        order=[OrderOperations.DESCENDING_ORDER(Deal.DATE_CREATE)],
    ), options=options)
    print(f'Status is: {response.code}\nResponse is: {response.data}")

main()

Asynchronous requests

import asyncio
from easy_bitrix.bitrix import Bitrix24
from easy_bitrix.options import RequestOptions
from easy_bitrix.bitrix_objects import Deal

async def main():
    options = RequestOptions(user_id='1', webhook_url='webhook', high_level_domain='ru')
    bitrix = Bitrix24('bitrix_portal')
    data = Deal.create(fields=[
        Deal.SET_TITLE('New Deal'),
        Deal.SET_OPPORTUNITY(10000),
        Deal.SET_TYPE_ID('SALE'),
        Deal.SET_STAGE_ID('NEW')
    ])
    result, status = await bitrix.request_async(param=data, options=options)
    print(f'Status: {status}\nResponse: {result}')

asyncio.run(main())

OAuth authentication

from easy_bitrix.oauth import OAuth

assess_token = OAuth.get_access_token(
    client_id=client_id,
    client_secret=client_secret,
    code=code,
)
print(assess_token)

Main Classes

  • Bitrix24 — main class for API interaction
  • Deal, Contact — classes for CRM objects
  • RequestOptions — connection parameters
  • FilterOperation, OrderOperations — filtering and ordering operations

Documentation

License

MIT License

Copyright (c) 2024 Alex Pavlov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easy_bitrix-0.1.12.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easy_bitrix-0.1.12-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file easy_bitrix-0.1.12.tar.gz.

File metadata

  • Download URL: easy_bitrix-0.1.12.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for easy_bitrix-0.1.12.tar.gz
Algorithm Hash digest
SHA256 f8ef1825cbe3fea5c2baea8ca3ca6eb570fae16a564dfca701a122fa72acf2ae
MD5 6befb04ff16a033063cc1f5c4acbb70a
BLAKE2b-256 a7db3995f568eedfc0b8efe49c23191d9d8060780e6deb4e0f8f92ecf8d3a8f6

See more details on using hashes here.

File details

Details for the file easy_bitrix-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: easy_bitrix-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for easy_bitrix-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 d358b9c10b47c12f3ea68835fbedf70ef0ee8cd628c6335a1467913f9ce02ed8
MD5 8ab392f12d1d3bf0721062afb53180a7
BLAKE2b-256 439fd43097afcf3fc84d93e7c2999c23cbf0a69d2cd453c5bb956034d5092435

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page