所有API請求需要在請求頭中攜帶API密鑰:
X-API-Key: your_api_keyAuthorization: Bearer your_api_key您可以在用戶中心查看和管理您的API密鑰
Base URL: https://www.tkhao.vip/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.tkhao.vip/api/goods" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.tkhao.vip/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.tkhao.vip/api/goods",
headers=headers
)
fetch("https://www.tkhao.vip/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.tkhao.vip/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.tkhao.vip/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.tkhao.vip/api/goods/{id}",
headers=headers
)
fetch("https://www.tkhao.vip/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.tkhao.vip/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.tkhao.vip/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.tkhao.vip/api/goods/{id}/stock",
headers=headers
)
fetch("https://www.tkhao.vip/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.tkhao.vip/api/balance" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.tkhao.vip/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.tkhao.vip/api/balance",
headers=headers
)
fetch("https://www.tkhao.vip/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.tkhao.vip/api/purchase" \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.tkhao.vip/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.tkhao.vip/api/purchase",
headers=headers
)
fetch("https://www.tkhao.vip/api/purchase", {
method: "POST",
headers: {
"X-API-Key": "your_api_key",
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => );