Skip to main content

Python wrapper for the Emfit QS API

Project description

EmfitAPI Python Wrapper

CI codecov Python 3.11+ License: MIT

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emfitapi_python-0.2.3.tar.gz (78.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emfitapi_python-0.2.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

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

Hashes for emfitapi_python-0.2.3.tar.gz
Algorithm Hash digest
SHA256 173de38d450b4dbe5c8f4252ee0c277e1468c2721eb0d4354a85745b66edfa51
MD5 9bf8bc34d337688cf4f246a17ad7a2cc
BLAKE2b-256 ebedbce8437f6c4d83ef6ee4b1cb30135ff6c36195d2117a5f033423b140055c

See more details on using hashes here.

Provenance

The following attestation bundles were made for emfitapi_python-0.2.3.tar.gz:

Publisher: auto-release.yml on harperreed/emfitapi-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file emfitapi_python-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for emfitapi_python-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 65083cf386e48a730e16604444186fd6182967d1f20a34cbb126a4ce6ed0b261
MD5 9fe607346583f7b40f5192f33ee4c582
BLAKE2b-256 f35a0aca60527e3734e1edaf69aab3060e73b8d438e4b1a7fde3d2decd1b099e

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page