Solve a vehicle routing problem
curl --request POST \
--url https://api.justrouting.tech/optimize \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"vehicles": [
{
"id": 1,
"profile": "car",
"start": [
103.79234106,
1.32463108
],
"end": [
103.79234106,
1.32463108
]
},
{
"id": 2,
"profile": "car",
"start": [
103.82324228,
1.32408622
],
"end": [
103.82324228,
1.32408622
]
}
],
"jobs": [
{
"id": 1,
"location": [
103.79751693,
1.31035001
]
},
{
"id": 2,
"location": [
103.78432387,
1.31490148
]
},
{
"id": 3,
"location": [
103.79763397,
1.31980519
]
},
{
"id": 4,
"location": [
103.81234512,
1.31824846
]
},
{
"id": 5,
"location": [
103.82152987,
1.30984208
]
},
{
"id": 6,
"location": [
103.83701939,
1.32143977
]
}
]
}
'import requests
url = "https://api.justrouting.tech/optimize"
payload = {
"vehicles": [
{
"id": 1,
"profile": "car",
"start": [103.79234106, 1.32463108],
"end": [103.79234106, 1.32463108]
},
{
"id": 2,
"profile": "car",
"start": [103.82324228, 1.32408622],
"end": [103.82324228, 1.32408622]
}
],
"jobs": [
{
"id": 1,
"location": [103.79751693, 1.31035001]
},
{
"id": 2,
"location": [103.78432387, 1.31490148]
},
{
"id": 3,
"location": [103.79763397, 1.31980519]
},
{
"id": 4,
"location": [103.81234512, 1.31824846]
},
{
"id": 5,
"location": [103.82152987, 1.30984208]
},
{
"id": 6,
"location": [103.83701939, 1.32143977]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
vehicles: [
{
id: 1,
profile: 'car',
start: [103.79234106, 1.32463108],
end: [103.79234106, 1.32463108]
},
{
id: 2,
profile: 'car',
start: [103.82324228, 1.32408622],
end: [103.82324228, 1.32408622]
}
],
jobs: [
{id: 1, location: [103.79751693, 1.31035001]},
{id: 2, location: [103.78432387, 1.31490148]},
{id: 3, location: [103.79763397, 1.31980519]},
{id: 4, location: [103.81234512, 1.31824846]},
{id: 5, location: [103.82152987, 1.30984208]},
{id: 6, location: [103.83701939, 1.32143977]}
]
})
};
fetch('https://api.justrouting.tech/optimize', 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://api.justrouting.tech/optimize",
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([
'vehicles' => [
[
'id' => 1,
'profile' => 'car',
'start' => [
103.79234106,
1.32463108
],
'end' => [
103.79234106,
1.32463108
]
],
[
'id' => 2,
'profile' => 'car',
'start' => [
103.82324228,
1.32408622
],
'end' => [
103.82324228,
1.32408622
]
]
],
'jobs' => [
[
'id' => 1,
'location' => [
103.79751693,
1.31035001
]
],
[
'id' => 2,
'location' => [
103.78432387,
1.31490148
]
],
[
'id' => 3,
'location' => [
103.79763397,
1.31980519
]
],
[
'id' => 4,
'location' => [
103.81234512,
1.31824846
]
],
[
'id' => 5,
'location' => [
103.82152987,
1.30984208
]
],
[
'id' => 6,
'location' => [
103.83701939,
1.32143977
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.justrouting.tech/optimize"
payload := strings.NewReader("{\n \"vehicles\": [\n {\n \"id\": 1,\n \"profile\": \"car\",\n \"start\": [\n 103.79234106,\n 1.32463108\n ],\n \"end\": [\n 103.79234106,\n 1.32463108\n ]\n },\n {\n \"id\": 2,\n \"profile\": \"car\",\n \"start\": [\n 103.82324228,\n 1.32408622\n ],\n \"end\": [\n 103.82324228,\n 1.32408622\n ]\n }\n ],\n \"jobs\": [\n {\n \"id\": 1,\n \"location\": [\n 103.79751693,\n 1.31035001\n ]\n },\n {\n \"id\": 2,\n \"location\": [\n 103.78432387,\n 1.31490148\n ]\n },\n {\n \"id\": 3,\n \"location\": [\n 103.79763397,\n 1.31980519\n ]\n },\n {\n \"id\": 4,\n \"location\": [\n 103.81234512,\n 1.31824846\n ]\n },\n {\n \"id\": 5,\n \"location\": [\n 103.82152987,\n 1.30984208\n ]\n },\n {\n \"id\": 6,\n \"location\": [\n 103.83701939,\n 1.32143977\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.justrouting.tech/optimize")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"vehicles\": [\n {\n \"id\": 1,\n \"profile\": \"car\",\n \"start\": [\n 103.79234106,\n 1.32463108\n ],\n \"end\": [\n 103.79234106,\n 1.32463108\n ]\n },\n {\n \"id\": 2,\n \"profile\": \"car\",\n \"start\": [\n 103.82324228,\n 1.32408622\n ],\n \"end\": [\n 103.82324228,\n 1.32408622\n ]\n }\n ],\n \"jobs\": [\n {\n \"id\": 1,\n \"location\": [\n 103.79751693,\n 1.31035001\n ]\n },\n {\n \"id\": 2,\n \"location\": [\n 103.78432387,\n 1.31490148\n ]\n },\n {\n \"id\": 3,\n \"location\": [\n 103.79763397,\n 1.31980519\n ]\n },\n {\n \"id\": 4,\n \"location\": [\n 103.81234512,\n 1.31824846\n ]\n },\n {\n \"id\": 5,\n \"location\": [\n 103.82152987,\n 1.30984208\n ]\n },\n {\n \"id\": 6,\n \"location\": [\n 103.83701939,\n 1.32143977\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.justrouting.tech/optimize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"vehicles\": [\n {\n \"id\": 1,\n \"profile\": \"car\",\n \"start\": [\n 103.79234106,\n 1.32463108\n ],\n \"end\": [\n 103.79234106,\n 1.32463108\n ]\n },\n {\n \"id\": 2,\n \"profile\": \"car\",\n \"start\": [\n 103.82324228,\n 1.32408622\n ],\n \"end\": [\n 103.82324228,\n 1.32408622\n ]\n }\n ],\n \"jobs\": [\n {\n \"id\": 1,\n \"location\": [\n 103.79751693,\n 1.31035001\n ]\n },\n {\n \"id\": 2,\n \"location\": [\n 103.78432387,\n 1.31490148\n ]\n },\n {\n \"id\": 3,\n \"location\": [\n 103.79763397,\n 1.31980519\n ]\n },\n {\n \"id\": 4,\n \"location\": [\n 103.81234512,\n 1.31824846\n ]\n },\n {\n \"id\": 5,\n \"location\": [\n 103.82152987,\n 1.30984208\n ]\n },\n {\n \"id\": 6,\n \"location\": [\n 103.83701939,\n 1.32143977\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"error": "<string>",
"summary": {
"cost": 123,
"routes": 123,
"unassigned": 123,
"setup": 123,
"service": 123,
"duration": 123,
"waiting_time": 123,
"priority": 123,
"distance": 123,
"delivery": [
123
],
"pickup": [
123
],
"violations": [
{
"cause": "delay",
"duration": 123
}
]
},
"unassigned": [
{
"id": 123,
"type": "<string>",
"location": [
123
],
"description": "<string>"
}
],
"routes": [
{
"vehicle": 123,
"cost": 123,
"setup": 123,
"service": 123,
"duration": 123,
"waiting_time": 123,
"priority": 123,
"distance": 123,
"geometry": "<string>",
"delivery": [
123
],
"pickup": [
123
],
"description": "<string>",
"steps": [
{
"type": "start",
"id": 123,
"arrival": 123,
"duration": 123,
"setup": 123,
"service": 123,
"waiting_time": 123,
"distance": 123,
"location": [
123
],
"load": [
123
],
"description": "<string>",
"violations": [
{
"cause": "delay",
"duration": 123
}
]
}
],
"violations": [
{
"cause": "delay",
"duration": 123
}
]
}
]
}{
"code": 123,
"error": "<string>"
}{
"code": "missing_auth",
"message": "<string>"
}{
"code": "rate_limited",
"message": "<string>"
}API Reference
Solve a vehicle routing problem
POST
/
optimize
Solve a vehicle routing problem
curl --request POST \
--url https://api.justrouting.tech/optimize \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"vehicles": [
{
"id": 1,
"profile": "car",
"start": [
103.79234106,
1.32463108
],
"end": [
103.79234106,
1.32463108
]
},
{
"id": 2,
"profile": "car",
"start": [
103.82324228,
1.32408622
],
"end": [
103.82324228,
1.32408622
]
}
],
"jobs": [
{
"id": 1,
"location": [
103.79751693,
1.31035001
]
},
{
"id": 2,
"location": [
103.78432387,
1.31490148
]
},
{
"id": 3,
"location": [
103.79763397,
1.31980519
]
},
{
"id": 4,
"location": [
103.81234512,
1.31824846
]
},
{
"id": 5,
"location": [
103.82152987,
1.30984208
]
},
{
"id": 6,
"location": [
103.83701939,
1.32143977
]
}
]
}
'import requests
url = "https://api.justrouting.tech/optimize"
payload = {
"vehicles": [
{
"id": 1,
"profile": "car",
"start": [103.79234106, 1.32463108],
"end": [103.79234106, 1.32463108]
},
{
"id": 2,
"profile": "car",
"start": [103.82324228, 1.32408622],
"end": [103.82324228, 1.32408622]
}
],
"jobs": [
{
"id": 1,
"location": [103.79751693, 1.31035001]
},
{
"id": 2,
"location": [103.78432387, 1.31490148]
},
{
"id": 3,
"location": [103.79763397, 1.31980519]
},
{
"id": 4,
"location": [103.81234512, 1.31824846]
},
{
"id": 5,
"location": [103.82152987, 1.30984208]
},
{
"id": 6,
"location": [103.83701939, 1.32143977]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
vehicles: [
{
id: 1,
profile: 'car',
start: [103.79234106, 1.32463108],
end: [103.79234106, 1.32463108]
},
{
id: 2,
profile: 'car',
start: [103.82324228, 1.32408622],
end: [103.82324228, 1.32408622]
}
],
jobs: [
{id: 1, location: [103.79751693, 1.31035001]},
{id: 2, location: [103.78432387, 1.31490148]},
{id: 3, location: [103.79763397, 1.31980519]},
{id: 4, location: [103.81234512, 1.31824846]},
{id: 5, location: [103.82152987, 1.30984208]},
{id: 6, location: [103.83701939, 1.32143977]}
]
})
};
fetch('https://api.justrouting.tech/optimize', 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://api.justrouting.tech/optimize",
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([
'vehicles' => [
[
'id' => 1,
'profile' => 'car',
'start' => [
103.79234106,
1.32463108
],
'end' => [
103.79234106,
1.32463108
]
],
[
'id' => 2,
'profile' => 'car',
'start' => [
103.82324228,
1.32408622
],
'end' => [
103.82324228,
1.32408622
]
]
],
'jobs' => [
[
'id' => 1,
'location' => [
103.79751693,
1.31035001
]
],
[
'id' => 2,
'location' => [
103.78432387,
1.31490148
]
],
[
'id' => 3,
'location' => [
103.79763397,
1.31980519
]
],
[
'id' => 4,
'location' => [
103.81234512,
1.31824846
]
],
[
'id' => 5,
'location' => [
103.82152987,
1.30984208
]
],
[
'id' => 6,
'location' => [
103.83701939,
1.32143977
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.justrouting.tech/optimize"
payload := strings.NewReader("{\n \"vehicles\": [\n {\n \"id\": 1,\n \"profile\": \"car\",\n \"start\": [\n 103.79234106,\n 1.32463108\n ],\n \"end\": [\n 103.79234106,\n 1.32463108\n ]\n },\n {\n \"id\": 2,\n \"profile\": \"car\",\n \"start\": [\n 103.82324228,\n 1.32408622\n ],\n \"end\": [\n 103.82324228,\n 1.32408622\n ]\n }\n ],\n \"jobs\": [\n {\n \"id\": 1,\n \"location\": [\n 103.79751693,\n 1.31035001\n ]\n },\n {\n \"id\": 2,\n \"location\": [\n 103.78432387,\n 1.31490148\n ]\n },\n {\n \"id\": 3,\n \"location\": [\n 103.79763397,\n 1.31980519\n ]\n },\n {\n \"id\": 4,\n \"location\": [\n 103.81234512,\n 1.31824846\n ]\n },\n {\n \"id\": 5,\n \"location\": [\n 103.82152987,\n 1.30984208\n ]\n },\n {\n \"id\": 6,\n \"location\": [\n 103.83701939,\n 1.32143977\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.justrouting.tech/optimize")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"vehicles\": [\n {\n \"id\": 1,\n \"profile\": \"car\",\n \"start\": [\n 103.79234106,\n 1.32463108\n ],\n \"end\": [\n 103.79234106,\n 1.32463108\n ]\n },\n {\n \"id\": 2,\n \"profile\": \"car\",\n \"start\": [\n 103.82324228,\n 1.32408622\n ],\n \"end\": [\n 103.82324228,\n 1.32408622\n ]\n }\n ],\n \"jobs\": [\n {\n \"id\": 1,\n \"location\": [\n 103.79751693,\n 1.31035001\n ]\n },\n {\n \"id\": 2,\n \"location\": [\n 103.78432387,\n 1.31490148\n ]\n },\n {\n \"id\": 3,\n \"location\": [\n 103.79763397,\n 1.31980519\n ]\n },\n {\n \"id\": 4,\n \"location\": [\n 103.81234512,\n 1.31824846\n ]\n },\n {\n \"id\": 5,\n \"location\": [\n 103.82152987,\n 1.30984208\n ]\n },\n {\n \"id\": 6,\n \"location\": [\n 103.83701939,\n 1.32143977\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.justrouting.tech/optimize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"vehicles\": [\n {\n \"id\": 1,\n \"profile\": \"car\",\n \"start\": [\n 103.79234106,\n 1.32463108\n ],\n \"end\": [\n 103.79234106,\n 1.32463108\n ]\n },\n {\n \"id\": 2,\n \"profile\": \"car\",\n \"start\": [\n 103.82324228,\n 1.32408622\n ],\n \"end\": [\n 103.82324228,\n 1.32408622\n ]\n }\n ],\n \"jobs\": [\n {\n \"id\": 1,\n \"location\": [\n 103.79751693,\n 1.31035001\n ]\n },\n {\n \"id\": 2,\n \"location\": [\n 103.78432387,\n 1.31490148\n ]\n },\n {\n \"id\": 3,\n \"location\": [\n 103.79763397,\n 1.31980519\n ]\n },\n {\n \"id\": 4,\n \"location\": [\n 103.81234512,\n 1.31824846\n ]\n },\n {\n \"id\": 5,\n \"location\": [\n 103.82152987,\n 1.30984208\n ]\n },\n {\n \"id\": 6,\n \"location\": [\n 103.83701939,\n 1.32143977\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"error": "<string>",
"summary": {
"cost": 123,
"routes": 123,
"unassigned": 123,
"setup": 123,
"service": 123,
"duration": 123,
"waiting_time": 123,
"priority": 123,
"distance": 123,
"delivery": [
123
],
"pickup": [
123
],
"violations": [
{
"cause": "delay",
"duration": 123
}
]
},
"unassigned": [
{
"id": 123,
"type": "<string>",
"location": [
123
],
"description": "<string>"
}
],
"routes": [
{
"vehicle": 123,
"cost": 123,
"setup": 123,
"service": 123,
"duration": 123,
"waiting_time": 123,
"priority": 123,
"distance": 123,
"geometry": "<string>",
"delivery": [
123
],
"pickup": [
123
],
"description": "<string>",
"steps": [
{
"type": "start",
"id": 123,
"arrival": 123,
"duration": 123,
"setup": 123,
"service": 123,
"waiting_time": 123,
"distance": 123,
"location": [
123
],
"load": [
123
],
"description": "<string>",
"violations": [
{
"cause": "delay",
"duration": 123
}
]
}
],
"violations": [
{
"cause": "delay",
"duration": 123
}
]
}
]
}{
"code": 123,
"error": "<string>"
}{
"code": "missing_auth",
"message": "<string>"
}{
"code": "rate_limited",
"message": "<string>"
}Authorizations
API key created in the JustRouting dashboard.
Body
application/json
Available vehicles. Free plan: up to 10; Hobby: up to 50.
Show child attributes
Show child attributes
Tasks to serve. Free plan: up to 100; Hobby: up to 1,000.
Show child attributes
Show child attributes
Pickup-and-delivery tasks (pickup must precede delivery).
Show child attributes
Show child attributes
Optional custom travel-time matrices per profile; skips OSRM table calls.
Show child attributes
Show child attributes
Add polyline geometry to each route in the response.
