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.

To obtain a premium API key, contact the Afdal Products administration team at ali_z_1@outlook.com.

API Reference

POST /api/v1/optimize JSON-based route optimization

Submits delivery locations, vehicle capacities, and time windows to receive an optimized routing plan.

Content-Type: application/json

Request Body Parameters

FieldTypeDescriptionDefault
deliveriesArrayList of delivery location objectsRequired
num_vehiclesIntegerNumber of available drivers/vehicles3
vehicle_capacityFloatMaximum weight each vehicle can carry100.0
depot_latFloatLatitude of the starting/ending depot48.8566
depot_lonFloatLongitude of the depot2.3522
time_limitIntegerMax solver execution time (seconds)10
routing_modeStringProfile: car, bike, walking"car"
solverStringAlgorithm: exact (default) or heuristic (advanced)"exact"

Delivery Object

FieldTypeDescriptionDefault
addressStringName or address of the client/locationRequired
latFloatLatitude of the delivery pointRequired
lonFloatLongitude of the delivery pointRequired
weightFloatCapacity weight required for this deliveryRequired
time_window_startIntegerEarliest arrival (minutes from start)0
time_window_endIntegerLatest arrival (minutes from start)480

Example Request

curl
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
  }'
POST /api/v1/optimize-file File-based bulk optimization

Upload a JSON file containing the optimization payload. Ideal for legacy systems or large datasets.

Content-Type: multipart/form-data

Example Request

curl
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.

response.json
{
  "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": []
}
FieldDescription
routesArray of vehicle tours with stops, distances, and loads
total_distanceCumulative distance of all routes (km)
vehicles_usedTotal number of vehicles deployed
unassigned_deliveriesDeliveries that could not be assigned
Download Collection