📈 自动路线优化
1 IC每次请求
欢迎使用自动路线优化 API(版本 1.0),这是由艾艾普科技有限公司开发的一款人工智能产品。我们的 API 通过在考虑车辆容量、时间窗口和交通状况等各种约束条件的同时,在多个目的地之间寻找最高效的路径来帮助优化配送路线。
演示
尝试我们交互式演示,了解自动路线优化 API 的实际应用:
📈 Automatic Route Optimization Demo
AI การจัดเส้นทางการส่งสินค้าหลายจุดอย่างอัจฉริยะ
入门
-
先决条件
- 艾艾普科技的 API 密钥
- 包含坐标的配送地点列表
- 车辆和配送约束
- 每次请求的最大地点数:100
-
快速入门
- 快速路线计算
- 实时交通状况考虑
- 多车支持
- 基于约束的优化
-
主要功能
- 优化的多站路线规划
- 车辆容量规划
- 时间窗口调度
- 实时交通集成
- 多车队支持
-
安全与合规
- 符合 GDPR 和 PDPA 标准
- 安全的 API 端点
- 传输过程中数据加密
API 端点
| 端点 | 方法 | 描述 | 费用 |
|---|---|---|---|
/v3/store/smart-city/automatic-route-optimization旧版: /route-optimization | POST | 优化多个目的地的配送路线 | 每次请求 1 IC |
功能和能力
核心功能
路线优化 API 提供了一种高效的路线规划和优化方式。以下是其主要功能的摘要:
-
路线规划
- 根据出发地和目的地自动优化路线。
- 计算最短可能的路线,减少燃料消耗和行程时间。
-
司机管理
- 支持为更大的配送作业分配多名司机。
- 根据可用司机数量动态调整路线。
-
可自定义的配送详情
- 允许为以下对象指定配送说明:
- 客服团队(例如,处理说明或指示)。
- 司机(例如,取货点、通话说明)。
- 支持为每个配送站点输入详细信息,包括:
- 收件人姓名、电话、电子邮件和地址。
- 配送物品的描述。
- 允许为以下对象指定配送说明:
-
距离计算
- 提供优化路线的总距离(以公里为单位)。
- 有助于追踪配送成本并有效规划物流。
请求示例
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"
}
]
}'
响应示例
{
"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 参考
端点
POST https://api.iapp.co.th/route-optimization
请求参数
Headers
| 键 | 必需 | 描述 |
|---|---|---|
apikey | 是 | 用于身份验证的 API 密钥。 |
Content-Type | 是 | 必须设置为 application/json。 |
Body (JSON)
| 键 | 类型 | 必需 | 描述 |
|---|---|---|---|
driverSize | Integer | 是 | 可用的司机数量。使用 -1 进行自动优化。 |
origin | Object | 是 | 配送路线的起点。 |
origin.address | String | 是 | 起点的地址。 |
origin.latitude | Float | 是 | 起点的纬度坐标。 |
origin.longitude | Float | 是 | 起点的经度坐标。 |
routes | Array of Objects | 是 | 配送目的地列表。 |
routes[].customerName | String | 是 | 收件人姓名。 |
routes[].customerPhone | String | 是 | 收件人电话号码。 |
routes[].customerMail | String | 否 | 收 件人电子邮件地址。 |
routes[].customerAddress | String | 是 | 配送地点的地址。 |
routes[].item | String | 是 | 配送物品的描述。 |
routes[].instructionCC | String | 否 | 给客服团队的说明。 |
routes[].instructionDriver | String | 否 | 给配送司机的说明。 |
routes[].latitude | Float | 否 | 目的地的纬度坐标。 |
routes[].longitude | Float | 否 | 目的地的经度坐标。 |
响应参数
| 键 | 类型 | 描述 |
|---|---|---|
jobs | Array of Objects | 配送任务详情,包括目的地信息。 |
jobs[].customerName | String | 收件人姓名。 |
jobs[].customerPhone | String | 收件人电话号码。 |
jobs[].customerMail | String | 收件人电子邮件(如果提供)。 |
jobs[].customerAddress | String | 配送地点地址。 |
jobs[].item | String | 配送物品描述。 |
jobs[].instructionCC | String | 客服说明。 |
jobs[].instructionDriver | String | 司机说明。 |
jobs[].latitude | Float | 目的地的纬度。 |
jobs[].longitude | Float | 目的地的经度。 |
numberOfDrops | Integer | 路线中的总停靠次数。 |
routes | Array of Strings | 所有路线地址列表。 |
totalDistanceKm | Float | 路线总距离(公里)。 |
代码示例
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);
}
代码示例
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);
定价
| AI API 服务名称 | 每次请求 IC | 本地部署 |
|---|---|---|
| 自动路线优化 | 1 IC/请求 | 联系我们 |