所有API请求需要在请求头中携带API密钥:
X-API-Key: your_api_keyAuthorization: Bearer your_api_key您可以在用户中心查看和管理您的API密钥
Base URL: https://www.cloudok.top/api
响应格式: JSON
编码: UTF-8
/goods
获取商品列表,支持分页和筛选
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
group_id |
integer | query | 可选 | 商品分组ID |
type |
integer | query | 可选 | 商品类型 |
search |
string | query | 可选 | 搜索关键词 |
per_page |
integer | query | 可选 |
每页数量,最多100
默认值: 15 |
page |
integer | query | 可选 |
页码
默认值: 1 |
{
"success": true,
"message": "操作成功",
"data": {
"current_page": 1,
"data": [
{
"id": 1,
"name": "商品名称",
"description": "商品描述",
"picture": "https:\/\/example.com\/picture.jpg",
"price": 99,
"sales_volume": "api.example_data.total_100",
"type": 1,
"type_name": "规格名称",
"subs": [
{
"id": 1,
"name": "规格名称",
"price": 99,
"stock": "api.example_data.total_100"
}
]
}
],
"total": "api.example_data.total_100",
"per_page": 15
}
}
curl -X GET "https://www.cloudok.top/api/goods" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.cloudok.top/api/goods");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-Key: your_api_key",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
response = requests.get(
"https://www.cloudok.top/api/goods",
headers=headers
)
fetch("https://www.cloudok.top/api/goods", {
method: "GET",
headers: {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => );
/goods/{id}
根据商品ID获取商品详细信息
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
id |
integer | path | 必填 | 商品ID |
{
"success": true,
"message": "操作成功",
"data": {
"id": 1,
"name": "商品名称",
"description": "商品描述",
"detail": "商品详情内容",
"usage_instructions": "使用说明",
"picture": "https:\/\/example.com\/picture.jpg",
"price": 99,
"sales_volume": "api.example_data.total_100",
"type": 1,
"type_name": "规格名称",
"require_login": false,
"subs": []
}
}
curl -X GET "https://www.cloudok.top/api/goods/{id}" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.cloudok.top/api/goods/{id}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-Key: your_api_key",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
response = requests.get(
"https://www.cloudok.top/api/goods/{id}",
headers=headers
)
fetch("https://www.cloudok.top/api/goods/{id}", {
method: "GET",
headers: {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => );
/goods/{id}/stock
获取商品各规格的库存信息
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
id |
integer | path | 必填 | 商品ID |
{
"success": true,
"message": "操作成功",
"data": {
"goods_id": 1,
"goods_name": "商品名称",
"subs": [
{
"sub_id": 1,
"sub_name": "规格名称",
"stock": "api.example_data.total_100",
"price": 99
}
]
}
}
curl -X GET "https://www.cloudok.top/api/goods/{id}/stock" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.cloudok.top/api/goods/{id}/stock");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-Key: your_api_key",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
response = requests.get(
"https://www.cloudok.top/api/goods/{id}/stock",
headers=headers
)
fetch("https://www.cloudok.top/api/goods/{id}/stock", {
method: "GET",
headers: {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => );
/balance
获取当前用户的余额信息
{
"success": true,
"message": "操作成功",
"data": {
"balance": 1000,
"total_spent": 5000,
"level_name": "白银会员"
}
}
curl -X GET "https://www.cloudok.top/api/balance" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.cloudok.top/api/balance");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-Key: your_api_key",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
response = requests.get(
"https://www.cloudok.top/api/balance",
headers=headers
)
fetch("https://www.cloudok.top/api/balance", {
method: "GET",
headers: {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => );
/purchase
创建订单并购买商品
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
goods_id |
integer | query | 必填 | 商品ID |
sub_id |
integer | query | 必填 | 商品规格ID |
quantity |
integer | query | 必填 |
购买数量
最小值: 1 |
email |
string | query | 可选 | 联系邮箱 |
payway |
string | query | 必填 | 支付方式ID或"balance"(余额支付) |
search_pwd |
string | query | 可选 | 查询密码 |
{
"success": true,
"message": "订单创建成功",
"data": {
"order_sn": "订单号",
"status": 4,
"total_price": 99,
"actual_price": 94.05,
"balance_used": 0
}
}
curl -X POST "https://www.cloudok.top/api/purchase" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.cloudok.top/api/purchase");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-Key: your_api_key",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
import requests
headers = {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
response = requests.post(
"https://www.cloudok.top/api/purchase",
headers=headers
)
fetch("https://www.cloudok.top/api/purchase", {
method: "POST",
headers: {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => );