Optimise visit order for multiple stops
curl --request POST \
--url https://api.footstep.ai/v1/routing/optimize \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"locations": [
{
"lat": 51.5322,
"lon": -0.124
},
{
"lat": 51.5055,
"lon": -0.0754
},
{
"lat": 51.5178,
"lon": -0.0823
},
{
"lat": 51.5055,
"lon": -0.0862
}
]
}
'import requests
url = "https://api.footstep.ai/v1/routing/optimize"
payload = { "locations": [
{
"lat": 51.5322,
"lon": -0.124
},
{
"lat": 51.5055,
"lon": -0.0754
},
{
"lat": 51.5178,
"lon": -0.0823
},
{
"lat": 51.5055,
"lon": -0.0862
}
] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
locations: [
{lat: 51.5322, lon: -0.124},
{lat: 51.5055, lon: -0.0754},
{lat: 51.5178, lon: -0.0823},
{lat: 51.5055, lon: -0.0862}
]
})
};
fetch('https://api.footstep.ai/v1/routing/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.footstep.ai/v1/routing/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([
'locations' => [
[
'lat' => 51.5322,
'lon' => -0.124
],
[
'lat' => 51.5055,
'lon' => -0.0754
],
[
'lat' => 51.5178,
'lon' => -0.0823
],
[
'lat' => 51.5055,
'lon' => -0.0862
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.footstep.ai/v1/routing/optimize"
payload := strings.NewReader("{\n \"locations\": [\n {\n \"lat\": 51.5322,\n \"lon\": -0.124\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0754\n },\n {\n \"lat\": 51.5178,\n \"lon\": -0.0823\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0862\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://api.footstep.ai/v1/routing/optimize")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"locations\": [\n {\n \"lat\": 51.5322,\n \"lon\": -0.124\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0754\n },\n {\n \"lat\": 51.5178,\n \"lon\": -0.0823\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0862\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.footstep.ai/v1/routing/optimize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"locations\": [\n {\n \"lat\": 51.5322,\n \"lon\": -0.124\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0754\n },\n {\n \"lat\": 51.5178,\n \"lon\": -0.0823\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0862\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"route": {
"waypoints": [
{
"lat": 123,
"lon": 123,
"original_index": 123
}
],
"legs": [
{
"distance_meters": 123,
"duration_seconds": 123,
"shape": "<string>",
"steps": [
{
"instruction": "<string>",
"street_names": [
"<string>"
],
"distance_meters": 123,
"duration_seconds": 123,
"begin_shape_index": 123,
"end_shape_index": 123,
"travel_mode": "<string>",
"flags": {
"toll": true,
"ferry": true,
"rough": true,
"gate": true,
"highway": true
},
"verbal_alert": "<string>",
"verbal_instruction": "<string>",
"bearing_before": 123,
"bearing_after": 123,
"roundabout_exit_count": 123,
"exit_sign": {
"exit_number": "<string>",
"exit_branch": "<string>",
"exit_toward": "<string>",
"exit_name": "<string>"
},
"lanes": [
{
"indications": [
"<string>"
],
"valid": true,
"active": true
}
]
}
],
"terrain": {
"total_ascent_meters": 123,
"total_descent_meters": 123,
"max_elevation_meters": 123,
"min_elevation_meters": 123,
"avg_grade_percent": 123,
"max_grade_percent": 123,
"elevation_profile": [
{
"distance_meters": 123,
"elevation_meters": 123
}
]
},
"flags": {
"has_toll": true,
"has_highway": true,
"has_ferry": true
},
"bounds": {
"min_lat": 123,
"min_lon": 123,
"max_lat": 123,
"max_lon": 123
}
}
],
"distance_meters": 123,
"duration_seconds": 123,
"flags": {
"has_toll": true,
"has_highway": true,
"has_ferry": true
},
"bounds": {
"min_lat": 123,
"min_lon": 123,
"max_lat": 123,
"max_lon": 123
},
"terrain": {
"total_ascent_meters": 123,
"total_descent_meters": 123,
"max_elevation_meters": 123,
"min_elevation_meters": 123,
"avg_grade_percent": 123,
"max_grade_percent": 123,
"elevation_profile": [
{
"distance_meters": 123,
"elevation_meters": 123
}
]
},
"units": "<string>",
"narrative": "<string>"
},
"optimized_order": [
123
],
"savings": {
"distance_saved_meters": 123,
"distance_saved_percent": 123,
"time_saved_seconds": 123,
"time_saved_percent": 123
}
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Routing
Optimise Route
Find the optimal order to visit multiple locations. Returns the optimised route with terrain analytics and savings (distance and time) compared to the original order.
POST
/
v1
/
routing
/
optimize
Optimise visit order for multiple stops
curl --request POST \
--url https://api.footstep.ai/v1/routing/optimize \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"locations": [
{
"lat": 51.5322,
"lon": -0.124
},
{
"lat": 51.5055,
"lon": -0.0754
},
{
"lat": 51.5178,
"lon": -0.0823
},
{
"lat": 51.5055,
"lon": -0.0862
}
]
}
'import requests
url = "https://api.footstep.ai/v1/routing/optimize"
payload = { "locations": [
{
"lat": 51.5322,
"lon": -0.124
},
{
"lat": 51.5055,
"lon": -0.0754
},
{
"lat": 51.5178,
"lon": -0.0823
},
{
"lat": 51.5055,
"lon": -0.0862
}
] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
locations: [
{lat: 51.5322, lon: -0.124},
{lat: 51.5055, lon: -0.0754},
{lat: 51.5178, lon: -0.0823},
{lat: 51.5055, lon: -0.0862}
]
})
};
fetch('https://api.footstep.ai/v1/routing/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.footstep.ai/v1/routing/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([
'locations' => [
[
'lat' => 51.5322,
'lon' => -0.124
],
[
'lat' => 51.5055,
'lon' => -0.0754
],
[
'lat' => 51.5178,
'lon' => -0.0823
],
[
'lat' => 51.5055,
'lon' => -0.0862
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.footstep.ai/v1/routing/optimize"
payload := strings.NewReader("{\n \"locations\": [\n {\n \"lat\": 51.5322,\n \"lon\": -0.124\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0754\n },\n {\n \"lat\": 51.5178,\n \"lon\": -0.0823\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0862\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://api.footstep.ai/v1/routing/optimize")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"locations\": [\n {\n \"lat\": 51.5322,\n \"lon\": -0.124\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0754\n },\n {\n \"lat\": 51.5178,\n \"lon\": -0.0823\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0862\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.footstep.ai/v1/routing/optimize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"locations\": [\n {\n \"lat\": 51.5322,\n \"lon\": -0.124\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0754\n },\n {\n \"lat\": 51.5178,\n \"lon\": -0.0823\n },\n {\n \"lat\": 51.5055,\n \"lon\": -0.0862\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"route": {
"waypoints": [
{
"lat": 123,
"lon": 123,
"original_index": 123
}
],
"legs": [
{
"distance_meters": 123,
"duration_seconds": 123,
"shape": "<string>",
"steps": [
{
"instruction": "<string>",
"street_names": [
"<string>"
],
"distance_meters": 123,
"duration_seconds": 123,
"begin_shape_index": 123,
"end_shape_index": 123,
"travel_mode": "<string>",
"flags": {
"toll": true,
"ferry": true,
"rough": true,
"gate": true,
"highway": true
},
"verbal_alert": "<string>",
"verbal_instruction": "<string>",
"bearing_before": 123,
"bearing_after": 123,
"roundabout_exit_count": 123,
"exit_sign": {
"exit_number": "<string>",
"exit_branch": "<string>",
"exit_toward": "<string>",
"exit_name": "<string>"
},
"lanes": [
{
"indications": [
"<string>"
],
"valid": true,
"active": true
}
]
}
],
"terrain": {
"total_ascent_meters": 123,
"total_descent_meters": 123,
"max_elevation_meters": 123,
"min_elevation_meters": 123,
"avg_grade_percent": 123,
"max_grade_percent": 123,
"elevation_profile": [
{
"distance_meters": 123,
"elevation_meters": 123
}
]
},
"flags": {
"has_toll": true,
"has_highway": true,
"has_ferry": true
},
"bounds": {
"min_lat": 123,
"min_lon": 123,
"max_lat": 123,
"max_lon": 123
}
}
],
"distance_meters": 123,
"duration_seconds": 123,
"flags": {
"has_toll": true,
"has_highway": true,
"has_ferry": true
},
"bounds": {
"min_lat": 123,
"min_lon": 123,
"max_lat": 123,
"max_lon": 123
},
"terrain": {
"total_ascent_meters": 123,
"total_descent_meters": 123,
"max_elevation_meters": 123,
"min_elevation_meters": 123,
"avg_grade_percent": 123,
"max_grade_percent": 123,
"elevation_profile": [
{
"distance_meters": 123,
"elevation_meters": 123
}
]
},
"units": "<string>",
"narrative": "<string>"
},
"optimized_order": [
123
],
"savings": {
"distance_saved_meters": 123,
"distance_saved_percent": 123,
"time_saved_seconds": 123,
"time_saved_percent": 123
}
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Authorizations
Your Footstep API key
Body
application/json
Locations (min 4 for TSP)
Required array length:
4 - 50 elementsShow child attributes
Show child attributes
Available options:
auto, bicycle, pedestrian Fine-tuning options. Include only the key matching your travel type.
Show child attributes
Show child attributes
Available options:
kilometers, miles Required range:
10 <= x <= 200Include a natural language summary of the optimised route. Uses AI generation, adds ~500ms latency.
Response format. footstep = optimised for app developers (encoded polyline, flat structure). geojson = standard GeoJSON FeatureCollection (decoded coordinates, immediately usable in Leaflet/Mapbox GL/deck.gl).
Available options:
footstep, geojson ⌘I