KiriminAja Rust SDK
Official Rust SDK for the KiriminAja logistics API. Async-first (powered by reqwest + tokio) with an opt-in synchronous facade. The API surface mirrors the Go SDK so examples translate one-to-one.
Requirements
- Rust 1.88+
- An async runtime compatible with
reqwest(Tokio recommended)
Installation
Or in Cargo.toml:
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
Quick Start
Create a client with Client::new(), then call any service method.
use ;
async
Config Options
| Field | Type | Default | Description |
|---|---|---|---|
env |
Env |
Env::Sandbox |
Target environment |
api_key |
String |
required | Your KiriminAja API key |
base_url |
Option<String> |
derived from env |
Override the base URL |
timeout |
Option<Duration> |
30s | Request timeout (used when no http_client) |
http_client |
Option<reqwest::Client> |
new client | Bring-your-own reqwest::Client |
use Duration;
use ;
// Custom base URL
let client = new;
// Custom timeout
let client = new;
// Bring your own reqwest::Client (proxy / test mock)
let http = builder.user_agent.build.unwrap;
let client = new;
Synchronous (blocking) API
For callers that don't use async, enable the blocking cargo feature:
[]
= { = "0.1", = ["blocking"] }
use Client;
use ;
The blocking client wraps the async client with a small internal Tokio runtime; the API surface is identical except methods are not async.
⚠️ Do not call blocking methods from inside an async runtime. The blocking facade calls
runtime.block_on(...)internally, which Tokio rejects with: "Cannot start a runtime from within a runtime." In async contexts (axum, actix-web,#[tokio::main]), use the async [kiriminaja::Client] directly.
Services
All async methods return kiriminaja::Result<T>.
Address
// List all provinces
client.address.provinces.await?;
// Cities in a province (provinsi_id)
client.address.cities.await?;
// Districts in a city (kabupaten_id)
client.address.districts.await?;
// Sub-districts in a district (kecamatan_id)
client.address.sub_districts.await?;
// Search districts by name
client.address.districts_by_name.await?;
Coverage Area & Pricing
use ;
// Express shipping rates
client.coverage_area.pricing_express.await?;
// Instant (same-day) rates
client.coverage_area.pricing_instant.await?;
Order — Express
use ;
// Track by order ID
client.order.express.track.await?;
// Cancel by AWB
client.order.express.cancel.await?;
// Request pickup
client.order.express.request_pickup.await?;
Order — Instant
use ;
// Create instant pickup
client.order.instant.create.await?;
// Find a new driver for an existing order
client.order.instant.find_new_driver.await?;
// Cancel instant order
client.order.instant.cancel.await?;
// Track instant order
client.order.instant.track.await?;
Courier
// List available couriers
client.courier.list.await?;
// Courier groups
client.courier.group.await?;
// Courier service detail
client.courier.detail.await?;
// Set whitelist services
client.courier.set_whitelist_services.await?;
Pickup Schedules
client.pickup.schedules.await?;
Payment
client.payment.get_payment.await?;
Credit
// Get the current KiriminAja credit balance
let balance = client.credit.balance.await?;
// balance.data.balance -> f64
Utilities — Volumetric
Estimate the smallest bounding box (length × width × height) for a multi-item package by trying vertical / horizontal / side-by-side stacking and returning the arrangement with the smallest volume.
use ;
let dim = calculate;
// dim.length, dim.width, dim.height
Error handling
All methods return kiriminaja::Result<T> where Error distinguishes invalid
arguments, transport errors, decoding errors, and non-2xx API responses
(Error::Api { status, body, .. }).
Development
License
MIT