📈 Automatic Route Optimization
📈 AI การจัดเส้นทางการส ่งสินค้าหลายจุดอย่างอัจฉริยะ
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 การจัดเส้นทางการส่งสินค้าหลายจุดอย่างอัจฉริยะ
Getting Started
-
Prerequisites
- An API key from iApp Technology
- List of delivery locations with coordinates
- Vehicle and delivery constraints
- Maximum locations per request: 100
-
Quick Start
- Fast route calculation
- Real-time traffic consideration
- Multiple vehicle support
- Constraint-based optimization
-
Key Features
- Optimized multi-stop routing
- Vehicle capacity planning
- Time window scheduling
- Real-time traffic integration
- Multiple vehicle fleet support
-
Security & Compliance
- GDPR and PDPA compliant
- Secure API endpoints
- Data encryption in transit
API Endpoints
| Endpoint | Method | Description | Cost |
|---|---|---|---|
/v3/store/smart-city/automatic-route-optimizationLegacy: /route-optimization | POST | Optimize delivery routes for multiple destinations | 1 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.
- Allows specifying delivery instructions for:
-
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
| Key | Required | Description |
|---|---|---|
apikey | Yes | API key for authentication. |
Content-Type | Yes | Must be set to application/json. |
Body (JSON)
| Key | Type | Required | Description |
|---|---|---|---|
driverSize | Integer | Yes | The number of drivers available for delivery. Use -1 for auto-optimize. |
origin | Object | Yes | The starting point of the delivery route. |
origin.address | String | Yes | Address of the origin. |
origin.latitude | Float | Yes | Latitude coordinate of the origin. |
origin.longitude | Float | Yes | Longitude coordinate of the origin. |
routes | Array of Objects | Yes | List of delivery destinations. |
routes[].customerName | String | Yes | Name of the recipient. |
routes[].customerPhone | String | Yes | Phone number of the recipient. |
routes[].customerMail | String | No | Email address of the recipient. |
routes[].customerAddress | String | Yes | Address of the delivery location. |
routes[].item | String | Yes | Description of the delivery item. |
routes[].instructionCC | String | No | Instructions for the customer care team. |
routes[].instructionDriver | String | No | Instructions for the delivery driver. |
routes[].latitude | Float | No | Latitude coordinate of the destination. |
routes[].longitude | Float | No | Longitude coordinate of the destination. |
Response Parameters
| Key | Type | Description |
|---|---|---|
jobs | Array of Objects | Details of the delivery jobs including destination info. |
jobs[].customerName | String | Name of the recipient. |
jobs[].customerPhone | String | Phone number of the recipient. |
jobs[].customerMail | String | Email of the recipient (if provided). |
jobs[].customerAddress | String | Address of the delivery location. |
jobs[].item | String | Description of the delivery item. |
jobs[].instructionCC | String | Instructions for customer care. |
jobs[].instructionDriver | String | Instructions for the delivery driver. |
jobs[].latitude | Float | Latitude of the destination. |
jobs[].longitude | Float | Longitude of the destination. |
numberOfDrops | Integer | Total number of stops in the route. |
routes | Array of Strings | List of all route addresses. |
totalDistanceKm | Float | Total 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 Name | IC Per Request | On-Premise |
|---|---|---|
| Automatic Route Optimization | 1 IC/Request | Contact |