Reseller API
เชื่อมต่อร้านค้าของคุณกับ GOODBUY24 — สั่งซื้อสินค้าอัตโนมัติผ่าน API
กรุณา เข้าสู่ระบบ หรือ สมัครสมาชิก เพื่อสร้าง API Key
Authentication & Base URL
ทุก request ต้องส่ง API Key:
แนะนำ: Header X-API-Key: YOUR_API_KEY
Compatibility: ?api_key=YOUR_API_KEY ยังใช้ได้ แต่หลีกเลี่ยงกับระบบใหม่เพราะ key อาจติดใน URL/access log
Base URL:
Parameters
ไม่มี parameter เพิ่มเติม
Response
Parameters
| Name | Type | Description |
|---|---|---|
| category_id optional | int | กรองตามหมวดหมู่ |
Response
Parameters
| Name | Type | Description |
|---|---|---|
| id required | int | Product ID |
Response
Parameters (POST body)
| Name | Type | Description |
|---|---|---|
| product_id required | int | ID สินค้าที่ต้องการซื้อ |
| quantity optional | int | จำนวน (default: 1, จำกัดตาม min_qty/max_qty) |
Response (Success)
Parameters
| Name | Type | Description |
|---|---|---|
| page optional | int | หน้า (default: 1) |
| limit optional | int | จำนวนต่อหน้า (default: 20, max: 50) |
Response
Parameters
| Name | Type | Description |
|---|---|---|
| order_id required | int | Order ID |
Response
Response
Response
Parameters
| Name | Type | Description |
|---|---|---|
| country optional | int | รหัสประเทศ (default: 52 = Thailand) |
Response
Parameters (POST body)
| Name | Type | Description |
|---|---|---|
| service required | string | รหัสบริการ เช่น "tg", "wa", "fb" |
| country optional | int | รหัสประเทศ (default: 52) |
| provider optional | string | "otp24hr" |
Response (Success)
Flow
1. เรียก otp_services เพื่อดูรายการบริการและราคา
2. เรียก otp_buy — ระบบหักเงินและส่งคืน order_id + เบอร์โทร
3. เรียก otp_status ซ้ำทุก 3-5 วินาที จนกว่าจะได้รับ OTP code
4. (ถ้าต้องการรอบถัดไป) เรียก otp_resend — ฟรี; OTP24HR ได้ order_id ใหม่ ส่วน HeroSMS ใช้ order_id เดิม
5. (ถ้ายกเลิก) เรียก otp_cancel — ระบบคืนเงินอัตโนมัติ
Parameters
| Name | Type | Description |
|---|---|---|
| order_id required | int | Order ID ที่ได้จาก otp_buy |
| provider optional | string | ใช้ค่า provider จาก otp_buy เมื่อมี order ID ซ้ำระหว่างผู้ให้บริการ |
Response
สถานะที่เป็นไปได้
| Status | Description |
|---|---|
| waiting | รอรับ OTP อยู่ |
| received | ได้รับ OTP แล้ว |
| success | รอบเดิมเสร็จแล้ว (เช่น OTP24HR เมื่อสร้างออเดอร์รอบถัดไป) |
| cancel | ยกเลิกแล้ว (คืนเงินแล้ว) |
| timeout | หมดเวลา (20 นาที) |
Parameters (POST body)
| Name | Type | Description |
|---|---|---|
| order_id required | int | Order ID ปัจจุบัน (ต้องได้รับ OTP รอบปัจจุบันแล้ว) |
| provider optional | string | ค่า provider จาก otp_buy; ช่วยระบุรายการให้ตรงเมื่อ order ID ซ้ำ |
Response (ตัวอย่าง HeroSMS — ใช้หมายเลขเดิม)
รองรับ OTP24HR และ HeroSMS — ไม่มีค่าใช้จ่ายเพิ่ม และใช้หมายเลขเดิม
OTP24HR จะคืน new_order_id ใหม่; HeroSMS ใช้ activation/order ID เดิม โดย new_order_id จะเท่ากับ original_order_id
ส่ง provider จาก otp_buy ได้ในคำขอ status/resend/cancel เพื่อป้องกัน order ID ซ้ำ
หลัง resend ให้เรียก otp_status ต่อ; ระหว่างรอ status จะเป็น waiting และ otp_code จะว่าง ส่วน messages เก็บประวัติ SMS ก่อนหน้าไว้
Parameters (POST body)
| Name | Type | Description |
|---|---|---|
| order_id required | int | Order ID ที่ต้องการยกเลิก (status ต้องเป็น waiting หรือ received) |
| provider optional | string | ค่า provider จาก otp_buy; ช่วยระบุรายการให้ตรงเมื่อ order ID ซ้ำ |
Response
การคืนเงินจะทำหลัง provider ยืนยันการยกเลิกเท่านั้น; ถ้าส่งคำขอซ้ำหลังยกเลิกสำเร็จ API จะตอบว่าออเดอร์ยกเลิกแล้วและคืน refunded: 0 เพื่อป้องกันการคืนเงินซ้ำ
Parameters
| Name | Type | Description |
|---|---|---|
| page optional | int | หน้า (default: 1) |
| limit optional | int | จำนวนต่อหน้า (default: 20, max: 50) |
Response
Error Codes
| Code | Description |
|---|---|
| 400 | Bad Request — parameter ไม่ถูกต้อง |
| 401 | Unauthorized — API Key ไม่ถูกต้อง |
| 403 | Forbidden — Key ถูกปิดหรือบัญชีถูกระงับ |
| 404 | Not Found |
| 409 | Conflict — สถานะออเดอร์ยังไม่พร้อม resend/cancel |
| 429 | Too Many Requests — เกิน rate limit |
| 500 | Server Error |
API Key
Endpoint
// กด Send Request เพื่อดู response