aiocdek - comprehensive asynchronous library for interaction with CDEK API
An asynchronous Python client library for the CDEK API. This SDK provides easy integration with CDEK delivery services, supporting all major API endpoints with type-safe models and comprehensive error handling.
Features
- Fully Asynchronous: Built with
aiohttpfor non-blocking operations - Type Safety: Complete Pydantic models for all API requests and responses
- Auto Authentication: Automatic OAuth token management with caching
- Comprehensive Coverage: Support for all major CDEK API endpoints:
- Order management (create, track, update)
- Tariff calculation and comparison
- Location and delivery point lookup
- Courier services
- Label and document printing
- Webhook management
- Error Handling: Robust error handling with detailed logging
- Easy Integration: Simple, intuitive API design
Requirements
- Python 3.9+
- aiohttp
- pydantic
- loguru
Installation
pip install aiocdek
Or install from source:
git clone https://github.com/avoidedabsence/aiocdek.git
cd aiocdek
pip install -e .
Quick Start
import asyncio
from aiocdek import CDEKAPIClient
from aiocdek.models import OrderRequest, OrderPackage, OrderSender, OrderRecipient, Location, Money
from aiocdek.enums import TariffCode
async def main():
# Initialize the client with your credentials
client = CDEKAPIClient(
client_id="your_client_id",
client_secret="your_client_secret",
test_environment=False, # If True, API URI = https://api.edu.cdek.ru/
debug=False # If True, will log success/fail for each API request
)
# Calculate delivery cost
from aiocdek.models import TariffRequest
tariff_request = TariffRequest(
type=1, # Online store
from_location=Location(code=270), # Moscow
to_location=Location(code=44), # Ekaterinburg
packages=[{
"weight": 1000, # 1kg
"length": 30,
"width": 20,
"height": 10
}]
)
tariff = await client.calculate_tariff(tariff_request)
print(f"Delivery cost: {tariff.delivery_sum} RUB")
# Create an order
order = OrderRequest(
type=1, # Online store
number="ORDER-001",
tariff_code=TariffCode.EXPRESS_DOOR_TO_DOOR,
sender=OrderSender(
name="John Doe",
phones=["+7123456789"]
),
recipient=OrderRecipient(
name="Jane Smith",
phones=["+7987654321"]
),
from_location=Location(code=270),
to_location=Location(code=44),
packages=[OrderPackage(
number="PKG-001",
weight=1000
)]
)
result = await client.create_order(order)
print(f"Order created: {result.entity.uuid}")
if __name__ == "__main__":
asyncio.run(main())
License
This project is licensed under the GNU v3.0 License - see the LICENSE file for details.
Links
Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed description
- Include code examples and error messages
Release files for aiocdek 0.1.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 | |
|---|---|---|---|
| aiocdek-0.1.7.tar.gz | 35.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiocdek-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 68.2 kB
Release files / aiocdek-0.1.7.tar.gz
| Download URL | aiocdek-0.1.7.tar.gz |
|---|---|
| Size | 35.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e0e29a4d2d71d80d0c693fd069b95355ad8d7273eabc08a44c2674016bf464e
|
|
BLAKE2b-256 checksum How to use checksums |
aee165bd1e7d1893cb6a8bca50ec5dc5f0a78002007b50939c2712ab581f1116
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Release files / aiocdek-0.1.7-py3-none-any.whl
| Download URL | aiocdek-0.1.7-py3-none-any.whl |
|---|---|
| Size | 32.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a28146ff637122d06f9092a1d1003fd6e1fc2b245a4f820ed50292cd8e97ae6
|
|
BLAKE2b-256 checksum How to use checksums |
6c111e3b09282b5c7b220cfe3427a4fda6d236b31283fc6df7a04750e270457f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|