Skip to content

Repository files navigation

pywaze

Asynchronous Waze client for calculating routes and travel times.

Based on WazeRouteCalculator

Installation

uv add pywaze

Usage

#!/usr/bin/env python3

import asyncio
from pywaze import route_calculator


async def get_time(start: str, end: str) -> float:
    """Return the travel time home."""

    async with route_calculator.WazeRouteCalculator() as client:
        results = await client.calc_routes(start, end)
        first_route = results[0]
        return first_route.duration


start = "50.00332659227126,8.262322651915843"
end = "50.08414976707619,8.247836017342934"

travel_time = asyncio.run(get_time(start, end))

print(travel_time)

Use the asynchronous context manager, or call await client.close() when finished. The calculator closes its own HTTPX client and its impersonating session, but leaves an injected httpx.AsyncClient open for its owner to close.

Address resolving base coordinates

When one or both endpoints are addresses, calc_routes() resolves them directly via Waze's mobile autocomplete API. You can provide custom base coordinates to bias address results near those coordinates:

await client.calc_routes(start, end, base_coords=(48.137154, 11.576124))

If base_coords is omitted and exactly one endpoint is already coordinates, that coordinate endpoint is used automatically as base coordinates for resolving the address.


About

Asynchronous Waze client for calculating routes and travel times.

Topics

Resources

Stars

16 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages