4. 统计数据模块
4.1 上报拦截次数
增加拦截次数统计(需要 token 验证)。
端点: POST /stats/a
请求头:
Text
Content-Type: application/json
请求体:
JSON
{
"token": "aBcD1234EfGh5678IjKlMnOpQrSt"
}
请求示例:
cURL:
Bash
curl -X POST https://api.ndpreforged.com/stats/a \
-H "Content-Type: application/json" \
-d '{
"token": "aBcD1234EfGh5678IjKlMnOpQrSt"
}'
Python:
Python
import requests
response = requests.post(
"https://api.ndpreforged.com/stats/a",
json={
"token": "aBcD1234EfGh5678IjKlMnOpQrSt"
}
)
print(response.json())
响应示例:
Success (200 OK):
JSON
{
"total": 42,
"message": "Recorded"
}
Error Responses:
| Status Code | Error Message | Description | |
|---|---|---|---|
| 401 | Invalid or missing token | Token 格式无效或缺失 | |
| 401 | Token not found | Token 不存在 | |
| 500 | Server error | 服务器内部错误 |
4.2 获取拦截统计
获取NDPR总拦截次数。
端点: GET /stats/s
请求示例:
Bash
curl https://api.ndpreforged.com/stats/s
Python 请求示例:
Python
import requests
response = requests.get("https://api.ndpreforged.com/stats/s")
print(response.json())
成功响应 (200):
JSON
{
"total": 42
}
错误响应 (500):
JSON
{
"error": "Server error"
}