api-client-python/README.md

77 lines
1.8 KiB
Markdown
Raw Normal View History

2020-12-18 01:04:43 +03:00
[![Build Status](https://github.com/retailcrm/api-client-python/workflows/ci/badge.svg)](https://github.com/retailcrm/api-client-python/actions)
[![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/api-client-python/master.svg?logo=codecov&logoColor=white)](https://codecov.io/gh/retailcrm/api-client-python)
[![PyPI](https://img.shields.io/pypi/v/retailcrm.svg?logo=pypi&logoColor=white)](https://pypi.python.org/pypi/retailcrm)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/retailcrm.svg?logo=python&logoColor=white)](https://pypi.python.org/pypi/retailcrm)
RetailCRM python API client
2016-03-17 00:54:42 +03:00
===========================
2014-09-11 11:16:44 +04:00
2020-12-15 13:31:30 +03:00
This is Python RetailCRM API client. This library allows to use all available API versions.
## Install
2015-03-12 16:08:55 +03:00
```
2021-09-08 16:28:10 +03:00
pip3 install retailcrm
2015-03-12 16:08:55 +03:00
```
## Usage
#### API version 3 order create
2015-03-12 16:08:55 +03:00
```python
# coding utf-8
2016-03-17 00:54:42 +03:00
import retailcrm
2015-03-12 16:08:55 +03:00
client = retailcrm.v3('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
2015-03-12 16:08:55 +03:00
order = {
'firstName': 'John',
'lastName': 'Doe',
2015-03-12 16:08:55 +03:00
'phone': '+79000000000',
'email': 'john@example.com',
2015-03-12 16:08:55 +03:00
'orderMethod': 'call-request',
}
result = client.order_create(order)
```
#### API version 4 customers history
```python
# coding utf-8
import retailcrm
client = retailcrm.v4('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
result = client.customers_history(filters={'sinceId': '1500', 'startDate': '2018-03-01'})
print(result['pagination']['totalCount'])
```
#### API version 5 task create
```python
# coding utf-8
import retailcrm
client = retailcrm.v5('https://demo.retailcrm.pro', 'uLxXKBwjQteE9NkO3cJAqTXNwvKktaTc')
site = 'example-com'
task = {
'text': 'Product availability problem',
'commentary': 'Take a look ASAP',
'order': {
'externalId': '100500'
},
'performerId': 1
}
result = client.task_create(task, site)
2015-03-12 16:08:55 +03:00
```