CDEK-API
Описание
Библиотека упрощающая работу с API службы доставки СДЭК.
Установка
Для работы требуется Python 3.6+ Для установки используйте pipenv (или pip):
$ pipenv install fs-cdek-api
$ pip install fs-cdek-api
Примеры
Запрос доставки
delivery_request = DeliveryRequest(number='12345678')
order = delivery_request.add_order(
number=randint(100000, 1000000),
recipient_name='Иванов Иван Иванович',
phone='+79999999999',
send_city_post_code='680000',
rec_city_post_code='680000',
seller_name='Магазин',
comment='Товар',
tariff_type_code=138,
shipping_price=300.0,
)
delivery_request.add_address(order, pvz_code='XAB1')
package = delivery_request.add_package(
order_element=order,
size_a=10,
size_b=10,
size_c=10,
number=randint(100000, 1000000),
barcode=randint(100000, 1000000),
weight=600,
)
delivery_request.add_item(
package_element=package,
weight=500,
cost=1000,
ware_key='12345678',
comment='Товар',
)
cdek_client = CDEKClient('login', 'pass')
delivery_orders = cdek_client.create_orders(delivery_request)
Удаление заказа
Условием возможности удаления заказа является отсутствие движения груза на складе СДЭК (статус заказа «Создан»).
delete_requests = cdek_client.delete_orders(
act_number=act_number,
dispatch_numbers=[dispatch_number],
)
Вызов курьера для забора груза ИМ
dispatch_number = order['DispatchNumber']
next_day = datetime.date.today() + datetime.timedelta(days=1)
call_courier = CallCourier()
call_request = call_courier.add_call(
date=next_day,
dispatch_number=dispatch_number,
sender_phone='+79999999999',
time_begin=datetime.time(hour=10),
time_end=datetime.time(hour=17),
lunch_begin=datetime.time(hour=13),
lunch_end=datetime.time(hour=14),
)
call_courier.add_address(
call_element=call_request,
address_street='Пушкина',
address_house='50',
address_flat='1',
)
call = cdek_client.call_courier(call_courier)
Информация о заказах
dispatch_number = order['DispatchNumber']
info = cdek_client.get_orders_info([dispatch_number])
Статусы заказов
dispatch_number = order['DispatchNumber']
info = cdek_client.get_orders_statuses([dispatch_number])
Печать накладной
Возврщает pdf документ в случае успеха.
order_print = cdek_client.get_orders_print([dispatch_number])
Печать ШК-мест
Возврщает pdf документ в случае успеха.
barcode_print = cdek_client.get_barcode_print([dispatch_number])
Список регионов
regions = cdek_client.get_regions(region_code_ext=27)
Список городов
cities = cdek_client.get_cities(region_code_ext=27)
Список ПВЗ
pvz_list = cdek_client.get_delivery_points(city_post_code=680000)['pvz']
Расчет стоимости доставки
shipping_costs = cdek_client.get_shipping_cost(
sender_city_id=270,
receiver_city_id=44,
goods=[
{'weight': 0.3, 'length': 10, 'width': 7, 'height': 5},
{'weight': 0.1, 'volume': 0.1},
],
tariff_id=3,
)
Создание преалерта
next_day = datetime.date.today() + datetime.timedelta(days=1)
pre_alert_element = PreAlert(planned_meeting_date=next_day, pvz_code='XAB1')
pre_alert_element.add_order(dispatch_number=dispatch_number)
pre_alerts = cdek_client.create_prealerts(pre_alert_element)
Metadata
Release files for fs-cdek-api 1.4.1
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 |
|---|---|---|---|---|
| fs-cdek-api-1.4.1.tar.gz | 13.3 kB | Without provenance | Details for fs-cdek-api-1.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fs_cdek_api-1.4.1-py3-none-any.whl | Python 3 | none | any | Details for fs_cdek_api-1.4.1-py3-none-any.whl |
Total release size: 25.8 kB
Release files / fs-cdek-api-1.4.1.tar.gz
| Download URL | fs-cdek-api-1.4.1.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
973b92d7376ba1ac6e7c4dbb559da511f80f3020710b62876d25b4cde93271b9
|
|
BLAKE2b-256 checksum How to use checksums |
6d595cfbcbe04c9c9f92f614ccb9c486757e7bbf90e3a9dc085ad4b2367e0b56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1
|
Release files / fs_cdek_api-1.4.1-py3-none-any.whl
| Download URL | fs_cdek_api-1.4.1-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6bf91d17182f31be233993c94db69297198437a07e7dcfcb41f4ffa4cca7a67
|
|
BLAKE2b-256 checksum How to use checksums |
29e05a48f0c973aefaa994749c9df36643811b2879828a4ac0f508d0d29c8c47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.1
|
Security for fs-cdek-api 1.4.1
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.