Python
Python 3.10+
A synchronous client with a context manager, typed models, and streaming support for tracking sessions. The distribution name is bardiyamap-sdk; the import name is bardiya.
Install
pip
pip install bardiyamap-sdkWhat it supports
- Places, geocoding, directions, distance matrix, address validation
- Tracking sessions, ingest, history and state
- Client tokens, webhooks and subscriptions
- Server-sent event streaming
Initialise the client
python
from bardiya import BardiyaClient
with BardiyaClient(api_key="bdy_live_...") as bardiya:
results = bardiya.maps.places.search("coffee", latitude=30.0444, longitude=31.2357)
for place in results.results:
print(place.name, place.coordinate.longitude, place.coordinate.latitude)Typical operations
Reverse geocoding
python
match = bardiya.maps.geocoding.reverse(30.0397, 31.2035, language="ar")
print(match.street_match.name, match.street_match.distance_m)Distance matrix
python
matrix = bardiya.maps.matrix.calculate(
origins=[{"latitude": 30.0444, "longitude": 31.2357}],
destinations=[{"latitude": 30.0626, "longitude": 31.2497}, {"latitude": 30.1, "longitude": 31.3}],
)
# A cell the road network cannot reach is None; read errors before durations.
print(matrix.durations, matrix.errors)Error handling
python
from bardiya import BardiyaError
try:
bardiya.maps.places.search("coffee")
except BardiyaError as failure:
print(failure.status_code, failure.code, failure.request_id, failure.retryable)Things that catch people out
- pip install bardiyamap-sdk installs the module bardiya: the names differ on purpose for registry reasons.
- The client is synchronous. In async code, run it in a thread pool rather than mixing event loops.
- Always use the context manager, or call close(), so the HTTP connection pool is released.
