# 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
```bash
pip install vitesy-python-unofficial
```
## Usage
### Initialize the Client
```python
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
```python
# 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
```python
device = client.get_device("device-id")
```
#### Get Sensors
```python
# Get all sensors
sensors = client.get_sensors()
# Get sensors with specific language
sensors = client.get_sensors(language="it")
```
#### Query Measurements
```python
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
```python
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
1. Clone the repository:
```bash
git clone https://github.com/yourusername/vitesy-python-sdk.git
cd vitesy-python-sdk
```
2. Create a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install development dependencies:
```bash
pip install -e ".[dev]"
```
4. Run tests:
```bash
pytest
```
### Publishing to PyPI
1. Build the package:
```bash
python -m pip install --upgrade build
python -m build
```
2. Upload to TestPyPI (optional):
```bash
python -m pip install --upgrade twine
python -m twine upload --repository testpypi dist/*
```
3. Upload to PyPI:
```bash
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:
```bash
pytest -m "not integration"
```
### Running Integration Tests
Integration tests require valid API credentials. To run them:
1. Set your API key as an environment variable:
```bash
export VITESY_API_KEY="your-api-key"
```
2. Run the integration tests:
```bash
pytest tests/integration/
```
Or run all tests (both unit and integration):
```bash
pytest
```
### Test Structure
- `tests/test_client.py`: Unit tests for the client
- `tests/integration/test_integration.py`: Integration tests with the actual API
- `tests/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.
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/vitesy-python-unofficial",
"name": "vitesy-python-unofficial",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "vitesy, api, sdk, unofficial",
"author": "Your Name",
"author_email": "Your Name <your.email@example.com>",
"download_url": "https://files.pythonhosted.org/packages/7f/f2/8b6d27e496c0d41aa224d5f2e47b5d736bab0f7371efa101c1241d59b326/vitesy_python_unofficial-0.1.0.tar.gz",
"platform": null,
"description": "# Vitesy Python SDK\n\nAn unofficial Python SDK for interacting with the Vitesy API platform.\n\n## Disclaimer\n\nThis 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\u2122 or registered\u00ae trademarks of their respective holders.\n\n## Installation\n\n```bash\npip install vitesy-python-unofficial\n```\n\n## Usage\n\n### Initialize the Client\n\n```python\nfrom vitesy import VitesyClient\n\n# Initialize with default language (English)\nclient = VitesyClient(api_key='your_api_key')\n\n# Or initialize with a specific language\nclient = VitesyClient(api_key='your_api_key', language='it')\n```\n\n### Available Endpoints\n\n#### Get Devices\n\n```python\n# Get devices for the authenticated user\ndevices = client.get_devices()\n\n# Get devices for a specific user\ndevices = client.get_devices(user_id=\"user-id\")\n\n# Get devices for a specific place\ndevices = client.get_devices(place_id=\"place-id\")\n\n# Get devices with expanded information\ndevices = client.get_devices(\n expand=[\"goal\", \"place\", \"plant\"]\n)\n```\n\n#### Get Device Details\n\n```python\ndevice = client.get_device(\"device-id\")\n```\n\n#### Get Sensors\n\n```python\n# Get all sensors\nsensors = client.get_sensors()\n\n# Get sensors with specific language\nsensors = client.get_sensors(language=\"it\")\n```\n\n#### Query Measurements\n\n```python\nfrom datetime import datetime, timedelta\n\n# Get latest measurements for a device\nmeasurements = client.query_measurements(\n device_id=\"device-id\",\n latest=True\n)\n\n# Get hourly measurements for the last 24 hours\nend_date = datetime.utcnow()\nstart_date = end_date - timedelta(days=1)\n\nmeasurements = client.query_measurements(\n device_id=\"device-id\",\n from_date=start_date,\n to_date=end_date,\n group_by=\"hour\"\n)\n\n# Get measurements for a specific place\nmeasurements = client.query_measurements(\n place_id=\"place-id\",\n group_by=\"day\"\n)\n```\n\n### Error Handling\n\n```python\nfrom vitesy import VitesyError, AuthenticationError, APIError\n\ntry:\n devices = client.get_devices()\nexcept AuthenticationError:\n print(\"Invalid API key\")\nexcept APIError as e:\n print(f\"API error {e.status_code}: {e.message}\")\nexcept VitesyError as e:\n print(f\"General error: {str(e)}\")\n```\n\n## Development\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/yourusername/vitesy-python-sdk.git\ncd vitesy-python-sdk\n```\n\n2. Create a virtual environment:\n```bash\npython -m venv venv\nsource venv/bin/activate # On Windows: venv\\Scripts\\activate\n```\n\n3. Install development dependencies:\n```bash\npip install -e \".[dev]\"\n```\n\n4. Run tests:\n```bash\npytest\n```\n\n### Publishing to PyPI\n\n1. Build the package:\n```bash\npython -m pip install --upgrade build\npython -m build\n```\n\n2. Upload to TestPyPI (optional):\n```bash\npython -m pip install --upgrade twine\npython -m twine upload --repository testpypi dist/*\n```\n\n3. Upload to PyPI:\n```bash\npython -m twine upload dist/*\n```\n\n## Testing\n\nThe SDK includes both unit tests and integration tests.\n\n### Running Unit Tests\n\nUnit tests can be run without any API credentials:\n\n```bash\npytest -m \"not integration\"\n```\n\n### Running Integration Tests\n\nIntegration tests require valid API credentials. To run them:\n\n1. Set your API key as an environment variable:\n```bash\nexport VITESY_API_KEY=\"your-api-key\"\n```\n\n2. Run the integration tests:\n```bash\npytest tests/integration/\n```\n\nOr run all tests (both unit and integration):\n```bash\npytest\n```\n\n### Test Structure\n\n- `tests/test_client.py`: Unit tests for the client\n- `tests/integration/test_integration.py`: Integration tests with the actual API\n- `tests/conftest.py`: Shared test fixtures and configuration\n\nThe test suite uses pytest and includes:\n- Basic client initialization tests\n- API endpoint tests with mocked responses\n- Error handling tests\n- Integration tests with the actual API\n- Language support tests\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Unofficial Python SDK for Vitesy APIs",
"version": "0.1.0",
"project_urls": {
"Bug-Tracker": "https://github.com/dgrassi1984/vitesy-python-unofficial/issues",
"Homepage": "https://github.com/dgrassi1984/vitesy-python-unofficial"
},
"split_keywords": [
"vitesy",
" api",
" sdk",
" unofficial"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6e6861d41acfe403ba3b0390ec7fc6db38ce85b5829371c3374f44dee10a95bf",
"md5": "124e0530663b7f2e85849cff7d2ecf0b",
"sha256": "1b35bdc56bc0c69b03687468517f72669a36007c324c587878a6deda2e88e927"
},
"downloads": -1,
"filename": "vitesy_python_unofficial-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "124e0530663b7f2e85849cff7d2ecf0b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 6249,
"upload_time": "2024-12-25T13:32:40",
"upload_time_iso_8601": "2024-12-25T13:32:40.607312Z",
"url": "https://files.pythonhosted.org/packages/6e/68/61d41acfe403ba3b0390ec7fc6db38ce85b5829371c3374f44dee10a95bf/vitesy_python_unofficial-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7ff28b6d27e496c0d41aa224d5f2e47b5d736bab0f7371efa101c1241d59b326",
"md5": "a140771294558792717e8092dc9ae071",
"sha256": "0f2ad82e2ecbd58cb810711a36246d15b046190fb2d9cb4b57f59b45ac9594a3"
},
"downloads": -1,
"filename": "vitesy_python_unofficial-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "a140771294558792717e8092dc9ae071",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7942,
"upload_time": "2024-12-25T13:32:42",
"upload_time_iso_8601": "2024-12-25T13:32:42.981478Z",
"url": "https://files.pythonhosted.org/packages/7f/f2/8b6d27e496c0d41aa224d5f2e47b5d736bab0f7371efa101c1241d59b326/vitesy_python_unofficial-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-25 13:32:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "vitesy-python-unofficial",
"github_not_found": true,
"lcname": "vitesy-python-unofficial"
}