Skip to main content

Async Python client for the Ride with GPS API

Project description

aioridewithgps

Async Python client for the Ride with GPS API v1.

This is the backend library that powers the Home Assistant Ride with GPS integration. It handles all communication with the Ride with GPS API behind the scenes.

For Home Assistant users

If you're here because you want to connect Ride with GPS to Home Assistant, you don't need to install this library yourself. Home Assistant installs it automatically when you add the integration.

What you'll need

A Ride with GPS API key. Here's how to get one:

  1. Log in to your Ride with GPS account at ridewithgps.com
  2. Go to your API clients page
  3. Click Create a new API client
  4. Give it a name (e.g., "Home Assistant")
  5. Copy the API Key that appears

That's all you need before setting up the integration.

Setting up in Home Assistant

Everything is done through the Home Assistant GUI. No code, no config files, no YAML.

  1. Open Home Assistant
  2. Go to Settings > Devices & services
  3. Click + Add integration (bottom right)
  4. Search for Ride with GPS
  5. A form pops up asking for three things:
    • API Key - the key you copied above
    • Email - the email you use to log in to Ride with GPS
    • Password - your Ride with GPS password
  6. Click Submit

That's it. Your ride data shows up as sensors automatically.

About your password

Your password is never stored by Home Assistant or this library. Here's what actually happens:

  1. When you click Submit, your password is sent to Ride with GPS one time to get an authentication token
  2. Ride with GPS returns a token (a long random string) that proves you're you
  3. Home Assistant saves only that token - your password is immediately discarded
  4. All future API calls use the token, not your password

If the token ever stops working, Home Assistant will ask you to re-authenticate through the same form.

What sensors do you get?

Once set up, you get sensors for:

Account totals:

  • Total rides, total routes
  • Total distance, total elevation gain, total moving time

Your 10 most recent rides (each with):

  • Ride name, date, activity type
  • Distance, duration, moving time
  • Elevation gain
  • Average and max speed
  • Average and max heart rate (if you have an HR monitor)
  • Average and max power (if you have a power meter)
  • Cadence, calories

Data updates automatically every 30 minutes using an efficient sync process - it only fetches what's changed, not your entire ride history every time.


For developers

If you want to use this library in your own Python project (outside of Home Assistant), here's how.

Installation

pip install aioridewithgps

Quick start

import asyncio
import aiohttp
from aioridewithgps import RideWithGPSClient

async def main():
    async with aiohttp.ClientSession() as session:
        # Authenticate - gets a token using your credentials.
        # The password is only used for this one call.
        auth = await RideWithGPSClient.authenticate(
            session,
            api_key="your_api_key",
            email="your_email@example.com",
            password="your_password",
        )

        # Create a client using the token (not your password)
        client = RideWithGPSClient(
            session,
            api_key="your_api_key",
            auth_token=auth.auth_token,
        )

        # Now use it
        user = await client.get_user()
        print(f"Hello, {user.display_name}!")

        trips = await client.get_all_trips()
        for trip in trips[:5]:
            print(f"  {trip.name}: {trip.distance / 1000:.1f} km")

asyncio.run(main())

Available methods

Method What it does
RideWithGPSClient.authenticate(...) Exchange credentials for a token
client.get_user() Get your profile
client.get_all_trips() Get all your rides
client.get_trip(trip_id) Get a single ride
client.get_trips(page=1) Get one page of rides (up to 200)
client.get_all_routes() Get all your routes
client.get_routes(page=1) Get one page of routes (up to 200)
client.get_sync(since="2024-01-01T00:00:00Z") Get changes since a date

Ride data fields

Every ride (TripSummary) includes:

Field Unit Example
name - "Morning Ride"
distance meters 32186.9
duration seconds 5400
moving_time seconds 4800
elevation_gain meters 305
avg_speed / max_speed km/h 24.1 / 52.3
avg_hr / max_hr bpm 145 / 172
avg_watts / max_watts watts 180 / 320
calories kcal 850
departed_at ISO 8601 "2024-06-15T08:00:00-07:00"
activity_type - "Cycling"

Fields like heart rate, power, and cadence are None if those sensors weren't used on the ride.

Links

License

MIT

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

aioridewithgps-0.1.4.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

aioridewithgps-0.1.4-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file aioridewithgps-0.1.4.tar.gz.

File metadata

  • Download URL: aioridewithgps-0.1.4.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for aioridewithgps-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c26c68918651d35a6eadc420e6353e02ff3191ad1052604e7b0c78e173b4d1c2
MD5 d64156fbc05c6ce30ab258be2b69ad52
BLAKE2b-256 49622d52f8ecdd8b21db2beadd05a49ca409a904d37c5198816d0392cef4bde4

See more details on using hashes here.

File details

Details for the file aioridewithgps-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: aioridewithgps-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for aioridewithgps-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5327a5bf306123bd600751a083a6fc47cef9566830249a43bf8d84403786e5eb
MD5 9e672bc9e800007af9098633d5dcc107
BLAKE2b-256 92b537a69fde119a59be67dae404da11518771145a9b1f6871402fc7b031cf8d

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