EZVIZ OpenAPI Utils
简体中文 | 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
TypedDictfor API responses, providing excellent IDE support and code completion for developers. - Clean Architecture: Clearly separates concerns:
Clienthandles authentication, andEZVIZOpenAPIhandles API calls, resulting in a codebase that is easy to understand and maintain.
📦 Installation
Install the package:
pip install ezviz-openapi-utils
This will install the package along with its core dependency requests.
(Note: For development, clone the repository and use pip install -e .[dev] to include dev dependencies.)
🧪 Testing
Setup
Create a .env file in the repository root with your EZVIZ credentials:
EZVIZ_APP_KEY=your_app_key_here
EZVIZ_APP_SECRET=your_app_secret_here
Running Tests
# Run all tests
pytest
# Run specific test file
pytest tests/test_client.py
# Tests automatically skip integration tests if credentials are not configured
🚀 Getting Started
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!'}
🛡️ Error Handling
The library provides custom exceptions for different error scenarios:
from ezviz_openapi_utils import Client, EZVIZOpenAPI
from ezviz_openapi_utils.exceptions import EZVIZAuthError, EZVIZAPIError
client = Client(app_key="YOUR_APP_KEY", app_secret="YOUR_APP_SECRET", region="cn")
api = EZVIZOpenAPI(client)
try:
response = api.add_device(device_serial="427734888", validate_code="ABCDEF")
print(f"Success: {response}")
except EZVIZAuthError as e:
print(f"Authentication error: {e.code} - {e.message}")
except EZVIZAPIError as e:
print(f"API error: {e.code} - {e.message}")
except Exception as e:
print(f"Unexpected error: {e}")
🔒 Security
- Never commit credentials: Keep your
EZVIZ_APP_KEYandEZVIZ_APP_SECRETout of version control - Use environment variables: Store credentials in
.envfile (ensure.gitignoreincludes.env) - Regular rotation: Rotate your API credentials periodically for security
- Least privilege: Use API keys with minimal required permissions
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details on how to set up the development environment, run tests, and submit pull requests.
If you find a bug or have a feature request, please open an issue.
Metadata
Release files for ezviz-openapi-utils 0.3.4
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 |
|---|---|---|---|---|
| ezviz_openapi_utils-0.3.4.tar.gz | 54.5 kB | With provenance | Details for ezviz_openapi_utils-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ezviz_openapi_utils-0.3.4-py3-none-any.whl | Python 3 | none | any | Details for ezviz_openapi_utils-0.3.4-py3-none-any.whl |
Total release size: 92.5 kB
Release files / ezviz_openapi_utils-0.3.4.tar.gz
| Download URL | ezviz_openapi_utils-0.3.4.tar.gz |
|---|---|
| Size | 54.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0021b5a1c6d9e3a65e71a3b6ae5122b2a4edddb6833d5f797791f115e877acc
|
|
BLAKE2b-256 checksum How to use checksums |
71ef2f502a3725ecdcaa786ad0c85de206fba9ac16a9f83b3d9d7351e57853c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logRelease files / ezviz_openapi_utils-0.3.4-py3-none-any.whl
| Download URL | ezviz_openapi_utils-0.3.4-py3-none-any.whl |
|---|---|
| Size | 38.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ef2e82f7b32de5a1a9bacc24923150861dcce35566a4b2145b65682968e234c
|
|
BLAKE2b-256 checksum How to use checksums |
0aa577614d4e377ec3c623d8eaa38d0ed2d222b4c65b5066845e395575f507ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logSecurity for ezviz-openapi-utils 0.3.4
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ezviz_openapi_utils-0.3.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logA 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.