Python wrapper for the Emfit QS API
Project description
EmfitAPI Python Wrapper
Overview
EmfitAPI is a Python wrapper for the Emfit QS API. It provides methods to authenticate, fetch user and device data, and retrieve various metrics such as presence, trends, and timeline data from Emfit devices.
Installation
You can install the EmfitAPI wrapper using uv:
uv add emfitapi-python
Or from source:
git clone https://github.com/harperreed/emfitapi-python.git
cd emfitapi-python
uv sync
Development Installation
For development, clone the repository and install with dev dependencies:
git clone https://github.com/harperreed/emfitapi-python.git
cd emfitapi-python
uv sync
Running Tests
uv run pytest
Code Quality
# Run linting
uv run ruff check .
# Run formatting
uv run ruff format .
# Run security checks
uv run bandit -r emfit/
uv run safety check
Usage
Initializing the API
To start using the EmfitAPI, you need to instantiate the class:
from emfit.api import EmfitAPI
api = EmfitAPI(token="your_token_here")
If you don't have a token, you can obtain one by logging in:
api = EmfitAPI()
response = api.login("your_username", "your_password")
Making Requests
After authentication, you can use various methods to interact with the API:
get_user(): Fetches user information.get_device_status(device_id): Retrieves the status of a specific device.get_device_info(device_id): Fetches information of a specific device.get_latest_presence(device_id): Gets the latest presence information for a device.get_presence(device_id, presence_id): Retrieves presence information for a specific device and presence ID.get_trends(device_id, start_date, end_date): Fetches trend data for a device within a specified date range.get_timeline(device_id, start_date, end_date): Retrieves timeline data for a device within a specified date range.get_notification_settings(device_id): Gets the notification settings for a specific device.
Example
# Retrieve and print user information
user_info = api.get_user()
print(user_info)
# Fetch and print device status
device_status = api.get_device_status("device_id_here")
print(device_status)
Running the Example
The repository includes an example script that demonstrates basic usage:
# Set up environment variables
export EMFIT_USERNAME="your_username"
export EMFIT_PASSWORD="your_password"
# Run the example
uv run example.py
Logging
EmfitAPI uses Python's logging module to log information, warnings, and errors. Configure the logging level as needed.
Exception Handling
The wrapper raises exceptions when API requests fail. Ensure to handle these exceptions in your application.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 emfitapi_python-0.2.3.tar.gz.
File metadata
- Download URL: emfitapi_python-0.2.3.tar.gz
- Upload date:
- Size: 78.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
173de38d450b4dbe5c8f4252ee0c277e1468c2721eb0d4354a85745b66edfa51
|
|
| MD5 |
9bf8bc34d337688cf4f246a17ad7a2cc
|
|
| BLAKE2b-256 |
ebedbce8437f6c4d83ef6ee4b1cb30135ff6c36195d2117a5f033423b140055c
|
Provenance
The following attestation bundles were made for emfitapi_python-0.2.3.tar.gz:
Publisher:
auto-release.yml on harperreed/emfitapi-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emfitapi_python-0.2.3.tar.gz -
Subject digest:
173de38d450b4dbe5c8f4252ee0c277e1468c2721eb0d4354a85745b66edfa51 - Sigstore transparency entry: 268229069
- Sigstore integration time:
-
Permalink:
harperreed/emfitapi-python@23a3ede4fff7c564c8c1468646c7748426585911 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/harperreed
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
auto-release.yml@23a3ede4fff7c564c8c1468646c7748426585911 -
Trigger Event:
push
-
Statement type:
File details
Details for the file emfitapi_python-0.2.3-py3-none-any.whl.
File metadata
- Download URL: emfitapi_python-0.2.3-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65083cf386e48a730e16604444186fd6182967d1f20a34cbb126a4ce6ed0b261
|
|
| MD5 |
9fe607346583f7b40f5192f33ee4c582
|
|
| BLAKE2b-256 |
f35a0aca60527e3734e1edaf69aab3060e73b8d438e4b1a7fde3d2decd1b099e
|
Provenance
The following attestation bundles were made for emfitapi_python-0.2.3-py3-none-any.whl:
Publisher:
auto-release.yml on harperreed/emfitapi-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
emfitapi_python-0.2.3-py3-none-any.whl -
Subject digest:
65083cf386e48a730e16604444186fd6182967d1f20a34cbb126a4ce6ed0b261 - Sigstore transparency entry: 268229076
- Sigstore integration time:
-
Permalink:
harperreed/emfitapi-python@23a3ede4fff7c564c8c1468646c7748426585911 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/harperreed
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
auto-release.yml@23a3ede4fff7c564c8c1468646c7748426585911 -
Trigger Event:
push
-
Statement type: