เอกสาร API
รายการ endpoint ทั้งหมดสำหรับเชื่อมต่อระบบ — เข้าสู่ระบบเพื่อใช้งานจริง
✨
v2 — recommended — RESTful URLs,
Authorization: Bearer auth, real HTTP status codes, consistent JSON error shape, pagination, filtering, idempotency. ใช้ API key เดียวกัน กับ v1 ได้เลย ไม่ต้อง regenerate🔑 Authentication
ส่ง API key เป็น Authorization header (วิธีที่แนะนำ — ไม่ leak ใน server logs):
Authorization: Bearer YOUR_API_KEY
วิธีอื่นที่รองรับ: X-Api-Key: KEY header หรือ ?api_key=KEY query (ไม่แนะนำ)
GET
API metadata + endpoint index (no auth)
Response
{
"name": "marketacc-api",
"version": "v2",
"endpoints": { ... }
}GET
รับข้อมูลบัญชีของคุณ
v2Headers
Authorization: Bearer YOUR_API_KEY
Response
{
"id": 1,
"username": "demo",
"email": "demo@example.com",
"balance": 1234.56,
"currency": "THB",
"totalDeposit": 5000,
"totalSpent": 3765.44,
"points": 376,
"orderCount": 8,
"role": "user",
"createdAt": "2026-01-01T00:00:00.000Z"
}GET
รายการหมวดหมู่
v2Headers
Authorization: Bearer YOUR_API_KEY
Response
{
"items": [
{ "id": 1, "slug": "hotmail-outlook", "name": "Hotmail - Outlook", "productCount": 2 }
],
"total": 17
}GET
รายการสินค้า (filter + paginate)
v2Headers
Authorization: Bearer YOUR_API_KEY
Parameters
qค้นหาตามชื่อ (optional)
categoryslug ของหมวด (optional)
min_stockstock ขั้นต่ำ (optional)
min_priceราคาต่ำสุด THB (optional)
max_priceราคาสูงสุด THB (optional)
page1-based (default 1)
per_page1..200 (default 50)
Response
{
"items": [
{ "id": 1, "name": "...", "slug": "...", "categorySlug": "...",
"price": 10.20, "stock": 28676, "sold": 42, "format": "user|pass|2fa" }
],
"page": 1, "perPage": 50, "total": 57, "totalPages": 2
}GET
สินค้าเดี่ยว (by id หรือ slug)
v2Headers
Authorization: Bearer YOUR_API_KEY
Response
{
"id": 1, "name": "...", "slug": "...",
"category": { "slug": "...", "name": "..." },
"price": 10.20, "stock": 28676, "sold": 42,
"description": "...", "format": "user|pass|2fa",
"createdAt": "..."
}POST
สร้างคำสั่งซื้อ (with idempotency)
v2Headers
Authorization: Bearer YOUR_API_KEY Content-Type: application/json
Body (JSON)
{
"productId": 315,
"quantity": 1,
"coupon": "WELCOME10", // optional
"idempotencyKey": "client-uuid" // optional — retry without double-charge
}Response
HTTP 201 Created
{
"id": 23,
"code": "APICB47T6UCYH",
"status": "completed",
"subtotal": 51,
"discount": 0,
"total": 51,
"balance": 9949,
"items": [
{ "productId": 315, "productName": "...", "quantity": 1, "unitPrice": 51,
"data": "user|pass|2fa|recovery_email" }
],
"createdAt": "..."
}
// Replay เดียวกัน (idempotencyKey ซ้ำ) → 200 + idempotent:trueGET
รายการคำสั่งซื้อของคุณ
v2Headers
Authorization: Bearer YOUR_API_KEY
Parameters
statusfilter: completed / pending / failed (optional)
page / per_pagepagination
Response
{
"items": [
{ "id": 23, "code": "APIXXX", "status": "completed", "total": 51,
"createdAt": "...", "items": [{ ... }] }
],
"page": 1, "perPage": 50, "total": 8, "totalPages": 1
}GET
คำสั่งซื้อเดี่ยว (by code)
v2Headers
Authorization: Bearer YOUR_API_KEY
Response
{
"id": 23, "code": "APIXXX", "status": "completed",
"subtotal": 51, "discount": 0, "total": 51,
"items": [
{ "productId": 1, "productName": "...", "quantity": 1, "unitPrice": 51,
"status": "delivered", "data": "user|pass|2fa" }
],
"createdAt": "..."
}❌ Error format
เมื่อ error ระบบส่ง HTTP status code ที่ถูกต้อง + body JSON รูปแบบเดียวกัน:
{
"error": {
"code": "insufficient_balance",
"message": "insufficient balance",
"details": [ ... ] // optional, validation errors
}
}400 invalid_requestpayload ผิด (missing field, type)401 unauthenticatedไม่มี API key หรือ key ผิด402 insufficient_balanceยอดเงินไม่พอ403 forbiddenบัญชีถูกแบน / IP ไม่อยู่ใน allowlist404 not_foundไม่พบสินค้า / คำสั่งซื้อ409 out_of_stockสต็อกหมด หรือ supplier ส่งไม่ได้429 rate_limitedเรียก API ถี่เกิน500 internal_errorระบบมีปัญหา ลองอีกครั้ง📝 cURL
# List products
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://dev.godacc.com/api/v2/products?per_page=10&category=hotmail-outlook"
# Buy
curl -X POST "https://dev.godacc.com/api/v2/orders" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"productId":315,"quantity":1,"idempotencyKey":"my-unique-id"}'📝 Node.js
const KEY = process.env.API_KEY;
const BASE = "https://dev.godacc.com";
async function buy(productId, quantity = 1) {
const r = await fetch(`${BASE}/api/v2/orders`, {
method: "POST",
headers: {
"Authorization": `Bearer ${KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
productId,
quantity,
idempotencyKey: crypto.randomUUID(),
}),
});
if (r.status === 201) {
const order = await r.json();
console.log("Accounts:", order.items[0].data);
return order;
}
const { error } = await r.json();
throw new Error(`${error.code}: ${error.message}`);
}📝 PHP
<?php
$key = getenv('API_KEY');
$base = "https://dev.godacc.com";
$ch = curl_init("$base/api/v2/orders");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $key",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
'productId' => 315,
'quantity' => 1,
'idempotencyKey' => uniqid('order-', true),
]),
]);
$res = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$data = json_decode($res, true);
if ($status === 201) {
echo "Accounts: " . $data['items'][0]['data'];
} else {
echo "Error {$data['error']['code']}: {$data['error']['message']}";
}📝 Python
import os, requests, uuid
KEY = os.environ['API_KEY']
BASE = "https://dev.godacc.com"
r = requests.post(
f"{BASE}/api/v2/orders",
headers={"Authorization": f"Bearer {KEY}"},
json={
"productId": 315,
"quantity": 1,
"idempotencyKey": str(uuid.uuid4()),
},
)
if r.status_code == 201:
order = r.json()
print("Accounts:", order["items"][0]["data"])
else:
err = r.json()["error"]
print(f"Error {err['code']}: {err['message']}")