Metadata-Version: 2.4
Name: ezviz-openapi-utils
Version: 0.1.1
Summary: A Python library for the EZVIZ OpenAPI platform, handling authentication and API requests.
Author-email: SunBo <1443584939@qq.com>
Project-URL: Homepage, https://github.com/sunbos/ezviz-openapi-utils
Project-URL: Bug Tracker, https://github.com/sunbos/ezviz-openapi-utils/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: python-dotenv; extra == "dev"
Dynamic: license-file

# EZVIZ OpenAPI Utils

[简体中文](README.zh-CN.md) | English

A Python library designed to simplify interactions with the EZVIZ OpenAPI platform. It handles authentication, automatic token refreshing, and provides a clean, unified interface for all API endpoints.

## ✨ Key Features

- **Automatic Token Management**: The client automatically handles Access Token expiration and renewal, requiring no manual intervention from the user.
- **Multi-Region Support**: Fully supports all 8 global regions (cn, en, eu, us, sa, sg, in, ru), ensuring compatibility worldwide.
- **Type Safe**: Uses `TypedDict` for API responses, providing excellent IDE support and code completion for developers.
- **Clean Architecture**: Clearly separates concerns: `Client` handles authentication, and `EZVIZOpenAPI` handles API calls, resulting in a codebase that is easy to understand and maintain.

## 📦 Installation

First, install the core dependency `requests`.

```bash
pip install requests
```

*(Note: This project uses `pyproject.toml` for dependency management. For a full development environment, use `pip install -e .[dev]`.)*

## 🚀 Getting Started

```python
from ezviz_openapi_utils import Client, EZVIZOpenAPI

# 1. Create a client instance (automatically fetches the access token)
client = Client(
    app_key="YOUR_APP_KEY",
    app_secret="YOUR_APP_SECRET",
    region="cn"  # Specify your region
)

# 2. Create an API instance
api = EZVIZOpenAPI(client)

# Add a device
add_device_response = api.add_device(device_serial="427734888", validate_code="ABCDEF")
print(add_device_response)
# Output: {'code': '200', 'msg': 'Operation succeeded!'}

# Get device information
device_info_response = api.get_device_info(device_serial="427734888")
print(device_info_response)
# Output: {'data': {'deviceSerial': '427734888', 'deviceName': 'niuxiaoge device', 'model': 'CS-C1-11WPFR', 'status': 0, 'defence': 1, 'isEncrypt': 0}, 'code': '200', 'msg': 'Operating succeeded!'}

# Delete a device
delete_response = api.delete_device(device_serial="427734888")
print(delete_response)
# Output: {'code': '200', 'msg': 'Operation succeeded!'}
```
