API Documentation
PromptPay QR API
REST API สำหรับสร้าง PromptPay QR Code ใช้งานง่าย รองรับหลายรูปแบบ
รวดเร็ว
Response time ต่ำกว่า 500ms
ปลอดภัย
HTTPS + CORS Support
ฟรี
ไม่มีค่าใช้จ่าย ไม่จำกัด
Base URL
URL หลักสำหรับเรียกใช้ API
https://pp-softerm.site/api
GET
/qr
สร้าง QR Code PromptPay
สร้าง QR Code และส่งกลับในรูปแบบที่ต้องการ
Parameters
id
required
stringเบอร์โทร 10 หลัก หรือบัตรประชาชน 13 หลักamount
optional
numberจำนวนเงิน (ทศนิยม)format
optional
stringbase64, svg, png (default: base64)ตัวอย่างการใช้งาน
Base64 JSON Response:
GET /api/qr?id=0812345678&amount=100.50
SVG Image:
GET /api/qr?id=0812345678&format=svg
PNG Image:
GET /api/qr?id=0812345678&format=png
Response (JSON format)
{
"success": true,
"data": {
"qrCode": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"payload": "00020101021129370016A000000677010111081234567805303764540610...",
"id": "081-234-5678",
"amount": 100.5
}
}
POST
/qr
สร้าง QR Code ผ่าน POST
ส่งข้อมูลผ่าน JSON body
Request Body
{
"id": "0812345678",
"amount": 100.50,
"format": "base64"
}
JavaScript Example
fetch('/api/qr', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
id: '0812345678',
amount: 100.50
})
})
.then(response => response.json())
.then(data => {
console.log(data.data.qrCode); // Base64 QR Code
});
GET
/payload
รับ Payload String
รับเฉพาะ payload string สำหรับสร้าง QR Code เอง
ตัวอย่าง
GET /api/payload?id=0812345678&amount=100.50
Response
{
"success": true,
"data": {
"payload": "00020101021129370016A000000677010111081234567805303764540610...",
"id": "081-234-5678",
"amount": 100.5
}
}
การใช้งานใน HTML
แสดง QR Code โดยตรงใน HTML
<!-- แสดง QR Code เป็นรูปภาพ SVG -->
<img src="/api/qr?id=0812345678&amount=100&format=svg" alt="PromptPay QR Code">
<!-- แสดง QR Code เป็นรูปภาพ PNG -->
<img src="/api/qr?id=0812345678&amount=100&format=png" alt="PromptPay QR Code">
Error Responses
รูปแบบ response เมื่อเกิดข้อผิดพลาด
{
"success": false,
"error": "Invalid ID format. Use 10-digit phone number or 13-digit national ID"
}
พร้อมทดลองใช้แล้ว!
ลองใช้ API ของเราได้เลย หรือกลับไปสร้าง QR Code ผ่านหน้าเว็บ