Skip to main content

Utilities for MyLaps Event Results API.

Project description

speedhive-tools

Command-line toolkit and Python library for the MyLaps Speedhive Event Results API.


Installation

pip install speedhive-tools

For development:

git clone https://github.com/ncrosty58/speedhive-tools.git
cd speedhive-tools
python -m venv .venv && source .venv/bin/activate
pip install -e .

Quick start – speedhive CLI

The installed console script speedhive provides a unified interface.

speedhive export-full-dump --org 30476 --output ./output
speedhive report-consistency --org 30476 --top 10
speedhive extract-driver-laps --org 30476 --driver "Firstname Lastname"
speedhive extract-track-records --org 30476

Run speedhive --help to see all commands.
The CLI auto‑discovers modules under speedhive.exporters, speedhive.processors, and speedhive.analyzers.


Python library – SpeedhiveClient wrapper

from speedhive.wrapper import SpeedhiveClient

client = SpeedhiveClient.create(token="your-api-token")

events = client.get_events(org_id=30476, limit=5)
for e in events:
    print(e["name"])

laps = client.get_laps(session_id=12345)

Available methods:
get_organization, get_events, iter_events, get_event, get_sessions, get_session, get_laps, get_results, get_announcements, get_lap_chart, get_championships, get_championship, get_server_time, get_track_records, get_fastest_track_record, iter_track_records_by_event.


Example scripts

The examples/ directory contains runnable scripts demonstrating common tasks.
Run them directly from the repository root:

python -m examples.example_get_events --org 30476 --limit 5
python -m examples.example_get_session_laps --session 12345

All examples use SpeedhiveClient.create().


Offline workflow (recommended)

  1. Export a full dump:
speedhive export-full-dump --org 30476 --output ./output
  1. Process and analyse the exported files without further API calls:
speedhive report-consistency --org 30476 --top 10
speedhive extract-driver-laps --org 30476 --driver "Firstname Lastname"

The processing tools (speedhive.processing.lap_analysis.compute_laps_and_enriched) work directly on the dumped NDJSON files.


Output format

Exported data is placed in output/<org_id>/:

output/30476/
├── events.ndjson.gz
├── sessions.ndjson.gz
├── laps.ndjson.gz
├── announcements.ndjson.gz
├── results.ndjson.gz
└── .checkpoint.json

Developer notes

Package layout (under src/speedhive/):

src/speedhive/
├── client.py          # BaseClient, Client, AuthenticatedClient
├── wrapper.py         # SpeedhiveClient (user‑friendly wrapper)
├── generated/         # auto‑generated API client (httpx/attrs)
├── processing/        # ndjson, lap_analysis, etc.
├── cli/
│   ├── main.py        # CLI entry point
│   └── discovery.py   # auto‑discovery of subcommands
├── exporters/         # exporter modules (e.g. export_full_dump)
├── analyzers/         # analysis modules
└── processors/        # future processors

Design decisions

  • No Pydantic dependency – the generated API client uses attrs for models, and the wrapper returns plain dicts from json.loads. This keeps the dependency footprint small and avoids mixing validation frameworks. If stricter validation is needed later, it can be added selectively without affecting the rest of the codebase.

Contributing

Pull requests welcome. Add tests for new functionality.


License

MIT © Nathan Crosty

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

speedhive_tools-0.2.0.tar.gz (172.4 kB view details)

Uploaded Source

Built Distribution

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

speedhive_tools-0.2.0-py3-none-any.whl (172.4 kB view details)

Uploaded Python 3

File details

Details for the file speedhive_tools-0.2.0.tar.gz.

File metadata

  • Download URL: speedhive_tools-0.2.0.tar.gz
  • Upload date:
  • Size: 172.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for speedhive_tools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6d0f08d74b0cc2890fba98c9e4480cb01f034adc0340e6793297aae2d0e42908
MD5 8c159107f9fac00a35372755ca3194a4
BLAKE2b-256 ff593e7e459e068b234e48b6f3bfd20ec7574010e86d621004cec6a2c79a417b

See more details on using hashes here.

File details

Details for the file speedhive_tools-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for speedhive_tools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 acfafc0e5448b39248e9bd341b635756c054d6e033c8413799ef75fe34f37d90
MD5 229a99b98ef719d1707e9e23012bef9e
BLAKE2b-256 8ee815f78831755c9f2ed01cb3e525352630c4f3403f110ca7d8f55eeaaf30e0

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