Bardiya Map SDK for Python
Official client for the Bardiya Map API. Python 3.10+.
- Pydantic v2 models generated from the published contract.
httpxtransport with bounded retries,Retry-Aftersupport and a shared connection pool.- Server-sent events parsed by
httpx-sse. - Every error is a
BardiyaErrorwithstatus,code,details,request_idandretry_after_ms.
Install
pip install bardiyamap-sdk
Requires Python 3.10 or newer. Published on PyPI.
Quickstart
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)
client.maps sends X-API-Key; client.tracking sends
Authorization: Bearer. Pass maps_api_key / tracking_api_key when the two
credentials differ.
Maps
route = bardiya.maps.routing.directions(
{"longitude": 31.2357, "latitude": 30.0444},
{"longitude": 31.3209, "latitude": 30.0626},
profile="driving",
)
matrix = bardiya.maps.matrix.calculate(
origins=[{"longitude": 31.2357, "latitude": 30.0444}],
destinations=[{"longitude": 31.3209, "latitude": 30.0626}],
)
reverse = bardiya.maps.geocoding.reverse(30.0451, 31.2362)
Maps GETs retry 429/5xx/network failures with bounded backoff. The three
chargeable POST computations (/v1/directions, /v1/distance-matrix,
/v1/validate-address) retry only when retry_post_computations=True and
the call passes idempotency_key; even then an HTTP error response is final and
only an ambiguous transport failure/timeout is replayed. The header itself is
accepted on every metered Maps route, including GET reads; the ledger
deduplicates debit and recomputes rather than caching the body. The server-side
idempotency ledger is flag-gated off in production, so no exactly-once guarantee
is claimed. Set max_retries=0 to disable retries.
Tracking
session = bardiya.tracking.sessions.create(
subject_type="device",
external_reference="TRUCK-17",
idempotency_key="truck-17-create",
)
result = bardiya.tracking.sessions.send_location(
session.id,
{
"client_event_id": "22222222-2222-2222-2222-222222222222",
"client_seq": 1,
"recorded_at": "2026-11-02T10:00:00Z",
"event_type": "location",
"latitude": 30.0444,
"longitude": 31.2357,
},
)
state = bardiya.tracking.sessions.state(session.id)
history = bardiya.tracking.sessions.history(session.id, limit=100)
client_seq must increase per session and client_event_id is the idempotency
key: re-sending the same id is reported as duplicate=True instead of creating
a second event. Reads of sessions, state, history and webhooks are routed to the
read plane automatically.
Realtime
for frame in bardiya.tracking.sessions.stream(session.id):
if frame.event == "location":
print(frame.id, frame.data)
elif frame.event == "closed":
break
Resume is not supported. On reconnect, read the snapshot again and use
history() for anything older.
Device ingest
Do not ship an API key inside a mobile app. Issue a session-scoped credential from your backend, then give the device only that:
credential = bardiya.tracking.client_tokens.issue_ingest(session.id)
device = bardiya.ingest_client(
session_id=session.id,
organization_id=ORGANIZATION_ID, # from the console; not returned by the session API
ingest_credential=credential.ingest_credential,
)
device.send_location({...})
The credential can only post events for its own session.
Webhooks
from bardiya import verify_webhook_signature
ok = verify_webhook_signature(
secret=endpoint_secret,
timestamp=int(request.headers["X-Bardiya-Webhook-Timestamp"]),
body=raw_body, # the exact bytes received
signature=request.headers["X-Bardiya-Webhook-Signature"],
)
Pass the full v1=<lowercase hex> header and the exact raw body. The helper
authenticates the timestamp but does not check freshness: reject timestamps
outside your replay window separately. Unsupported versions return False;
pass raise_on_unknown_version=True to receive a ValueError instead.
Errors
from bardiya import BardiyaError
try:
bardiya.maps.places.search("coffee")
except BardiyaError as error:
print(error.status, error.code, error.request_id)
if error.status == 429:
time.sleep((error.retry_after_ms or 1000) / 1000)
status == 0 means no HTTP response was received (timeout or network failure).
Free Sandbox quotas
A 429 can mean two different things:
- a renewable rate window:
Retry-Afteris present, retrying later works; - a spent Free Sandbox lifetime balance:
X-Free-Sandbox-Credits-Remaining: 0and noRetry-After. It does not refill; do not loop.
Limitations
- Sync client only; an async client is not shipped yet.
- No publishable/browser key type exists, so this package is server-side only.
- The client has not been exercised against a live API in this repository.
Tests
The suite ships in tests/ in the source distribution and needs the test
extra:
pip install "bardiyamap-sdk[test]"
One check compares the packaged LICENSE and NOTICE with their sdk/ root
copies, so it only passes inside a full SDK checkout.
Metadata
Release files for bardiyamap-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bardiyamap_sdk-0.1.0.tar.gz | 35.2 kB | Without provenance | Details for bardiyamap_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bardiyamap_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for bardiyamap_sdk-0.1.0-py3-none-any.whl |
Total release size: 63.4 kB
Release files / bardiyamap_sdk-0.1.0.tar.gz
| Download URL | bardiyamap_sdk-0.1.0.tar.gz |
|---|---|
| Size | 35.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa677acded18db988ba5e4c6efd7aa4e608cdff832bc90c26b8d8624f327d111
|
|
BLAKE2b-256 checksum How to use checksums |
dbfc8e871015db8a056b10c6986199dbd0e542995e9f9a6bba94ce4b6f104e84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.18
|
Release files / bardiyamap_sdk-0.1.0-py3-none-any.whl
| Download URL | bardiyamap_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 28.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1666d7f1ceaa45ff6cd7ad763643f0afb9926531e4b57a8a5a4933ee2d07847
|
|
BLAKE2b-256 checksum How to use checksums |
f88889aa576e3abf66eb7afa956fcc039ddf9ff394aa20d0f1ebecf0b63d36cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.18
|
Security for bardiyamap-sdk 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.