Plan vehicle routes
curl --request POST \
--url https://b.hudhud.sa/v1/routing/optimization \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"model": {
"jobs": [
{
"id": "delivery-1",
"location": {
"lat": 24.7136,
"lon": 46.6753
},
"demand": 1
}
],
"vehicles": [
{
"id": "vehicle-1",
"routing_profile": "car",
"start_location": {
"lat": 24.7136,
"lon": 46.6753
},
"capacity": 100
}
]
}
}
'import requests
url = "https://b.hudhud.sa/v1/routing/optimization"
payload = { "model": {
"jobs": [
{
"id": "delivery-1",
"location": {
"lat": 24.7136,
"lon": 46.6753
},
"demand": 1
}
],
"vehicles": [
{
"id": "vehicle-1",
"routing_profile": "car",
"start_location": {
"lat": 24.7136,
"lon": 46.6753
},
"capacity": 100
}
]
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: {
jobs: [{id: 'delivery-1', location: {lat: 24.7136, lon: 46.6753}, demand: 1}],
vehicles: [
{
id: 'vehicle-1',
routing_profile: 'car',
start_location: {lat: 24.7136, lon: 46.6753},
capacity: 100
}
]
}
})
};
fetch('https://b.hudhud.sa/v1/routing/optimization', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://b.hudhud.sa/v1/routing/optimization",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => [
'jobs' => [
[
'id' => 'delivery-1',
'location' => [
'lat' => 24.7136,
'lon' => 46.6753
],
'demand' => 1
]
],
'vehicles' => [
[
'id' => 'vehicle-1',
'routing_profile' => 'car',
'start_location' => [
'lat' => 24.7136,
'lon' => 46.6753
],
'capacity' => 100
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://b.hudhud.sa/v1/routing/optimization"
payload := strings.NewReader("{\n \"model\": {\n \"jobs\": [\n {\n \"id\": \"delivery-1\",\n \"location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"demand\": 1\n }\n ],\n \"vehicles\": [\n {\n \"id\": \"vehicle-1\",\n \"routing_profile\": \"car\",\n \"start_location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"capacity\": 100\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://b.hudhud.sa/v1/routing/optimization")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": {\n \"jobs\": [\n {\n \"id\": \"delivery-1\",\n \"location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"demand\": 1\n }\n ],\n \"vehicles\": [\n {\n \"id\": \"vehicle-1\",\n \"routing_profile\": \"car\",\n \"start_location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"capacity\": 100\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://b.hudhud.sa/v1/routing/optimization")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": {\n \"jobs\": [\n {\n \"id\": \"delivery-1\",\n \"location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"demand\": 1\n }\n ],\n \"vehicles\": [\n {\n \"id\": \"vehicle-1\",\n \"routing_profile\": \"car\",\n \"start_location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"capacity\": 100\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"metrics": {
"travel_distance_meters": 123,
"travel_duration_seconds": 123,
"used_vehicle_count": 123
},
"routes": [
{
"metrics": {
"travel_distance_meters": 123,
"travel_duration_seconds": 123
},
"vehicle_id": "<string>",
"visits": [
{
"job_id": "<string>"
}
]
}
],
"unassigned_job_ids": [
"<string>"
]
},
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}Route Optimization
Plan vehicle routes
Alpha API. Plans routes by assigning jobs to vehicles and ordering the stops for each vehicle. The contract may change before general availability.
POST
/
routing
/
optimization
Plan vehicle routes
curl --request POST \
--url https://b.hudhud.sa/v1/routing/optimization \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"model": {
"jobs": [
{
"id": "delivery-1",
"location": {
"lat": 24.7136,
"lon": 46.6753
},
"demand": 1
}
],
"vehicles": [
{
"id": "vehicle-1",
"routing_profile": "car",
"start_location": {
"lat": 24.7136,
"lon": 46.6753
},
"capacity": 100
}
]
}
}
'import requests
url = "https://b.hudhud.sa/v1/routing/optimization"
payload = { "model": {
"jobs": [
{
"id": "delivery-1",
"location": {
"lat": 24.7136,
"lon": 46.6753
},
"demand": 1
}
],
"vehicles": [
{
"id": "vehicle-1",
"routing_profile": "car",
"start_location": {
"lat": 24.7136,
"lon": 46.6753
},
"capacity": 100
}
]
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: {
jobs: [{id: 'delivery-1', location: {lat: 24.7136, lon: 46.6753}, demand: 1}],
vehicles: [
{
id: 'vehicle-1',
routing_profile: 'car',
start_location: {lat: 24.7136, lon: 46.6753},
capacity: 100
}
]
}
})
};
fetch('https://b.hudhud.sa/v1/routing/optimization', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://b.hudhud.sa/v1/routing/optimization",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => [
'jobs' => [
[
'id' => 'delivery-1',
'location' => [
'lat' => 24.7136,
'lon' => 46.6753
],
'demand' => 1
]
],
'vehicles' => [
[
'id' => 'vehicle-1',
'routing_profile' => 'car',
'start_location' => [
'lat' => 24.7136,
'lon' => 46.6753
],
'capacity' => 100
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://b.hudhud.sa/v1/routing/optimization"
payload := strings.NewReader("{\n \"model\": {\n \"jobs\": [\n {\n \"id\": \"delivery-1\",\n \"location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"demand\": 1\n }\n ],\n \"vehicles\": [\n {\n \"id\": \"vehicle-1\",\n \"routing_profile\": \"car\",\n \"start_location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"capacity\": 100\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://b.hudhud.sa/v1/routing/optimization")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": {\n \"jobs\": [\n {\n \"id\": \"delivery-1\",\n \"location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"demand\": 1\n }\n ],\n \"vehicles\": [\n {\n \"id\": \"vehicle-1\",\n \"routing_profile\": \"car\",\n \"start_location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"capacity\": 100\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://b.hudhud.sa/v1/routing/optimization")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": {\n \"jobs\": [\n {\n \"id\": \"delivery-1\",\n \"location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"demand\": 1\n }\n ],\n \"vehicles\": [\n {\n \"id\": \"vehicle-1\",\n \"routing_profile\": \"car\",\n \"start_location\": {\n \"lat\": 24.7136,\n \"lon\": 46.6753\n },\n \"capacity\": 100\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"metrics": {
"travel_distance_meters": 123,
"travel_duration_seconds": 123,
"used_vehicle_count": 123
},
"routes": [
{
"metrics": {
"travel_distance_meters": 123,
"travel_duration_seconds": 123
},
"vehicle_id": "<string>",
"visits": [
{
"job_id": "<string>"
}
]
}
],
"unassigned_job_ids": [
"<string>"
]
},
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}{
"data": "<unknown>",
"error": "",
"ok": true
}Authorizations
JWT Bearer token for authentication. Example: "Bearer YOUR_API_TOKEN_HERE"
Body
application/json
Jobs and vehicles
Jobs and vehicles
Show child attributes
Show child attributes
