Skip to main content

Asynchronous Python client for the Fressnapf Tracker GPS API

Project description

fressnapftracker

Asynchronous Python client for the Fressnapf Tracker GPS API

GitHub Actions PyPi License

Installation

uv add fressnapftracker

Usage

Authentication Flow

If you don't have credentials yet, you can use the authentication flow:

import asyncio

from fressnapftracker import AuthClient


async def main() -> None:
    """Show example of authentication flow."""
    async with AuthClient() as auth:
        # Step 1: Request SMS code
        # Phone number should be in E.164 format (e.g., +49123456789)
        sms_response = await auth.request_sms_code("+49123456789")
        user_id = sms_response.id
        print(f"User ID: {user_id}")

        # Step 2: Verify with SMS code (you'll receive this via SMS)
        sms_code = input("Enter SMS code: ")
        verify_response = await auth.verify_phone_number(user_id, sms_code)
        access_token = verify_response.user_token.access_token
        print(f"Access token: {access_token}")

        # Step 3: Get list of devices
        devices = await auth.get_devices(user_id, access_token)
        for device in devices:
            print(f"Device: {device.serialnumber} - Token: {device.token}")


if __name__ == "__main__":
    asyncio.run(main())

Getting Tracker Data

import asyncio

from fressnapftracker import ApiClient


async def main() -> None:
    """Show example of getting tracker data."""
    async with ApiClient(
        serial_number="<YOUR_SERIAL_NUMBER>",
        device_token="<YOUR_DEVICE_TOKEN>",
    ) as api:
        tracker = await api.get_tracker()
        print(f"Pet name: {tracker.name}")
        print(f"Battery: {tracker.battery}%")
        if tracker.position:
            print(f"Location: {tracker.position.lat}, {tracker.position.lng}")


if __name__ == "__main__":
    asyncio.run(main())

Controlling the Tracker

import asyncio

from fressnapftracker import ApiClient


async def main() -> None:
    """Show example of controlling the tracker."""
    async with ApiClient(
        serial_number="<YOUR_SERIAL_NUMBER>",
        device_token="<YOUR_DEVICE_TOKEN>",
    ) as api:
        # Set LED brightness (0-100)
        await api.set_led_brightness(75)

        # Enable/disable deep sleep mode
        await api.set_deep_sleep(True)


if __name__ == "__main__":
    asyncio.run(main())

API Reference

AuthClient

Client for handling authentication with the Fressnapf Tracker API.

Constructor Parameters

  • request_timeout (int, optional): Request timeout in seconds (default: 10)
  • client (httpx.AsyncClient, optional): Custom httpx client to use
  • user_agent (str, optional): Custom user agent string

Methods

  • request_sms_code(phone_number: str, locale: str = "en") -> SmsCodeResponse: Request SMS verification code
  • verify_phone_number(user_id: int, sms_code: str) -> PhoneVerificationResponse: Verify phone with code received via SMS
  • get_devices(user_id: int, user_access_token: str) -> list[Device]: Get list of devices

ApiClient

Client for interacting with the Fressnapf Tracker device API.

Constructor Parameters

  • serial_number (str): The serial number of your tracker device (required)
  • device_token (str): The device token for API authentication (required)
  • request_timeout (int, optional): Request timeout in seconds (default: 10)
  • client (httpx.AsyncClient, optional): Custom httpx client to use
  • user_agent (str, optional): Custom user agent string

Methods

  • get_tracker() -> Tracker: Get current tracker data
  • set_led_brightness(brightness: int): Set LED brightness (0-100)
  • set_deep_sleep(enabled: bool): Enable/disable deep sleep mode

Models

Tracker

  • name: Pet/device name
  • battery: Battery percentage
  • charging: Whether the device is charging
  • position: Position data (lat, lng, accuracy)
  • tracker_settings: Device settings and features
  • led_brightness: LED brightness settings
  • deep_sleep: Deep sleep settings

Device

  • serialnumber: Device serial number
  • name: Device name
  • device_token: Device token for API calls
  • auth_token: Auth token for API calls

Exceptions

  • FressnapfTrackerError: Base exception
  • FressnapfTrackerConnectionError: Connection/timeout errors
  • FressnapfTrackerAuthenticationError: Authentication errors
  • FressnapfTrackerInvalidTokenError: Invalid auth token
  • FressnapfTrackerInvalidDeviceTokenError: Invalid device token
  • FressnapfTrackerInvalidSerialNumberError: Invalid serial number

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

fressnapftracker-0.2.1.tar.gz (46.9 kB view details)

Uploaded Source

Built Distribution

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

fressnapftracker-0.2.1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file fressnapftracker-0.2.1.tar.gz.

File metadata

  • Download URL: fressnapftracker-0.2.1.tar.gz
  • Upload date:
  • Size: 46.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fressnapftracker-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a498ca83b0b25245f4c5773cd633cb77e06bad8b55cefef8520ef44dd4933950
MD5 43631271078a35d4fe7728858312daa1
BLAKE2b-256 3c319433911ea5498d3bce03e8d88392e97888b94cff7c2613175cc335f4c2a2

See more details on using hashes here.

File details

Details for the file fressnapftracker-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: fressnapftracker-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fressnapftracker-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e29847a3adbe9a87da21f7941586c9d6f1dee8d3ef87b56007cdd777a764be78
MD5 3a8ab0b23efddd50eb31451b64ea39ff
BLAKE2b-256 f7e2b41a81402b848c07340c53216a992144b5281bd7a4cdfaffff4e4f5f79a3

See more details on using hashes here.

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