python-spot-client is an asynchronous Python library for interacting with the SPOT device API. It targets developers who need to fetch or manage data from SPOT GPS tracker/satellite messaging devices, supporting both synchronous and asynchronous Python code.
- Async and sync APIs: Core
SpotApiclass exposes async methods (e.g.,await client.request_latest()) and tested sync wrappers (e.g.,client.request_latest_sync()). - Data models: Strongly-typed dataclasses represent messages (
SpotMessage) and feeds (SpotFeed). These support parsing, aggregation, filtering, and robust handling of malformed or missing data. - Pagination & Time Range: Methods support paginated fetching (
request_all_pages) and time-windowed queries (request_with_datesand variants). - Request throttling: Built-in rate limit enforcement; API responses include throttling status/enums and wait recommendations via
SpotRequestStatus.THROTTLED. - Aggregation/filter helpers: Model helpers provide averaging methods (e.g.
average_location), type filtering, latest-per-device matchup, sorted iteration, and more—all tested intests/test_spot_api.py. - Type-checked enums: Enums cover battery state, device/message/feed types, request statuses, and more (
src/spot_api/enums.py). Mappings from external values to enums are robust, with unrecognized cases logged as warnings. - Client hygiene: Works as a context manager (async or sync); can use a provided or managed httpx.AsyncClient. Handles proper connection management.
- Public API: Defined in
src/spot_api/__init__.py, exposing client, models, enums, and internal helpers. - Client logic:
src/spot_api/client.pyimplements transport, API state/rate limiting, parameter handling, and endpoint logic. - Data parsing/models:
src/spot_api/models.pydefinesSpotFeedandSpotMessage, with rich parsing, type coercion, and helper methods. - Enums:
src/spot_api/enums.pycontains all enum classes (for request types, battery, device/feed/message types, and statuses). All enums have.from_str()classmethods for safe construction from API values, and logging for unrecognized input. - Testing focus: Core business logic (API, models, enums, and coercion/parsing helpers) is covered by unit tests in
tests/test_spot_api.py, with coverage for error-handling, sync/async logic, parsing, averaging/location math, and all enum mappings.
- Library use only: No CLI or standalone entrypoint. Main usage: import
SpotApiand other types in Python. Key user methods includerequest_latest(),request_all_pages(), and aggregation helpers on models.
- Python 3.11+ required
- Install:
pip install python-spot-clientfor use; for development: clone, thenpip install -e .[docs,test,lint]or userequirements-dev.txt. - Tests: Run with
pytest(mainly intests/test_spot_api.py). - Docs: Build with Sphinx (
make htmlindocs/).
- Feeds provided at runtime as list of
(feed_id, password). Password is optional per feed but must be explicitly set (Noneis allowed for public feeds). Code and tests enforce that creds should not be hardcoded. - No built-in config/env loader: User is responsible for managing secrets and runtime feed config.
- All data: Pulled from SPOT REST API over HTTP using
httpx.AsyncClient. No secondary DB or persistent queue; strong typing for results returned fromSpotApimethods.
- Entry:
src/spot_api/client.py(SpotApi) - Models:
src/spot_api/models.py(SpotFeed,SpotMessage) - Enums:
src/spot_api/enums.py(battery, device, feed, message types and statuses) - Public API Surface:
src/spot_api/__init__.py
- Async/sync duality: Both modes are fully supported and tested, but edge case test coverage of rare network faults or deep async context handling is not exhaustively reviewed.
- API throttling: Spot API rate limits are strictly enforced. Throttling status is reported, and suggested wait times included.
- Parsing issues: Malformed or missing datetimes/coords fallback to safe defaults (e.g., origin, 0/None) with warnings. Unrecognized enums are mapped to
UNKNOWN_*values and log a warning. Tests verify this behavior for all enums and parsing. - Secrets: User manages secret lifecycles externally—no in-repo secret management or helpers.
- Parsing/coercion: Tests for boolean, float, int, and datetime coercers; verify warning logs on invalid input.
- Enum robustness: Each enum's
.from_str()covers known, unknown, case-variation, and edge cases; logs are asserted. - SpotApi edge cases: Handles duplicate feeds, missing/empty lists, custom endpoints, and aggregation math (with missing/invalid messages).
- Model utility: Message parsing, coordinate clamping, short date/loc formatting, and feed construction from realistic API samples are all covered.
- No integration/system tests: Coverage is thorough at the unit/surface API level, but not proven for full network or multi-feed integration.
src/spot_api/client.py(SpotApi core implementation)src/spot_api/models.py(Feed/Message models)src/spot_api/enums.py(Enum type safety and robust mappings)
- Are there edge cases in deep async context handling or network retries that lack coverage?
- How does logging scale in high-throughput or multi-feed scenarios—does it flood for unrecognized inputs?
- Are there plans for system/integration test coverage or just unit tests going forward?
Get productive with python-spot-client by following this step-by-step guide. The plan focuses on vital library logic, usage, and safe extension, and balances deep dives with surface-level orientation.
-
src/spot_api/client.py Why it matters: Core implementation of the SpotApi client—most business logic lives here. What to look for:
- Async and sync API surface (core methods, context manager behavior)
- Rate limiting/throttling logic
- How API params and responses are handled Time estimate: 20 min
-
src/spot_api/models.py Why it matters: All main data structures, parsing, aggregation, and helpers are defined here. What to look for:
- SpotFeed and SpotMessage classes (fields, parsing, helper methods)
- Parsing/coercion strategies for incoming API data
- Aggregation and formatting utilities Time estimate: 18 min
-
src/spot_api/enums.py Why it matters: Houses all key enums, including type safety and robust mapping from API responses. What to look for:
- Enum class definitions (battery, device, message, feed, status)
.from_str()construction and handling of unknowns- Logging/warning mechanisms for unrecognized values Time estimate: 12 min
-
src/spot_api/init.py Why it matters: Defines the public API, what users are meant to import and how. What to look for:
- What is exposed explicitly
- Any init-time configuration or import-time side effects Time estimate: 3 min
-
tests/test_spot_api.py Why it matters: Unit test coverage for core logic, edge cases, and robustness. What to look for:
- Test coverage of API methods (positive and edge cases)
- Enum mapping/robustness, error handling, parsing failure handling
- Aggregation and helper function behaviors Time estimate: 15 min
-
README.md Why it matters: User-facing guide for installation, supported features, and minimal usage. What to look for:
- Package purpose and installation instructions
- Feature overview and typical usage
- Any environment or runtime requirements Time estimate: 4 min
-
requirements.txt and pyproject.toml Why it matters: Declares dependencies and packaging; helpful for setting up dev/test environments. What to look for:
- Required Python version and main dependencies
- Extra requirements for testing or documentation Time estimate: 3 min
-
setup.py Why it matters: Contains legacy build/packaging metadata, sometimes with extra notes. What to look for:
- Package metadata for distribution
- Any custom install or setup logic Time estimate: 2 min
-
.github/workflows/ci.yml Why it matters: Shows the continuous integration pipeline for running tests and lint checks. What to look for:
- How tests are executed; Python version(s) covered
- Linting, coverage, and build triggers Time estimate: 3 min
- Read
src/spot_api/client.py(skim core methods, context manager, throttling) — 12 min - Read
src/spot_api/models.py(only data class definitions/constructor and key helpers) — 8 min - Glance at
tests/test_spot_api.py(skim test case structure and edge cases) — 6 min
- How to run tests/build:
- Install dev requirements:
pip install -e .[docs,test,lint]or userequirements-dev.txt. - Run tests with:
pytest tests/test_spot_api.py
- Install dev requirements:
- Where to add a small change and validate quickly:
- For core logic: add/change a method in
src/spot_api/client.py. - Quickly validate by adding or modifying a test case in
tests/test_spot_api.pyand runningpytest.
- For core logic: add/change a method in
- What to verify:
- Ensure all tests pass (including edge and error cases).
- If modifying parsing/mapping: check warnings/logs for malformed input as tested in the suite.