Skip to content

Commit 261e812

Browse files
committed
Update docs with additional examples
1 parent 48bad0b commit 261e812

File tree

4 files changed

+110
-32
lines changed

4 files changed

+110
-32
lines changed

README.md

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,75 @@ Easy way to communicate with bitrix24 portal over REST without OAuth 2.0
44

55
## Description
66

7-
Bitrix24 REST is a simple API wrapper for working with Bitrix24
8-
REST API over webhooks.
7+
Bitrix24 REST is an API wrapper for working with Bitrix24 REST API over webhooks.
8+
No OAuth 2.0 required. It's easy to use and super lightweight, with minimal dependencies.
99

1010
## Features
1111

12-
- Works both with cloud and on-premises versions of bitrix24, much more
13-
- Super easy for setting up. No OAuth implemetation required
14-
- Compatible with latests Bitrix24 REST API
15-
16-
## Requirements
17-
- Python 2.6+ or 3.2+
18-
- requests
12+
- Works with both cloud and on-premises versions of Bitrix24.
13+
- Super easy to setup. No OAuth 2.0 infrastructure required.
14+
- Built with data analysis in mind and fully compatible with Jupyter Notebook.
15+
- Fetch paginated data at once without hassle.
16+
- Works with large datasets and handles rate limits.
1917

2018
## Installation
19+
2120
```
2221
pip install bitrix24-rest
2322
```
2423

2524
## Quickstart
2625

2726
```python
28-
from bitrix24 import *
27+
from bitrix24 import Bitrix24
2928

3029
bx24 = Bitrix24('https://example.bitrix24.com/rest/1/33olqeits4avuyqu')
3130

3231
print(bx24.callMethod('crm.product.list'))
3332
```
3433

35-
## Advanced usage
36-
37-
You can define filters and additional parameters in any order:
34+
In async mode:
3835

3936
```python
40-
bx24.callMethod('crm.deal.list',
41-
order={'STAGE_ID': 'ASC'},
42-
filter={'>PROBABILITY': 50},
43-
select=['ID', 'TITLE', 'STAGE_ID', 'PROBABILITY'])
44-
```
37+
import asyncio
38+
from bitrix24 import bitrix24
4539

46-
Catch the server error with exception:
40+
async def main():
41+
bx24 = Bitrix24('https://example.bitrix24.com/rest/1/33olqeits4avuyqu')
42+
result = await bx24.callMethod('crm.product.list')
43+
print(result)
4744

48-
```python
49-
try:
50-
bx24.callMethod('tasks.task.add', fields={'TITLE': 'task for test', 'RESPONSIBLE_ID': 1})
51-
except BitrixError as message:
52-
print(message)
45+
asyncio.run(main())
5346
```
5447

48+
## Advanced usage
49+
50+
- [Using filters and additional parameters](docs/using-filters-and-additional-parameters.md)
51+
- [Working with large datasets](docs/working-with-large-datasets.md)
52+
- [Disabling certificate verification](docs/disabling-certificate-verification.md)
53+
5554
## Notes
56-
List methods return all available items at once. For large collections
57-
of data use limits.
5855

59-
## Tests
56+
List methods return all available items at once. For large collections of data use limits.
6057

58+
## Development
59+
60+
New contributers and pull requests are welcome. If you have any questions or suggestions, feel free to open an issue.
61+
62+
Code comes with makefile for easy code base management. You can check `make help` for more details.
63+
64+
```sh
65+
make init install # to create a local virtual environment and install dependencies
66+
67+
make test # to run tests
68+
69+
make lint # to run linter
6170
```
62-
python -m unittest discover
63-
```
6471

65-
## Author
72+
I suggest to use `make all` before committing your changes as it will run all the necessary checks.
73+
74+
## Support this project
6675

67-
Akop Kesheshyan - <akop.kesheshyan@icloud.com>
76+
You can support this project by starring ⭐, sharing 📤, and contributing.
6877

69-
New contributers and pull requests are welcome.
78+
You can also support the author by buying him a coffee ☕. Click sponsor button on the top of the page.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Disabling certificate verification
2+
3+
By default, the library verifies SSL certificates. If you want to disable this behavior, you can set `safe` parameter to `False` in the `Bitrix24` class.
4+
5+
This tells Python's underlying SSL handling to accept the server's certificate even if it's expired or invalid.
6+
7+
```python
8+
bx24 = Bitrix24('https://example.bitrix24.com/rest/1/33olqeits4avuyqu', safe=False)
9+
10+
await bx24.callMethod('crm.deal.list')
11+
```
12+
13+
## Important Consideration
14+
15+
Disabling SSL certificate verification undermines the security of HTTPS by making your application vulnerable to man-in-the-middle attacks.
16+
17+
It should only be used in controlled environments, such as development or testing, where security is not a concern.
18+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Using filters and additional parameters
2+
3+
Define filters and additional parameters in any order using keyword arguments.
4+
5+
```python
6+
bx24 = Bitrix24('https://example.bitrix24.com/rest/1/33olqeits4avuyqu')
7+
8+
await bx24.callMethod('crm.deal.list',
9+
order={'STAGE_ID': 'ASC'},
10+
filter={'>PROBABILITY': 50},
11+
select=['ID', 'TITLE', 'STAGE_ID', 'PROBABILITY'])
12+
```
13+
14+
You also can pass filters as a dictionary, similar to the original Bitrix24 API:
15+
16+
````python
17+
18+
payload = {
19+
'order': {'STAGE_ID': 'ASC'},
20+
'filter': {'>PROBABILITY': 50},
21+
'select': ['ID', 'TITLE', 'STAGE_ID', 'PROBABILITY']
22+
}
23+
24+
await bx24.callMethod('crm.deal.list', payload)
25+
26+
````

docs/working-with-large-datasets.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Working with large datasets
2+
3+
Fetching large datasets can be a problem. Bitrix24 REST API has a limit of 50 items per request and a rate limiter
4+
that can block your requests if you exceed the limit.
5+
6+
This library has a built-in feature to handle large datasets without any hassle.
7+
It will automatically detect if the dataset is paginated and fetch all the data at once.
8+
9+
Also, all requests are made concurrently, which means you can fetch data faster and with low resource usage.
10+
11+
However, if you for any reason want to disable this feature, you can do so by setting the `fetch_all_pages` parameter to `False`.
12+
13+
14+
```python
15+
16+
bx24 = Bitrix24('https://example.bitrix24.com/rest/1/33olqeits4avuyqu', fetch_all_pages=False)
17+
18+
# `page1` will contain only the first page of the dataset
19+
page1 = await bx24.callMethod('crm.deal.list')
20+
21+
# fetch next page
22+
page2 = await bx24.callMethod('crm.deal.list', start=50)
23+
```
24+
25+
In this mode, you will need to handle pagination manually.

0 commit comments

Comments
 (0)