Documentation menu

SDKs

Python SDK

The official Wayline SDK for Python: Python 3.9+. Sync and async clients built on httpx. Fully type-hinted.

Install

PyPI
pip install wayline
# or: uv add wayline · poetry add wayline

Quickstart

Set WAYLINE_API_KEY to a test key (see the Quickstart), then:

Python
from wayline import Wayline, AsyncWayline

client = Wayline()  # reads WAYLINE_API_KEY from the environment

d = client.distance(origin=(23.7925, 90.4078), destination="23.733,90.4172", units="imperial")
print(d.distance_miles, d.duration_seconds)

batch = client.distance_batch(points=[(23.7925, 90.4078), (23.7937, 90.4066), (23.7465, 90.376)], units="imperial")
print(batch.total_distance_miles)

# Async
async def main():
    async with AsyncWayline() as aclient:
        m = await aclient.matrix(origins=[(23.7925, 90.4078)], destinations=[(23.733, 90.4172)])
        print(m.rows[0].elements[0].duration_seconds)

Errors

Non-2xx responses raise a typed error after retries are exhausted. Branch on code — the full list is in the error reference.

Error handling
from wayline import WaylineError

try:
    client.distance(origin="0,0", destination="0,1")
except WaylineError as e:
    print(e.code, e.status, e.request_id)

Configuration

OptionDefaultDescription
API keyWAYLINE_API_KEYYour live or test key. Never logged.
Base URLhttps://api.wayline.cloudOverride for staging or a proxy.
Timeout30 secondsPer attempt.
Max retries3For 429 and 5xx, with exponential backoff + jitter, honoring Retry-After.

Source and releases

Package: wayline on PyPI. Source: packages/sdk-python. Versions follow semantic versioning; see the CHANGELOG in the package and our product changelog.

Was this page helpful?