USD
首页 命令 信息

API 文档

将自动化采购系统集成到您的应用程序中。全面支持订单创建、状态查询、产品列表等功能。

API Version 1.0 - RESTful
Base URL https://datamoll.net/api/v1
Content-Type application/json
Response JSON
API密钥管理 使用权 trang API 密钥 创建、管理和查看您的 API 使用历史记录。

所有对 API 的请求都必须包含以下标头:

Header 描述
X-API-Key 您的 API 密钥(40 个字符,以 sk_live_ 开头)
X-API-Secret 您的 API 密钥(74 个字符,以 sk_secret_ 开头)
Content-Type application/json (选择 POST 请求)
示例标题
HTTP Headers
X-API-Key: sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
X-API-Secret: sk_secret_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2
Content-Type: application/json
安全通知 请务必妥善保管您的 API 密钥和 API 密钥密文。切勿共享或将其提交到您的源代码中。请使用环境变量来存储它们。
POST https://datamoll.net/api/v1/orders/create
请求正文
Parameter Type 描述
items 强制性的 array 待购商品清单
items[].plan_id 强制性的 integer 产品包 ID(取自 /products/list)
items[].quantity integer 购买数量(默认值:1)
items[].fields object 其他字段(如果计划要求)
coupon_code string 折扣码(如有)
示例代码
PHP
<?php
$apiKey = 'sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6';
$apiSecret = 'sk_secret_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2';

$data = [
    'items' => [
        ['plan_id' => 18, 'quantity' => 1, 'fields' => ['email_dang_nhap' => 'user@example.com']]
    ],
    'coupon_code' => ''
];

$ch = curl_init('https://datamoll.net/api/v1/orders/create');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'X-API-Key: ' . $apiKey,
        'X-API-Secret: ' . $apiSecret
    ]
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);

print_r($response);
?>
样本响应
Success Response
{
  "success": true,
  "message": "Đơn hàng đã được tạo thành công",
  "data": {
    "orders": [{
      "trans_id": "ORD1703750400ABC",
      "product_name": "Sản phẩm Premium",
      "status": "completed",
      "total": 100000
    }],
    "summary": {
      "total_amount": 100000,
      "new_balance": 400000
    }
  }
}
GET https://datamoll.net/api/v1/orders/status?trans_id={trans_id}
查询参数
Parameter Type 描述
trans_id 强制性的 string 订单创建结果中的交易代码
示例代码
PHP
<?php
$transId = 'ORD1703750400ABC';
$url = 'https://datamoll.net/api/v1/orders/status?trans_id=' . $transId;

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6',
        'X-API-Secret: sk_secret_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2'
    ]
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($response);
?>
样本响应
Success Response
{
  "success": true,
  "timestamp": 1770020629,
  "request_id": "req_69805f15a5ed77.94324321",
  "data": {
    "order": {
      "id": 36,
      "trans_id": "PO8153690",
      "user_id": 1,
      "product": {
        "id": 21,
        "name": "Sản phẩm Figma",
        "slug": "san-pham-figma",
        "image": "https://example.com/product.jpg"
      },
      "plan": {
        "id": 19,
        "name": "Figma Edu 1 năm - Tài khoản",
        "is_instant": true
      },
      "quantity": 2,
      "total_price": 1600000,
      "sale_price": 400000,
      "discount_amount": 0,
      "coupon_code": null,
      "final_amount": 400000,
      "fields_data": [],
      "status": "completed",
      "payment_status": "paid",
      "order_source": "api",
      "created_at": "2026-02-02 15:23:14",
      "updated_at": "2026-02-02 15:23:14"
    },
    "delivery": {
      "items": ["Account: user@mail.com | Pass: abc123", "Account: user2@mail.com | Pass: xyz789"],
      "delivered_count": 2,
      "expected_count": 2
    },
    "execution_time": 0.0238
  }
}
GET https://datamoll.net/api/v1/orders/list
查询参数
Parameter Type 描述
page integer 页数(默认值:1)
limit integer 页数(默认值:20,最大值:100)
status string 词语:待处理、处理中、已完成、已取消
示例代码
cURL
curl "https://datamoll.net/api/v1/orders/list?page=1&limit=20&status=completed" \
  -H "X-API-Key: sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" \
  -H "X-API-Secret: sk_secret_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2"
样本响应
Success Response
{
  "success": true,
  "data": {
    "orders": [{
      "id": 1234,
      "trans_id": "ORD-1705678901-ABC123",
      "product": {
        "id": 10,
        "name": "Windows 11 Pro Key",
        "slug": "windows-11-pro-key"
      },
      "plan": {
        "id": 5,
        "name": "Gói Retail - Vĩnh viễn"
      },
      "quantity": 2,
      "total_price": 1500000,
      "final_amount": 1350000,
      "status": "completed",
      "payment_status": "paid",
      "created_at": "2026-01-19 10:30:00"
    }],
    "pagination": {
      "current_page": 1,
      "per_page": 20,
      "total": 45,
      "total_pages": 3,
      "has_more": true
    },
    "execution_time": 0.0234
  }
}
GET https://datamoll.net/api/v1/products/list
查询参数
Parameter Type 描述
page integer 页数(默认值:1)
limit integer Số lượng/trang (mặc định: 10, tối đa: 100)
category_id integer 按类别筛选
search string 按名称搜索
sort string Sắp xếp: newest, oldest, price_asc, price_desc, bestseller
Phân trang API trả về tối đa 100 sản phẩm/trang. Sử dụng tham số page và kiểm tra pagination.has_more trong response để lấy tất cả sản phẩm.
示例代码
PHP - Lấy tất cả sản phẩm (phân trang)
<?php
$apiKey = 'sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6';
$apiSecret = 'sk_secret_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2';
$baseUrl = 'https://datamoll.net/api/v1';

$allProducts = [];
$page = 1;
$limit = 100; // Tối đa 100 sản phẩm/trang

do {
    $url = $baseUrl . '/products/list?page=' . $page . '&limit=' . $limit;

    $ch = curl_init($url);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'X-API-Key: ' . $apiKey,
            'X-API-Secret: ' . $apiSecret
        ]
    ]);

    $response = json_decode(curl_exec($ch), true);
    curl_close($ch);

    if (!$response['success']) break;

    $products = $response['data']['products'] ?? [];
    $allProducts = array_merge($allProducts, $products);

    $hasMore = $response['data']['pagination']['has_more'] ?? false;
    $page++;
} while ($hasMore);

echo 'Tổng sản phẩm: ' . count($allProducts);
?>
响应字段(计划)
Field Type 描述
id integer 产品包装 ID
name string 产品包装名称
price float 原价
sale_price float 促销价格(如有)
final_price float 最终价格(最好是促销价,如有)
is_instant boolean 自动化配送
duration_type string 期限类型:<code>终身</code>(永久),<code>天</code>(天),<code>月</code>(月),<code>年</code>(年)
duration_value integer|null 持续时间值(例如,30 天、1 个月)。如果 duration_type = lifetime,则为 null。
stock_count integer 库存数量(如果 is_instant = true)
in_stock boolean 还有货吗?
fields array 下单时需要填写的字段列表
样本响应
Success Response
{
  "success": true,
  "timestamp": 1769604661,
  "request_id": "req_697a063503ed57.32834148",
  "data": {
    "products": [{
      "id": 29,
      "name": "Key Adobe Creative Cloud All Apps",
      "slug": "key-adobe-creative-cloud-all-apps",
      "image": "https://example.com/product.jpg",
      "description": "<p>Mô tả sản phẩm...</p>",
      "category": {
        "id": 5,
        "name": "Học Tập",
        "slug": "hoc-tap",
        "image": "https://example.com/category.jpg"
      },
      "categories": [
        {"id": 5, "name": "Học Tập", "slug": "hoc-tap", "image": "https://example.com/category.jpg"},
        {"id": 14, "name": "Làm việc", "slug": "lam-viec", "image": null}
      ],
      "min_price": 375000,
      "max_price": 1650000,
      "sold": 24,
      "rating": 4.5,
      "plans": [{
        "id": 319,
        "name": "Tài khoản 1 tháng",
        "price": 375000,
        "sale_price": 0,
        "final_price": 375000,
        "is_instant": true,
        "duration_type": "month",
        "duration_value": 1,
        "stock_count": 50,
        "in_stock": true,
        "description": "",
        "fields": []
      }, {
        "id": 320,
        "name": "Nâng chính chủ 1 Tháng",
        "price": 1650000,
        "sale_price": 0,
        "final_price": 1650000,
        "is_instant": false,
        "duration_type": "month",
        "duration_value": 3,
        "stock_count": 0,
        "in_stock": true,
        "description": "",
        "fields": [
          {"key": "email", "label": "Email", "type": "email", "required": true},
          {"key": "mat_khau", "label": "Mật khẩu", "type": "password", "required": true}
        ]
      }]
    }],
    "pagination": {
      "current_page": 1,
      "per_page": 10,
      "total": 21,
      "total_pages": 3,
      "has_more": true
    },
    "execution_time": 0.0828
  }
}
GET https://datamoll.net/api/v1/categories/list
查询参数
Parameter Type 描述
parent_id integer 按父类别筛选
include_children boolean 包含子类别(0 或 1)
include_products boolean 包括产品数量(0 或 1)
示例代码
cURL
curl "https://datamoll.net/api/v1/categories/list?include_children=1" \
  -H "X-API-Key: sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" \
  -H "X-API-Secret: sk_secret_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2"
样本响应
Success Response
{
  "success": true,
  "timestamp": 1770022554,
  "request_id": "req_6980669a4793d9.70486853",
  "data": {
    "categories": [{
      "id": 3,
      "name": "Giải Trí",
      "slug": "giai-tri",
      "description": "",
      "image": "https://example.com/category/DOQ4.png",
      "parent_id": 1,
      "sort_order": 9
    }, {
      "id": 5,
      "name": "Học Tập",
      "slug": "hoc-tap",
      "description": "",
      "image": "https://example.com/category/9IRK.png",
      "parent_id": 1,
      "sort_order": 4
    }, {
      "id": 1,
      "name": "Tiện Ích",
      "slug": "tien-ich",
      "description": "",
      "image": "https://example.com/category/EIT3.png",
      "parent_id": 0,
      "sort_order": 0
    }],
    "total": 15,
    "execution_time": 0.0341
  }
}
GET https://datamoll.net/api/v1/account/balance
示例代码
cURL
curl "https://datamoll.net/api/v1/account/balance" \
  -H "X-API-Key: sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" \
  -H "X-API-Secret: sk_secret_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2"
样本响应
Success Response
{
  "success": true,
  "timestamp": 1770022345,
  "request_id": "req_698065c9694a56.14017855",
  "data": {
    "user": {
      "id": 1,
      "username": "admin",
      "email": "admin@cmsnt.co"
    },
    "balance": {
      "current": 93537500,
      "total_deposited": 100000000,
      "currency": "VND",
      "formatted": "93.537.500đ"
    },
    "execution_time": 0.0258
  }
}
GET https://datamoll.net/api/v1/account/info
示例代码
cURL
curl "https://datamoll.net/api/v1/account/info" \
  -H "X-API-Key: sk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" \
  -H "X-API-Secret: sk_secret_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2"
样本响应
Success Response
{
  "success": true,
  "timestamp": 1770022432,
  "request_id": "req_69806620805ae3.29218122",
  "data": {
    "user": {
      "id": 1,
      "username": "admin",
      "email": "admin@cmsnt.co",
      "phone": "",
      "balance": 93537500,
      "total_deposited": 100000000,
      "created_at": null
    },
    "api_key": {
      "name": "API Key",
      "permissions": [
        "orders.create",
        "orders.list",
        "orders.status",
        "products.list",
        "account.balance",
        "account.info"
      ],
      "rate_limit": 60,
      "daily_limit": 10000,
      "expires_at": null,
      "created_at": "2026-02-02 14:53:35"
    },
    "orders_summary": {
      "total": 12,
      "pending": 3,
      "completed": 8
    },
    "api_usage_today": {
      "period": "day",
      "start_time": "2026-02-02 00:00:00",
      "total_requests": 5,
      "success_requests": 5,
      "failed_requests": 0,
      "success_rate": 100
    },
    "execution_time": 0.0449
  }
}
错误代码 HTTP 描述
INVALID_API_KEY 401 无效的 API 密钥
INVALID_API_SECRET 401 API密钥不正确。
DISABLED_API_KEY 401 API密钥已被禁用。
RATE_LIMIT_EXCEEDED 429 请求次数已超过限制。
IP_NOT_ALLOWED 403 该IP地址无权访问。
PERMISSION_DENIED 403 无权表演
INSUFFICIENT_BALANCE 400 平衡不足
PRODUCT_NOT_FOUND 404 该产品不存在。
OUT_OF_STOCK 400 该产品已售罄。
错误响应格式
Error Response
{
  "success": false,
  "message": "Số dư không đủ để thanh toán",
  "data": {
    "error_code": "INSUFFICIENT_BALANCE"
  }
}
Cần hỗ trợ?