Skip to main content

📈 การปรับเส้นทางอัตโนมัติ

1 ICต่อการร้องขอ
v1.0 ใช้งานอยู่ POST /v3/store/smart-city/automatic-route-optimization

ยินดีต้อนรับสู่ API การปรับเส้นทางอัตโนมัติ เวอร์ชัน 1.0 ผลิตภัณฑ์ AI ที่พัฒนาโดย บริษัท ไอแอพพ์เทคโนโลยี จำกัด API ของเราช่วยปรับเส้นทางการจัดส่งให้เหมาะสมโดยการค้นหาเส้นทางที่มีประสิทธิภาพที่สุดระหว่างหลายปลายทาง โดยพิจารณาข้อจำกัดต่างๆ เช่น ความจุของยานพาหนะ, ช่วงเวลาที่กำหนด และสภาพการจราจร

เดโม

ลองใช้เดโมแบบโต้ตอบของเราเพื่อดู API การปรับเส้นทางอัตโนมัติในการทำงาน:

📈 Automatic Route Optimization Demo

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

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

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

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

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

Route 1

เริ่มต้นใช้งาน

  1. สิ่งที่ต้องมี

    • คีย์ API จาก บริษัท ไอแอพพ์เทคโนโลยี
    • รายการที่ตั้งสำหรับการจัดส่งพร้อมพิกัด
    • ข้อจำกัดของยานพาหนะและการจัดส่ง
    • จำนวนที่ตั้งสูงสุดต่อการร้องขอ: 100
  2. เริ่มต้นอย่างรวดเร็ว

    • การคำนวณเส้นทางที่รวดเร็ว
    • การพิจารณาสภาพการจราจรแบบเรียลไทม์
    • การรองรับยานพาหนะหลายคัน
    • การปรับให้เหมาะสมตามข้อจำกัด
  3. คุณสมบัติหลัก

    • การปรับเส้นทางหลายจุดให้เหมาะสม
    • การวางแผนความจุยานพาหนะ
    • การกำหนดตารางเวลาตามช่วงเวลา
    • การผสานรวมสภาพการจราจรแบบเรียลไทม์
    • การรองรับยานพาหนะหลายคัน
  4. ความปลอดภัยและการปฏิบัติตามข้อกำหนด

    • เป็นไปตาม 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)

คีย์ประเภทจำเป็นคำอธิบาย
driverSizeIntegerใช่จำนวนผู้ขับขี่ที่มีอยู่สำหรับการจัดส่ง ใช้ -1 สำหรับการปรับให้เหมาะสมอัตโนมัติ
originObjectใช่จุดเริ่มต้นของเส้นทางการจัดส่ง
origin.addressStringใช่ที่อยู่ของต้นทาง
origin.latitudeFloatใช่ละติจูดของต้นทาง
origin.longitudeFloatใช่ลองจิจูดของต้นทาง
routesArray of Objectsใช่รายการจุดหมายปลายทางการจัดส่ง
routes[].customerNameStringใช่ชื่อผู้รับ
routes[].customerPhoneStringใช่หมายเลขโทรศัพท์ของผู้รับ
routes[].customerMailStringไม่ใช่ที่อยู่อีเมลของผู้รับ
routes[].customerAddressStringใช่ที่อยู่ของสถานที่จัดส่ง
routes[].itemStringใช่คำอธิบายสินค้าที่จะจัดส่ง
routes[].instructionCCStringไม่ใช่คำแนะนำสำหรับทีมดูแลลูกค้า
routes[].instructionDriverStringไม่ใช่คำแนะนำสำหรับผู้ขับขี่จัดส่ง
routes[].latitudeFloatไม่ใช่ละติจูดของปลายทาง
routes[].longitudeFloatไม่ใช่ลองจิจูดของปลายทาง

พารามิเตอร์การตอบกลับ

คีย์ประเภทคำอธิบาย
jobsArray of Objectsรายละเอียดงานจัดส่ง รวมถึงข้อมูลปลายทาง
jobs[].customerNameStringชื่อผู้รับ
jobs[].customerPhoneStringหมายเลขโทรศัพท์ของผู้รับ
jobs[].customerMailStringอีเมลของผู้รับ (หากระบุ)
jobs[].customerAddressStringที่อยู่ของสถานที่จัดส่ง
jobs[].itemStringคำอธิบายสินค้าที่จะจัดส่ง
jobs[].instructionCCStringคำแนะนำสำหรับฝ่ายดูแลลูกค้า
jobs[].instructionDriverStringคำแนะนำสำหรับผู้ขับขี่จัดส่ง
jobs[].latitudeFloatละติจูดของปลายทาง
jobs[].longitudeFloatลองจิจูดของปลายทาง
numberOfDropsIntegerจำนวนจุดแวะทั้งหมดในเส้นทาง
routesArray of Stringsรายการที่อยู่ทั้งหมดในเส้นทาง
totalDistanceKmFloatระยะทางรวมของเส้นทางเป็นกิโลเมตร

ตัวอย่างโค้ด

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 APIIC ต่อการร้องขอติดตั้งภายในองค์กร
การปรับเส้นทางอัตโนมัติ1 IC/การร้องขอติดต่อ