ออนไลน์ 09:00–22:30·GMT+7
นโยบาย·FAQ·ติดต่อ·
·
MarketAccount logogodaccprofessional ad account solutionsMarketAccount
เข้าสู่ระบบ

เอกสาร API

รายการ endpoint ทั้งหมดสำหรับเชื่อมต่อระบบ — เข้าสู่ระบบเพื่อใช้งานจริง

ต้องเข้าสู่ระบบ
เข้าสู่ระบบเพื่อรับ API Key ส่วนตัว ตั้งค่า IP allowlist และใช้งาน API ด้านล่าง
เข้าสู่ระบบสมัครสมาชิก
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

รับข้อมูลบัญชีของคุณ

v2
Headers
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

รายการหมวดหมู่

v2
Headers
Authorization: Bearer YOUR_API_KEY
Response
{
  "items": [
    { "id": 1, "slug": "hotmail-outlook", "name": "Hotmail - Outlook", "productCount": 2 }
  ],
  "total": 17
}
GET

รายการสินค้า (filter + paginate)

v2
Headers
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)

v2
Headers
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)

v2
Headers
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:true
GET

รายการคำสั่งซื้อของคุณ

v2
Headers
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)

v2
Headers
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 ไม่อยู่ใน allowlist
404 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']}")
PARTNERSพาร์ทเนอร์และผู้สนับสนุนของเรา
new like