Bardiya.Map 0.1.0

dotnet add package Bardiya.Map --version 0.1.0
                    
NuGet\Install-Package Bardiya.Map -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bardiya.Map" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bardiya.Map" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Bardiya.Map" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bardiya.Map --version 0.1.0
                    
#r "nuget: Bardiya.Map, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bardiya.Map@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bardiya.Map&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Bardiya.Map&version=0.1.0
                    
Install as a Cake Tool

Bardiya.Map — .NET SDK

Official .NET client for Bardiya Map location platform: Places, Geocoding, Directions, Distance Matrix, Address Validation, Map tiles and styles, Tracking ingest, history, Realtime server-sent events and signed webhooks.

The API surface is generated from the shared SDK contract (sdk/contract/openapi/bardiya-sdk-v1.json) with OpenAPI Generator 7.27.0 (httpclient library: Newtonsoft.Json + Polly). Hand-written layers add the two credential families, read-plane routing, retry policy, SSE streaming, webhook signature verification and device ingest.

Install

dotnet add package Bardiya.Map

Targets net10.0. Published on nuget.org.

Quick start

using Bardiya.Map;
using Bardiya.Map.Model;

using var client = new BardiyaClient(new BardiyaOptions
{
    // Maps and Tracking authenticate differently; configure the families you use.
    MapsApiKey = "bdy_maps_...",
    TrackingApiKey = "bdy_tracking_...",
});

// Maps family: X-API-Key
var places = await client.Places!.SearchPlacesAsync("café", latitude: 30.0444, longitude: 31.2357);

// Tracking family: Authorization: Bearer
var session = await client.Tracking!.CreateSessionAsync(
    new PublicSessionCreate(subjectType: "device"),
    idempotencyKey: "order-123");

Credentials and routing

  • Maps operations (/v1/places, /v1/geocode, /v1/directions, /v1/distance-matrix, /v1/validate-address, /v1/style.json, /v1/tiles) send X-API-Key.
  • Tracking operations (/v1/tracking, /v1/webhooks) send Authorization: Bearer.
  • GET reads of sessions, state, history, subscriptions, client tokens and webhooks are routed to the read plane (read-api.bardiyamap.com) automatically. Streams stay on the core plane.
  • A maps-only client never holds a tracking credential, and vice versa.

Custom handlers

If you supply BardiyaOptions.HttpHandler, the client never mutates or disposes it — ownership stays with you. The handler must have automatic redirects disabled (AllowAutoRedirect = false) on its innermost transport (HttpClientHandler or SocketsHttpHandler); a handler that follows redirects would replay X-API-Key/Authorization to another origin, so the client rejects it with ArgumentException before any request is sent. The default SDK handler disables redirects. The same rule applies to the handler argument of BardiyaIngestClient.Create.

Retries

Only operations that are safe to repeat are retried: GET/HEAD on transient statuses, and the three chargeable POST computations (/v1/directions, /v1/distance-matrix, /v1/validate-address) only when RetryPostComputations is enabled and the call passes an idempotencyKey. Even then an HTTP error response is final; only an ambiguous transport failure is replayed. Writes are never replayed. Transient statuses are 408, 425, 429, 500, 502, 503 and 504; Retry-After is honoured (capped at 30 s). Configure with MaxRetries and RetryBaseDelay. The header 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.

Errors

Non-2xx responses surface as BardiyaApiException with StatusCode, Code (from the envelope), RequestId, RetryAfter, Details and RawBody. Transport failures have StatusCode == 0 and Retryable == true.

try
{
    await client.Tracking!.ListSessionsAsync();
}
catch (BardiyaApiException e) when (e.StatusCode == 429)
{
    Console.WriteLine($"rate limited; retry after {e.RetryAfter}");
}

Realtime (SSE)

await foreach (var frame in client.StreamSessionAsync(sessionId))
{
    // frame.Type: snapshot | location | heartbeat | limit | closed
    Console.WriteLine($"{frame.Type}: {frame.Data}");
}

Frames are parsed with System.Net.ServerSentEvents (Microsoft). The stream ends when the server closes it; a frame is only delivered once the server has terminated it with the SSE blank-line delimiter.

Webhooks

Deliveries carry X-Bardiya-Webhook-Timestamp and X-Bardiya-Webhook-Signature. Verify over the exact bytes received — do not re-serialise the body (JSON key order or spacing changes the digest):

using Bardiya.Map;
// Read the raw request body as bytes, exactly as received on the wire.
byte[] rawBody;
using (var ms = new MemoryStream())
{
    await Request.Body.CopyToAsync(ms);
    rawBody = ms.ToArray();
}

var ok = BardiyaClient.VerifyWebhookSignature(
    endpointSecret,          // from the createWebhook response
    long.Parse(Request.Headers["X-Bardiya-Webhook-Timestamp"]!),
    rawBody,                 // exact bytes, not a re-serialised object
    Request.Headers["X-Bardiya-Webhook-Signature"]!);

The scheme is v1=hex(HMAC-SHA256(secret, "<timestamp>." + body)), shared with the TypeScript and Go SDKs and the delivery worker. The timestamp must be within 300 seconds of the current UTC time (replay protection). Recompute over the raw body — a re-serialised object will not match.

Device ingest

Mint a session-scoped credential server-side, then send it to the device:

// server (your backend holds the tracking API key)
var credential = await client.Tracking!.IssueIngestTokenAsync(sessionId);
// hand sessionId, organizationId and credential.IngestCredential to the device

On the device, build a standalone scoped-ingest client — it must NOT construct a BardiyaClient with a server key:

using Bardiya.Map;
using Bardiya.Map.Model;

// Device-side: only the session-scoped credential, never a server key.
using var ingest = BardiyaIngestClient.Create(
    sessionId, organizationId, credential.IngestCredential);

await ingest.SendLocationAsync(new TrackingIngestEventCreate(
    clientEventId: Guid.NewGuid(),
    clientSeq: 1,
    recordedAt: DateTime.UtcNow));

The ingest credential can only post events for that one session; every request carries X-Tracking-Organization-Id.

Numeric types

Coordinates are double (the contract marks them format: double; a float32 cannot preserve six decimal places at Egyptian latitudes, so the shared precision fixture would fail). client_seq and state_version are long/long? — the backend schema declares them as signed BIGINT, so 32-bit int would overflow. This is handled by generate.py, which preprocesses the shared contract in memory (adding format: int64 to those fields) before generation; the shared contract, baseline, TypeScript and Go SDKs are unchanged.

Regenerating

python sdk/dotnet/generate.py                # drift check
python sdk/dotnet/generate.py --apply        # apply generated sources
python sdk/dotnet/generate.py --selftest     # drift-detector self-tests

generate.py is cross-platform (Python 3 stdlib + JVM + the pinned JAR, verified by SHA-1). The optional PowerShell wrapper generate.ps1 delegates to it. CI runs the drift check so generator or contract changes cannot silently change the committed surface.

License

Apache-2.0 — see sdk/LICENSE and sdk/NOTICE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 0 11/29/2026