Quick Start
Everything you need to get up and running in minutes.
Authentication
All requests must include the X-API-Key header. Contact our team to obtain your premium key.
Base URL
The production API is located at:https://back.laffa.afdal.tech/api/v1
Rate Limits
B2B customers enjoy high-concurrency limits and dedicated processing threads.
API Key Management
Validation
Keys are validated against a secure, persistent database on the server.
Usage Tracking
Every request automatically tracks usage_count and last_used timestamps.
Remote Deactivation
Keys can be deactivated remotely by administrators if misuse is detected.
API Reference
Submits delivery locations, vehicle capacities, and time windows to receive an optimized routing plan.
Content-Type: application/json
Request Body Parameters
| Field | Type | Description | Default |
|---|---|---|---|
| deliveries | Array | List of delivery location objects | Required |
| num_vehicles | Integer | Number of available drivers/vehicles | 3 |
| vehicle_capacity | Float | Maximum weight each vehicle can carry | 100.0 |
| depot_lat | Float | Latitude of the starting/ending depot | 48.8566 |
| depot_lon | Float | Longitude of the depot | 2.3522 |
| time_limit | Integer | Max solver execution time (seconds) | 10 |
| routing_mode | String | Profile: car, bike, walking | "car" |
| solver | String | Algorithm: exact (default) or heuristic (advanced) | "exact" |
Delivery Object
| Field | Type | Description | Default |
|---|---|---|---|
| address | String | Name or address of the client/location | Required |
| lat | Float | Latitude of the delivery point | Required |
| lon | Float | Longitude of the delivery point | Required |
| weight | Float | Capacity weight required for this delivery | Required |
| time_window_start | Integer | Earliest arrival (minutes from start) | 0 |
| time_window_end | Integer | Latest arrival (minutes from start) | 480 |
Example Request
curl -X POST "https://back.laffa.afdal.tech/api/v1/optimize" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"deliveries": [
{
"address": "Client A",
"lat": 33.8938,
"lon": 35.5018,
"weight": 10.0,
"time_window_start": 0,
"time_window_end": 120
}
],
"num_vehicles": 2,
"vehicle_capacity": 50.0,
"depot_lat": 33.8888,
"depot_lon": 35.4968,
"time_limit": 5
}'
Upload a JSON file containing the optimization payload. Ideal for legacy systems or large datasets.
Content-Type: multipart/form-data
Example Request
curl -X POST "https://back.laffa.afdal.tech/api/v1/optimize-file" \ -H "X-API-Key: YOUR_API_KEY" \ -F "file=@/path/to/payload.json;type=application/json"
Response Format
Both endpoints return an identical JSON structure representing the optimized routes.
{
"routes": [
{
"vehicle_id": 1,
"stops": [
{
"address": "DEPOT",
"lat": 33.888764,
"lon": 35.49697,
"weight": 0.0,
"arrival_time": 0,
"cumulative_load": 0.0
},
{
"address": "Client A",
"lat": 33.893667,
"lon": 35.502073,
"weight": 10.0,
"arrival_time": 0,
"cumulative_load": 10.0
}
],
"total_distance": 2.15,
"total_load": 10.0
}
],
"total_distance": 2.15,
"vehicles_used": 1,
"unassigned_deliveries": []
}
| Field | Description |
|---|---|
| routes | Array of vehicle tours with stops, distances, and loads |
| total_distance | Cumulative distance of all routes (km) |
| vehicles_used | Total number of vehicles deployed |
| unassigned_deliveries | Deliveries that could not be assigned |