PUBLIC API V2 · ROUTING + OPTIMIZATION

From a place
to a plan.

Search for a place, route by car or on foot, then optimize a whole fleet. One API key and one base URL: https://api.afdal.tech.

ONE BASE URL API v2
POSTapi.afdal.tech/api/v2/optimize
{
  "mode": "drive",
  "depot": {"lat": 33.8938, "lon": 35.5018},
  "stops": [{"id": "A1", "address": "Hamra",
             "lat": 33.8963, "lon": 35.4841}],
  "fleet": {"vehicles": 1, "capacity": 4}
}
→ Ordered stops + complete road geometry
01

RoutingDrive or walk, through ordered points

02

OptimizationDriving only, with fleet constraints and GeoJSON

03

PlacesAddress and point-of-interest search

START HERE

One key.
One clear path.

Use X-API-Key for routes, optimization and place search. The modes endpoint is public. Keep your key on your server, never in a browser bundle.

  1. 01

    Request your key

    We can set a suitable query and location allowance for your integration.

    Contact Afdal →
  2. 02

    Choose the operation and mode

    Routing supports drive and walk; optimization supports drive only.

  3. 03

    Use the road geometry

    Route and optimization responses include GeoJSON LineString coordinates in [longitude, latitude] order.

first-route.sh
export AFDAL_API_KEY="your-key"

curl -X POST "https://api.afdal.tech/api/v2/route" \
  -H "X-API-Key: $AFDAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode":"drive","points":[
    {"lat":33.8938,"lon":35.5018},
    {"lat":33.8963,"lon":35.4841},
    {"lat":33.8884,"lon":35.5198}
  ]}'

PUBLIC V2 OPERATIONS

Pick the operation.
Keep the same host.

Base URL: https://api.afdal.tech
Request and response details: Read the v2 guide ↗

GET/api/v2/modesAvailable travel modes

Returns {"routing":["drive","walk"],"optimization":["drive"]}. No key required.

POST/api/v2/routeRoad route and geometry

Send mode and an ordered points array of {"lat":…,"lon":…} objects. Points are not reordered. Returns distance in metres, duration in seconds, route legs, and GeoJSON geometry.

POST/api/v2/optimizeStop order, vehicles and geometry

Send a depot, stops, optional fleet and planning. Only mode: "drive" is accepted. The response includes each vehicle’s ordered stops, phone numbers, unassigned IDs, distance, duration and full road-following GeoJSON. The road matrix is used for optimization; there is no straight-line fallback.

GET/api/v2/geocodeAddresses and points of interest

Use q for search text. Add focus_lat and focus_lon together to bias results near a location. Returns names, labels and coordinates.

REAL ROAD GEOMETRY

Order and path, together.

Afdal returns the chosen stop order and a road-following path for each vehicle. Use the distance, duration, and GeoJSON geometry in your own application.

response excerpt
{
  "routes": [{
    "vehicle_id": 1,
    "stops": [{"kind": "depot"}, {"order_id": "A1", "kind": "delivery"}],
    "geometry": {
      "type": "LineString",
      "coordinates": [[35.5018, 33.8938], ...]
    },
    "routing_engines": ["afdal"]
  }],
  "matrix_source": "afdal"
}

LEARN BY RUNNING

Four queries.
One clear progression.

The downloadable notebook shows each request and draws its returned road geometry. The Python runner saves complete JSON and GeoJSON files.

01 / ROUTE

Two points

Send a start and finish to POST /api/v2/route. Read distance_m, duration_s, and the GeoJSON geometry.

02 / OPTIMIZE

Several stops, one vehicle

Send a depot and stops to POST /api/v2/optimize. See the chosen visit order and the vehicle’s distance, driving time, and path.

03 / FLEET

Several stops, two vehicles

Offer two vehicles and a short shift. Inspect each used vehicle’s stops, distance_m, duration_s, and geometry.

04 / CONSTRAINTS

Windows and equal capacities

Give each stop a load and arrival window. Set the same fleet.capacity for both vehicles, then check arrivals, cumulative loads, and unassigned stops.

Driving time excludes service and waiting. Time windows use minutes after midnight: 540 means 09:00. The driving profile chooses a preferred road path; it does not guarantee the fewest metres.

BUILD WITH V2

Download, run,
then use your data.

The v2 package contains JSON requests, a Python runner, a guided Jupyter notebook, a Postman collection, and a README. No credentials are included.

YOUR OPERATION, CONNECTED

Bring us your stops.
We’ll help with the next step.

Ask for an API key or a walkthrough with your own data.