Asynchronous Python client for the Fressnapf Tracker GPS API
Project description
fressnapftracker
Asynchronous Python client for the Fressnapf Tracker GPS API
Installation
uv add fressnapftracker
Usage
Email Authentication Flow
Use your Fressnapf account credentials to request a sign-in link by email:
import asyncio
from fressnapftracker import AuthClient
async def main() -> None:
"""Show the email authentication flow."""
async with AuthClient() as auth:
# Step 1: Request the email sign-in link
response = await auth.request_magic_link("<EMAIL>", "<PASSWORD>")
user_id = response.user.id
access_token = response.user_token.access_token
customer_id = response.user.additional_parameters.fressnapf_id
# Step 2: Open the link in the email, then check its status
input("Open the sign-in link, then press Enter: ")
if not await auth.check_magic_link_was_clicked(access_token):
raise RuntimeError("The sign-in link has not been opened")
# Step 3: Complete authentication and get the tracker devices
await auth.complete_magic_link(user_id, access_token, customer_id)
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())
check_magic_link_was_clicked() performs one status request. Applications that poll should choose an appropriate interval and timeout.
Legacy SMS Authentication Flow
Phone-number authentication remains available for existing accounts:
async with AuthClient() as auth:
sms_response = await auth.request_sms_code("+49123456789")
sms_code = input("Enter SMS code: ")
response = await auth.verify_phone_number(sms_response.id, sms_code)
devices = await auth.get_devices(sms_response.id, response.user_token.access_token)
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 useuser_agent(str, optional): Custom user agent string
Methods
request_magic_link(email: str, password: str, locale: str = "en")->MagicLinkResponse: Request an email sign-in linkcheck_magic_link_was_clicked(user_access_token: str)->bool: Check once whether the email sign-in link has been openedcomplete_magic_link(user_id: int, user_access_token: str, customer_id: str)->TrackerUser: Complete email authenticationrequest_sms_code(phone_number: str, locale: str = "en")->SmsCodeResponse: Request an SMS verification codeverify_phone_number(user_id: int, sms_code: str)->PhoneVerificationResponse: Verify a phone number with its SMS codeget_devices(user_id: int, user_access_token: str)->list[Device]: Get the authenticated user's 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 useuser_agent(str, optional): Custom user agent string
Methods
get_tracker()->Tracker: Get current tracker dataset_led_brightness(brightness: int): Set LED brightness (0-100)set_deep_sleep(enabled: bool): Enable/disable deep sleep mode
Models
Tracker
name: Pet/device namebattery: Battery percentagecharging: Whether the device is chargingposition: Position data (lat, lng, accuracy)tracker_settings: Device settings and featuresled_brightness: LED brightness settingsdeep_sleep: Deep sleep settings
MagicLinkResponse
user: Authenticated user information, including the user and Fressnapf customer IDsuser_token: Access token and current magic-link confirmation status
TrackerUser
id: Tracker user IDemail: Fressnapf account email addressadditional_parameters: Fressnapf-specific account settings
Device
serialnumber: Device serial numbertoken: Device token for API calls
Exceptions
FressnapfTrackerError: Base exceptionFressnapfTrackerConnectionError: Connection/timeout errorsFressnapfTrackerAuthenticationError: Authentication errorsFressnapfTrackerInvalidTokenError: Invalid auth tokenFressnapfTrackerInvalidDeviceTokenError: Invalid device tokenFressnapfTrackerInvalidSerialNumberError: 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
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 fressnapftracker-0.3.0.tar.gz.
File metadata
- Download URL: fressnapftracker-0.3.0.tar.gz
- Upload date:
- Size: 48.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40d0f388b704006657e37cb59e9583ab29c567b680541734d1b25dc56cb732b6
|
|
| MD5 |
2f8d80c2a0396bc35d62c514f4b31214
|
|
| BLAKE2b-256 |
dd598e33eba133e47bef962489d8215e375d958f859ccd9146720f23255c4b2f
|
File details
Details for the file fressnapftracker-0.3.0-py3-none-any.whl.
File metadata
- Download URL: fressnapftracker-0.3.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cbb6b7b53c341052ba4dd134439f5a6282919112fe33ca9ae8dbcd02fd193f7
|
|
| MD5 |
99177a856a074c25d8dea7a49b37b916
|
|
| BLAKE2b-256 |
edb67426f88eac5a8155f845aaba9903e223966cb2da3cb625241e81149d2cfc
|