Metadata-Version: 2.4
Name: aiocdek
Version: 0.1.6
Summary: An asynchronous Python client library for the CDEK API
Project-URL: Homepage, https://github.com/avoidedabsence/aiocdek
Project-URL: Repository, https://github.com/avoidedabsence/aiocdek.git
Project-URL: Documentation, https://github.com/avoidedabsence/aiocdek/blob/main/docs/API_REFERENCE.md
Project-URL: Bug Tracker, https://github.com/avoidedabsence/aiocdek/issues
Author-email: "Alexey P." <i@apechenin.ru>
License-Expression: GPL-3.0
License-File: LICENSE
Keywords: api,async,cdek,courier,delivery,logistics,russia,shipping
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Office/Business
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: aiohttp>=3.8.0
Requires-Dist: build>=1.3.0
Requires-Dist: loguru>=0.6.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == 'dev'
Requires-Dist: build>=0.10.0; extra == 'dev'
Requires-Dist: flake8>=6.0.0; extra == 'dev'
Requires-Dist: isort>=5.12.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: twine>=4.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# aiocdek - comprehensive asynchronous library for interaction with CDEK API

![Python](https://img.shields.io/badge/python-3.9+-blue.svg)
![License](https://img.shields.io/badge/license-GNUv3.0-green.svg)

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 `aiohttp` for 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

```bash
pip install aiocdek
```

Or install from source:

```bash
git clone https://github.com/avoidedabsence/aiocdek.git
cd aiocdek
pip install -e .
```

## Quick Start

```python
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](LICENSE) file for details.

## Links

- [CDEK API Documentation](https://api.cdek.ru/)
- [PyPI Package](https://pypi.org/project/aiocdek/)

## Support

If you encounter any issues or have questions:

1. Check the [Issues](https://github.com/avoidedabsence/aiocdek/issues) page
2. Create a new issue with detailed description
3. Include code examples and error messages
