Skip to main content

📈 Automatic Route Optimization

📈 AI การจัดเส้นทางการส่งสินค้าหลายจุดอย่างอัจฉริยะ

Version Status Production Legacy

Welcome to the Automatic Route Optimization API, version 1.0, an AI product developed by iApp Technology Co., Ltd. Our API helps optimize delivery routes by finding the most efficient path between multiple destinations while considering various constraints like vehicle capacity, time windows, and traffic conditions.

Demo

Try our interactive demo to see the Automatic Route Optimization API in action:

📈 Automatic Route Optimization Demo

AI การจัดเส้นทางการส่งสินค้าหลายจุดอย่างอัจฉริยะ

Configuration / การตั้งค่า

💡 Driver size determines how many drivers are available for route optimization.

Origin / จุดเริ่มต้น

Routes / เส้นทางส่งของ

Route 1

Getting Started

  1. Prerequisites

    • An API key from iApp Technology
    • List of delivery locations with coordinates
    • Vehicle and delivery constraints
    • Maximum locations per request: 100
  2. Quick Start

    • Fast route calculation
    • Real-time traffic consideration
    • Multiple vehicle support
    • Constraint-based optimization
  3. Key Features

    • Optimized multi-stop routing
    • Vehicle capacity planning
    • Time window scheduling
    • Real-time traffic integration
    • Multiple vehicle fleet support
  4. Security & Compliance

    • GDPR and PDPA compliant
    • Secure API endpoints
    • Data encryption in transit

API Endpoints

EndpointMethodDescriptionCost
/v3/store/smart-city/automatic-route-optimization
Legacy: /route-optimization
POSTOptimize delivery routes for multiple destinations1 IC per request

Features and Capabilities

Core Features

The Route Optimization API provides an efficient way to plan and optimize delivery routes. Below is a summary of its key features:

  • Route Planning

    • Automatically optimizes routes based on the origin and destinations.
    • Calculates the shortest possible route, reducing fuel consumption and travel time.
  • Driver Management

    • Supports assigning multiple drivers for larger delivery operations.
    • Dynamic route adjustments based on the number of available drivers.
  • Customizable Delivery Details

    • Allows specifying delivery instructions for:
      • Customer care team (e.g., handling notes or instructions).
      • Drivers (e.g., drop-off points, call instructions).
    • Supports detailed input for each delivery stop, including:
      • Recipient name, phone number, email, and address.
      • Description of the delivery item.
  • Distance Calculation

    • Provides the total distance (in kilometers) for the optimized route.
    • Helps in tracking delivery costs and planning logistics effectively.

Request Example

curl --location 'https://api.iapp.co.th/route-optimization' \
--header 'apikey: {YOUR API KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{
"driverSize": -1,
"origin": {
"address": "บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส",
"latitude": 13.7882814,
"longitude": 100.5528693
},
"routes": [
{
"customerName": "Kobkrit Viriyayudhakorn",
"customerPhone": "0812345678",
"customerMail": "abc@google.com",
"customerAddress": "202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
"item": "Lanch box p23",
"instructionCC": "Next to Rachativee BTS station",
"instructionDriver": "Call me when arrive",
"latitude": 13.788463744195484,
"longitude": 100.5550741266538
},
{
"customerName": "Tanun C Lannon",
"customerPhone": "0890042785",
"customerMail": "def@google.com",
"customerAddress": "Big C Saphan Kwai",
"item": "2 Box of Coffee"
}
]
}'

Response Example

{
"jobs": [
{
"customerName": "Kobkrit Viriyayudhakorn",
"customerPhone": "0812345678",
"customerMail": "abc@google.com",
"customerAddress": "202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
"item": "Lanch box p23",
"instructionCC": "Next to Rachativee BTS station",
"instructionDriver": "Call me when arrive",
"latitude": 13.788463744195486,
"longitude": 100.5550741266538
},
{
"customerName": "Tanun C Lannon",
"customerPhone": "0890042785",
"customerMail": "def@google.com",
"customerAddress": "Big C Saphan Kwai",
"item": "2 Box of Coffee",
"instructionCC": "",
"instructionDriver": ""
}
],
"numberOfDrops": 2,
"routes": ["202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400", "Big C Saphan Kwai"],
"totalDistanceKm": 5.32
}

API Reference

Endpoint

POST https://api.iapp.co.th/route-optimization

Request Parameters

Headers

KeyRequiredDescription
apikeyYesAPI key for authentication.
Content-TypeYesMust be set to application/json.

Body (JSON)

KeyTypeRequiredDescription
driverSizeIntegerYesThe number of drivers available for delivery. Use -1 for auto-optimize.
originObjectYesThe starting point of the delivery route.
origin.addressStringYesAddress of the origin.
origin.latitudeFloatYesLatitude coordinate of the origin.
origin.longitudeFloatYesLongitude coordinate of the origin.
routesArray of ObjectsYesList of delivery destinations.
routes[].customerNameStringYesName of the recipient.
routes[].customerPhoneStringYesPhone number of the recipient.
routes[].customerMailStringNoEmail address of the recipient.
routes[].customerAddressStringYesAddress of the delivery location.
routes[].itemStringYesDescription of the delivery item.
routes[].instructionCCStringNoInstructions for the customer care team.
routes[].instructionDriverStringNoInstructions for the delivery driver.
routes[].latitudeFloatNoLatitude coordinate of the destination.
routes[].longitudeFloatNoLongitude coordinate of the destination.

Response Parameters

KeyTypeDescription
jobsArray of ObjectsDetails of the delivery jobs including destination info.
jobs[].customerNameStringName of the recipient.
jobs[].customerPhoneStringPhone number of the recipient.
jobs[].customerMailStringEmail of the recipient (if provided).
jobs[].customerAddressStringAddress of the delivery location.
jobs[].itemStringDescription of the delivery item.
jobs[].instructionCCStringInstructions for customer care.
jobs[].instructionDriverStringInstructions for the delivery driver.
jobs[].latitudeFloatLatitude of the destination.
jobs[].longitudeFloatLongitude of the destination.
numberOfDropsIntegerTotal number of stops in the route.
routesArray of StringsList of all route addresses.
totalDistanceKmFloatTotal distance of the route in kilometers.

Code Example

Python

import requests
import json

url = "https://api.iapp.co.th/route-optimization"

payload = json.dumps({
"driverSize": -1,
"origin": {
"address": "บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส",
"latitude": 13.7882814,
"longitude": 100.5528693
},
"routes": [
{
"customerName": "Kobkrit Viriyayudhakorn",
"customerPhone": "0812345678",
"customerMail": "abc@google.com",
"customerAddress": "บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส 202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
"item": "Lanch box p23",
"instructionCC": "Next to Rachativee BTS station",
"instructionDriver": "Call me when arrive",
"latitude": 13.788463744195484,
"longitude": 100.5550741266538
},
{
"customerName": "Tanun C Lannon",
"customerPhone": "0890042785",
"customerMail": "def@google.com",
"customerAddress": "บิ๊กซี ซูเปอร์เซ็นเตอร์ สะพานควาย 618 1 ถ. พหลโยธิน แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
"item": "2 Box of Coffee",
"instructionCC": "",
"instructionDriver": ""
},
{
"customerName": "Johny",
"customerPhone": "0812345677",
"customerMail": "ghi@google.com",
"customerAddress": "Central Ladprao 1693 ถ. พหลโยธิน แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900",
"item": "Letter",
"instructionCC": "Be careful",
"instructionDriver": ""
},
{
"customerName": "คุณเค้ก",
"customerPhone": "0876543212",
"customerAddress": "J.J Mall 588 ถนน กำแพงเพชร 2 แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900",
"item": "2 Cup of Golden Tomato Juice",
"instructionCC": "ฝากไว้ที่รูปปั้น",
"instructionDriver": "Call me when arrive",
"latitude": 13.80216676654782,
"longitude": 100.54899906898275
},
{
"customerName": "Umbrella corporation",
"customerPhone": "0142419514",
"customerAddress": "Future Park Rangsit 94 ถ. พหลโยธิน ตำบล ประชาธิปัตย์ อำเภอธัญบุรี ปทุมธานี 12130",
"item": "photo",
"instructionCC": "ฝากไว้ที่รูปปั้น",
"instructionDriver": "Call me when arrive",
"latitude": 13.989517181399442,
"longitude": 100.61792848432681
}
]
})
headers = {
'apikey': '{YOUR API KEY}',
'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

JavaScript

const axios = require("axios")
let data = JSON.stringify({
driverSize: -1,
origin: {
address: "บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส",
latitude: 13.7882814,
longitude: 100.5528693,
},
routes: [
{
customerName: "Kobkrit Viriyayudhakorn",
customerPhone: "0812345678",
customerMail: "abc@google.com",
customerAddress: "บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส 202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
item: "Lanch box p23",
instructionCC: "Next to Rachativee BTS station",
instructionDriver: "Call me when arrive",
latitude: 13.788463744195484,
longitude: 100.5550741266538,
},
{
customerName: "Tanun C Lannon",
customerPhone: "0890042785",
customerMail: "def@google.com",
customerAddress: "บิ๊กซี ซูเปอร์เซ็นเตอร์ สะพานควาย 618 1 ถ. พหลโยธิน แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
item: "2 Box of Coffee",
instructionCC: "",
instructionDriver: "",
},
{
customerName: "Johny",
customerPhone: "0812345677",
customerMail: "ghi@google.com",
customerAddress: "Central Ladprao 1693 ถ. พหลโยธิน แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900",
item: "Letter",
instructionCC: "Be careful",
instructionDriver: "",
},
{
customerName: "คุณเค้ก",
customerPhone: "0876543212",
customerAddress: "J.J Mall 588 ถนน กำแพงเพชร 2 แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900",
item: "2 Cup of Golden Tomato Juice",
instructionCC: "ฝากไว้ที่รูปปั้น",
instructionDriver: "Call me when arrive",
latitude: 13.80216676654782,
longitude: 100.54899906898275,
},
{
customerName: "Umbrella corporation",
customerPhone: "0142419514",
customerAddress: "Future Park Rangsit 94 ถ. พหลโยธิน ตำบล ประชาธิปัตย์ อำเภอธัญบุรี ปทุมธานี 12130",
item: "photo",
instructionCC: "ฝากไว้ที่รูปปั้น",
instructionDriver: "Call me when arrive",
latitude: 13.989517181399442,
longitude: 100.61792848432681,
},
],
})

let config = {
method: "post",
maxBodyLength: Infinity,
url: "https://api.iapp.co.th/route-optimization",
headers: {
apikey: "{YOUR API KEY}",
"Content-Type": "application/json",
},
data: data,
}

axios
.request(config)
.then((response) => {
console.log(JSON.stringify(response.data))
})
.catch((error) => {
console.log(error)
})

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.iapp.co.th/route-optimization',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"driverSize": -1,
"origin":{
"address":"บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส",
"latitude": 13.7882814,
"longitude": 100.5528693
},
"routes": [
{
"customerName": "Kobkrit Viriyayudhakorn",
"customerPhone": "0812345678",
"customerMail": "abc@google.com",
"customerAddress": "บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส 202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
"item": "Lanch box p23",
"instructionCC": "Next to Rachativee BTS station",
"instructionDriver": "Call me when arrive",
"latitude": 13.788463744195484,
"longitude": 100.5550741266538
},
{
"customerName": "Tanun C Lannon",
"customerPhone": "0890042785",
"customerMail": "def@google.com",
"customerAddress": "บิ๊กซี ซูเปอร์เซ็นเตอร์ สะพานควาย 618 1 ถ. พหลโยธิน แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
"item": "2 Box of Coffee",
"instructionCC": "",
"instructionDriver": ""
},
{
"customerName": "Johny",
"customerPhone": "0812345677",
"customerMail": "ghi@google.com",
"customerAddress": "Central Ladprao 1693 ถ. พหลโยธิน แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900",
"item": "Letter",
"instructionCC": "Be careful",
"instructionDriver": ""
},
{
"customerName": "คุณเค้ก",
"customerPhone": "0876543212",
"customerAddress": "J.J Mall 588 ถนน กำแพงเพชร 2 แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900",
"item": "2 Cup of Golden Tomato Juice",
"instructionCC": "ฝากไว้ที่รูปปั้น",
"instructionDriver": "Call me when arrive",
"latitude": 13.80216676654782,
"longitude": 100.54899906898275
},
{
"customerName": "Umbrella corporation",
"customerPhone": "0142419514",
"customerAddress": "Future Park Rangsit 94 ถ. พหลโยธิน ตำบล ประชาธิปัตย์ อำเภอธัญบุรี ปทุมธานี 12130",
"item": "photo",
"instructionCC": "ฝากไว้ที่รูปปั้น",
"instructionDriver": "Call me when arrive",
"latitude": 13.989517181399443,
"longitude": 100.61792848432681
}
]
}',
CURLOPT_HTTPHEADER => array(
'apikey: {YOUR API KEY}',
'Content-Type: application/json'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Swift

let parameters = "{\n\t\"driverSize\": -1,\n\t\"origin\":{\n\t\t\"address\":\"บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส\",\n\t\t\"latitude\": 13.7882814,\n\t\t\"longitude\": 100.5528693\n\t},\n\t\"routes\": [\n\t\t{\n\t\t\t\"customerName\": \"Kobkrit Viriyayudhakorn\",\n\t\t\t\"customerPhone\": \"0812345678\",\n\t\t\t\"customerMail\": \"abc@google.com\",\n\t\t\t\"customerAddress\": \"บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส  202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400\",\n\t\t\t\"item\": \"Lanch box p23\",\n\t\t\t\"instructionCC\": \"Next to Rachativee BTS station\",\n\t\t\t\"instructionDriver\": \"Call me when arrive\",\n\t\t\t\"latitude\": 13.788463744195484,\n\t\t\t\"longitude\": 100.5550741266538\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"Tanun C Lannon\",\n\t\t\t\"customerPhone\": \"0890042785\",\n\t\t\t\"customerMail\": \"def@google.com\",\n\t\t\t\"customerAddress\": \"บิ๊กซี ซูเปอร์เซ็นเตอร์ สะพานควาย 618 1 ถ. พหลโยธิน แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400\",\n\t\t\t\"item\": \"2 Box of Coffee\",\n\t\t\t\"instructionCC\": \"\",\n\t\t\t\"instructionDriver\": \"\"\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"Johny\",\n\t\t\t\"customerPhone\": \"0812345677\",\n\t\t\t\"customerMail\": \"ghi@google.com\",\n\t\t\t\"customerAddress\": \"Central Ladprao 1693 ถ. พหลโยธิน แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900\",\n\t\t\t\"item\": \"Letter\",\n\t\t\t\"instructionCC\": \"Be careful\",\n\t\t\t\"instructionDriver\": \"\"\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"คุณเค้ก\",\n\t\t\t\"customerPhone\": \"0876543212\",\n\t\t\t\"customerAddress\": \"J.J Mall 588 ถนน กำแพงเพชร 2 แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900\",\n\t\t\t\"item\": \"2 Cup of Golden Tomato Juice\",\n\t\t\t\"instructionCC\": \"ฝากไว้ที่รูปปั้น\",\n\t\t\t\"instructionDriver\": \"Call me when arrive\",\n\t\t\t\"latitude\": 13.80216676654782,\n\t\t\t\"longitude\": 100.54899906898275\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"Umbrella corporation\",\n\t\t\t\"customerPhone\": \"0142419514\",\n\t\t\t\"customerAddress\": \"Future Park Rangsit 94 ถ. พหลโยธิน ตำบล ประชาธิปัตย์ อำเภอธัญบุรี ปทุมธานี 12130\",\n\t\t\t\"item\": \"photo\",\n\t\t\t\"instructionCC\": \"ฝากไว้ที่รูปปั้น\",\n\t\t\t\"instructionDriver\": \"Call me when arrive\",\n\t\t\t\"latitude\": 13.989517181399443,\n\t\t\t\"longitude\": 100.61792848432681\n\t\t}\n\t]\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://api.iapp.co.th/route-optimization")!,timeoutInterval: Double.infinity)
request.addValue("{YOUR API KEY}", forHTTPHeaderField: "apikey")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}

task.resume()

Kotlin

val client = OkHttpClient()
val mediaType = "application/json".toMediaType()
val body = "{\n\t\"driverSize\": -1,\n\t\"origin\":{\n\t\t\"address\":\"บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส\",\n\t\t\"latitude\": 13.7882814,\n\t\t\"longitude\": 100.5528693\n\t},\n\t\"routes\": [\n\t\t{\n\t\t\t\"customerName\": \"Kobkrit Viriyayudhakorn\",\n\t\t\t\"customerPhone\": \"0812345678\",\n\t\t\t\"customerMail\": \"abc@google.com\",\n\t\t\t\"customerAddress\": \"บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส 202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400\",\n\t\t\t\"item\": \"Lanch box p23\",\n\t\t\t\"instructionCC\": \"Next to Rachativee BTS station\",\n\t\t\t\"instructionDriver\": \"Call me when arrive\",\n\t\t\t\"latitude\": 13.788463744195484,\n\t\t\t\"longitude\": 100.5550741266538\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"Tanun C Lannon\",\n\t\t\t\"customerPhone\": \"0890042785\",\n\t\t\t\"customerMail\": \"def@google.com\",\n\t\t\t\"customerAddress\": \"บิ๊กซี ซูเปอร์เซ็นเตอร์ สะพานควาย 618 1 ถ. พหลโยธิน แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400\",\n\t\t\t\"item\": \"2 Box of Coffee\",\n\t\t\t\"instructionCC\": \"\",\n\t\t\t\"instructionDriver\": \"\"\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"Johny\",\n\t\t\t\"customerPhone\": \"0812345677\",\n\t\t\t\"customerMail\": \"ghi@google.com\",\n\t\t\t\"customerAddress\": \"Central Ladprao 1693 ถ. พหลโยธิน แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900\",\n\t\t\t\"item\": \"Letter\",\n\t\t\t\"instructionCC\": \"Be careful\",\n\t\t\t\"instructionDriver\": \"\"\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"คุณเค้ก\",\n\t\t\t\"customerPhone\": \"0876543212\",\n\t\t\t\"customerAddress\": \"J.J Mall 588 ถนน กำแพงเพชร 2 แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900\",\n\t\t\t\"item\": \"2 Cup of Golden Tomato Juice\",\n\t\t\t\"instructionCC\": \"ฝากไว้ที่รูปปั้น\",\n\t\t\t\"instructionDriver\": \"Call me when arrive\",\n\t\t\t\"latitude\": 13.80216676654782,\n\t\t\t\"longitude\": 100.54899906898275\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"Umbrella corporation\",\n\t\t\t\"customerPhone\": \"0142419514\",\n\t\t\t\"customerAddress\": \"Future Park Rangsit 94 ถ. พหลโยธิน ตำบล ประชาธิปัตย์ อำเภอธัญบุรี ปทุมธานี 12130\",\n\t\t\t\"item\": \"photo\",\n\t\t\t\"instructionCC\": \"ฝากไว้ที่รูปปั้น\",\n\t\t\t\"instructionDriver\": \"Call me when arrive\",\n\t\t\t\"latitude\": 13.989517181399443,\n\t\t\t\"longitude\": 100.61792848432681\n\t\t}\n\t]\n}".toRequestBody(mediaType)
val request = Request.Builder()
.url("https://api.iapp.co.th/route-optimization")
.post(body)
.addHeader("apikey", "{YOUR API KEY}")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()

Java

OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"driverSize\": -1,\n\t\"origin\":{\n\t\t\"address\":\"บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส\",\n\t\t\"latitude\": 13.7882814,\n\t\t\"longitude\": 100.5528693\n\t},\n\t\"routes\": [\n\t\t{\n\t\t\t\"customerName\": \"Kobkrit Viriyayudhakorn\",\n\t\t\t\"customerPhone\": \"0812345678\",\n\t\t\t\"customerMail\": \"abc@google.com\",\n\t\t\t\"customerAddress\": \"บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส 202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400\",\n\t\t\t\"item\": \"Lanch box p23\",\n\t\t\t\"instructionCC\": \"Next to Rachativee BTS station\",\n\t\t\t\"instructionDriver\": \"Call me when arrive\",\n\t\t\t\"latitude\": 13.788463744195484,\n\t\t\t\"longitude\": 100.5550741266538\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"Tanun C Lannon\",\n\t\t\t\"customerPhone\": \"0890042785\",\n\t\t\t\"customerMail\": \"def@google.com\",\n\t\t\t\"customerAddress\": \"บิ๊กซี ซูเปอร์เซ็นเตอร์ สะพานควาย 618 1 ถ. พหลโยธิน แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400\",\n\t\t\t\"item\": \"2 Box of Coffee\",\n\t\t\t\"instructionCC\": \"\",\n\t\t\t\"instructionDriver\": \"\"\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"Johny\",\n\t\t\t\"customerPhone\": \"0812345677\",\n\t\t\t\"customerMail\": \"ghi@google.com\",\n\t\t\t\"customerAddress\": \"Central Ladprao 1693 ถ. พหลโยธิน แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900\",\n\t\t\t\"item\": \"Letter\",\n\t\t\t\"instructionCC\": \"Be careful\",\n\t\t\t\"instructionDriver\": \"\"\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"คุณเค้ก\",\n\t\t\t\"customerPhone\": \"0876543212\",\n\t\t\t\"customerAddress\": \"J.J Mall 588 ถนน กำแพงเพชร 2 แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900\",\n\t\t\t\"item\": \"2 Cup of Golden Tomato Juice\",\n\t\t\t\"instructionCC\": \"ฝากไว้ที่รูปปั้น\",\n\t\t\t\"instructionDriver\": \"Call me when arrive\",\n\t\t\t\"latitude\": 13.80216676654782,\n\t\t\t\"longitude\": 100.54899906898275\n\t\t},\n\t\t{\n\t\t\t\"customerName\": \"Umbrella corporation\",\n\t\t\t\"customerPhone\": \"0142419514\",\n\t\t\t\"customerAddress\": \"Future Park Rangsit 94 ถ. พหลโยธิน ตำบล ประชาธิปัตย์ อำเภอธัญบุรี ปทุมธานี 12130\",\n\t\t\t\"item\": \"photo\",\n\t\t\t\"instructionCC\": \"ฝากไว้ที่รูปปั้น\",\n\t\t\t\"instructionDriver\": \"Call me when arrive\",\n\t\t\t\"latitude\": 13.989517181399443,\n\t\t\t\"longitude\": 100.61792848432681\n\t\t}\n\t]\n}");
Request request = new Request.Builder()
.url("https://api.iapp.co.th/route-optimization")
.method("POST", body)
.addHeader("apikey", "{YOUR API KEY}")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();

Dart

var headers = {
'apikey': '{YOUR API KEY}',
'Content-Type': 'application/json'
};
var request = http.Request('POST', Uri.parse('https://api.iapp.co.th/route-optimization'));
request.body = json.encode({
"driverSize": -1,
"origin": {
"address": "บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส",
"latitude": 13.7882814,
"longitude": 100.5528693
},
"routes": [
{
"customerName": "Kobkrit Viriyayudhakorn",
"customerPhone": "0812345678",
"customerMail": "abc@google.com",
"customerAddress": "บจก. สปีดี้ แพคเก็จ เอ็กซ์เพรส 202/1 ซอย อินทามระ 6 แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
"item": "Lanch box p23",
"instructionCC": "Next to Rachativee BTS station",
"instructionDriver": "Call me when arrive",
"latitude": 13.788463744195484,
"longitude": 100.5550741266538
},
{
"customerName": "Tanun C Lannon",
"customerPhone": "0890042785",
"customerMail": "def@google.com",
"customerAddress": "บิ๊กซี ซูเปอร์เซ็นเตอร์ สะพานควาย 618 1 ถ. พหลโยธิน แขวง สามเสนใน เขตพญาไท กรุงเทพมหานคร 10400",
"item": "2 Box of Coffee",
"instructionCC": "",
"instructionDriver": ""
},
{
"customerName": "Johny",
"customerPhone": "0812345677",
"customerMail": "ghi@google.com",
"customerAddress": "Central Ladprao 1693 ถ. พหลโยธิน แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900",
"item": "Letter",
"instructionCC": "Be careful",
"instructionDriver": ""
},
{
"customerName": "คุณเค้ก",
"customerPhone": "0876543212",
"customerAddress": "J.J Mall 588 ถนน กำแพงเพชร 2 แขวง จตุจักร เขตจตุจักร กรุงเทพมหานคร 10900",
"item": "2 Cup of Golden Tomato Juice",
"instructionCC": "ฝากไว้ที่รูปปั้น",
"instructionDriver": "Call me when arrive",
"latitude": 13.80216676654782,
"longitude": 100.54899906898275
},
{
"customerName": "Umbrella corporation",
"customerPhone": "0142419514",
"customerAddress": "Future Park Rangsit 94 ถ. พหลโยธิน ตำบล ประชาธิปัตย์ อำเภอธัญบุรี ปทุมธานี 12130",
"item": "photo",
"instructionCC": "ฝากไว้ที่รูปปั้น",
"instructionDriver": "Call me when arrive",
"latitude": 13.989517181399442,
"longitude": 100.61792848432681
}
]
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}

Code Examples

Curl

curl -X POST https://api.iapp.co.th/v3/store/smart-city/route-optimization \
-H "apikey: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"locations": [], "constraints": {}}'

Python

import requests
import json

url = "https://api.iapp.co.th/v3/store/smart-city/route-optimization"
headers = {
"apikey": "YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {"locations": [], "constraints": {}}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())

JavaScript

const axios = require("axios");

const config = {
method: "post",
url: "https://api.iapp.co.th/v3/store/smart-city/route-optimization",
headers: {
apikey: "YOUR_API_KEY",
"Content-Type": "application/json",
},
data: {"locations": [], "constraints": {}},
};

axios(config)
.then((response) => console.log(response.data))
.catch((error) => console.log(error));

PHP

<?php
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.iapp.co.th/v3/store/smart-city/route-optimization',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => '{"locations": [], "constraints": {}}',
CURLOPT_HTTPHEADER => array(
'apikey: YOUR_API_KEY',
'Content-Type: application/json'
),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>

Swift

import Foundation

let url = URL(string: "https://api.iapp.co.th/v3/store/smart-city/route-optimization")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("YOUR_API_KEY", forHTTPHeaderField: "apikey")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

let jsonData = try! JSONSerialization.data(withJSONObject: {"locations": [], "constraints": {}})
request.httpBody = jsonData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8)!)
}
}
task.resume()

Kotlin

import okhttp3.*
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.toRequestBody

val client = OkHttpClient()

val json = """
{"locations": [], "constraints": {}}
""".trimIndent()

val requestBody = json.toRequestBody("application/json".toMediaTypeOrNull())

val request = Request.Builder()
.url("https://api.iapp.co.th/v3/store/smart-city/route-optimization")
.addHeader("apikey", "YOUR_API_KEY")
.post(requestBody)
.build()

client.newCall(request).execute().use { response ->
println(response.body?.string())
}

Java

import okhttp3.*;

OkHttpClient client = new OkHttpClient();

String json = "{"locations": [], "constraints": {}}";

RequestBody body = RequestBody.create(
MediaType.parse("application/json"),
json
);

Request request = new Request.Builder()
.url("https://api.iapp.co.th/v3/store/smart-city/route-optimization")
.addHeader("apikey", "YOUR_API_KEY")
.post(body)
.build();

try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}

Dart

import 'package:http/http.dart' as http;
import 'dart:convert';

var headers = {
'apikey': 'YOUR_API_KEY',
'Content-Type': 'application/json'
};

var data = {"locations": [], "constraints": {}};

var response = await http.post(
Uri.parse('https://api.iapp.co.th/v3/store/smart-city/route-optimization'),
headers: headers,
body: jsonEncode(data)
);

print(response.body);

Pricing

AI API Service NameIC Per RequestOn-Premise
Automatic Route Optimization1 IC/RequestContact