Unofficial Python SDK for Vitesy APIs
Project description
Vitesy Python SDK
An unofficial Python SDK for interacting with the Vitesy API platform.
Disclaimer
This is an unofficial SDK and is not affiliated with, maintained, authorized, endorsed, or sponsored by Vitesy or any of its affiliates. This is an independent and unofficial project. All product and company names are trademarks™ or registered® trademarks of their respective holders.
Installation
pip install vitesy-python-unofficial
Usage
Initialize the Client
from vitesy import VitesyClient
# Initialize with default language (English)
client = VitesyClient(api_key='your_api_key')
# Or initialize with a specific language
client = VitesyClient(api_key='your_api_key', language='it')
Available Endpoints
Get Devices
# Get devices for the authenticated user
devices = client.get_devices()
# Get devices for a specific user
devices = client.get_devices(user_id="user-id")
# Get devices for a specific place
devices = client.get_devices(place_id="place-id")
# Get devices with expanded information
devices = client.get_devices(
expand=["goal", "place", "plant"]
)
Get Device Details
device = client.get_device("device-id")
Get Sensors
# Get all sensors
sensors = client.get_sensors()
# Get sensors with specific language
sensors = client.get_sensors(language="it")
Query Measurements
from datetime import datetime, timedelta
# Get latest measurements for a device
measurements = client.query_measurements(
device_id="device-id",
latest=True
)
# Get hourly measurements for the last 24 hours
end_date = datetime.utcnow()
start_date = end_date - timedelta(days=1)
measurements = client.query_measurements(
device_id="device-id",
from_date=start_date,
to_date=end_date,
group_by="hour"
)
# Get measurements for a specific place
measurements = client.query_measurements(
place_id="place-id",
group_by="day"
)
Error Handling
from vitesy import VitesyError, AuthenticationError, APIError
try:
devices = client.get_devices()
except AuthenticationError:
print("Invalid API key")
except APIError as e:
print(f"API error {e.status_code}: {e.message}")
except VitesyError as e:
print(f"General error: {str(e)}")
Development
- Clone the repository:
git clone https://github.com/yourusername/vitesy-python-sdk.git
cd vitesy-python-sdk
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install development dependencies:
pip install -e ".[dev]"
- Run tests:
pytest
Publishing to PyPI
- Build the package:
python -m pip install --upgrade build
python -m build
- Upload to TestPyPI (optional):
python -m pip install --upgrade twine
python -m twine upload --repository testpypi dist/*
- Upload to PyPI:
python -m twine upload dist/*
Testing
The SDK includes both unit tests and integration tests.
Running Unit Tests
Unit tests can be run without any API credentials:
pytest -m "not integration"
Running Integration Tests
Integration tests require valid API credentials. To run them:
- Set your API key as an environment variable:
export VITESY_API_KEY="your-api-key"
- Run the integration tests:
pytest tests/integration/
Or run all tests (both unit and integration):
pytest
Test Structure
tests/test_client.py: Unit tests for the clienttests/integration/test_integration.py: Integration tests with the actual APItests/conftest.py: Shared test fixtures and configuration
The test suite uses pytest and includes:
- Basic client initialization tests
- API endpoint tests with mocked responses
- Error handling tests
- Integration tests with the actual API
- Language support tests
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vitesy_python_unofficial-0.1.0.tar.gz.
File metadata
- Download URL: vitesy_python_unofficial-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f2ad82e2ecbd58cb810711a36246d15b046190fb2d9cb4b57f59b45ac9594a3
|
|
| MD5 |
a140771294558792717e8092dc9ae071
|
|
| BLAKE2b-256 |
7ff28b6d27e496c0d41aa224d5f2e47b5d736bab0f7371efa101c1241d59b326
|
File details
Details for the file vitesy_python_unofficial-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vitesy_python_unofficial-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b35bdc56bc0c69b03687468517f72669a36007c324c587878a6deda2e88e927
|
|
| MD5 |
124e0530663b7f2e85849cff7d2ecf0b
|
|
| BLAKE2b-256 |
6e6861d41acfe403ba3b0390ec7fc6db38ce85b5829371c3374f44dee10a95bf
|