数据统计模块

功能说明

接口前缀为:

  1. 主站:https://ai.burncloud.com
  2. 企业站:https://b.burncloud.com

用量数据的聚合统计系统。管理员可查看全站统计,用户可查看个人统计。数据按模型和日期分组,用于生成图表和报表,监控系统使用趋势。

🔐 用户鉴权

我的用量按日期统计

💡 请求示例:

const response = await fetch('/api/data/self?start_timestamp=1640908800&end_timestamp=1640995200', {  
  method: 'GET',  
  headers: {  
    'Content-Type': 'application/json',  
    'Authorization': 'Bearer your_user_token',
    'New-Api-User': 'Bearer your_user_id'
  }  
});  
const data = await response.json();

✅ 成功响应示例:

{  
  "success": true,  
  "message": "",  
  "data": [  
    {  
      "model_name": "gpt-3.5-turbo",  
      "count": 25,  
      "quota": 12500,  
      "token_used": 2000,  
      "created_at": 1640995200,  
      "user_id": 1,  
      "username": "testuser"  
    },  
    {  
      "model_name": "gpt-4",  
      "count": 10,  
      "quota": 30000,  
      "token_used": 1500,  
      "created_at": 1640995200,  
      "user_id": 1,  
      "username": "testuser"  
    }  
  ]  
}

❗ 失败响应示例:

{  
  "success": false,  
  "message": "获取个人统计数据失败"  
}

🧾 字段说明:

🔐 管理员鉴权

全站用量按日期统计

💡 请求示例:

const response = await fetch('/api/data/?start_timestamp=1640908800&end_timestamp=1640995200&username=testuser', {  
  method: 'GET',  
  headers: {  
    'Content-Type': 'application/json',  
    'Authorization': 'Bearer your_admin_token',
    'New-Api-User': 'Bearer your_user_id'
  }  
});  
const data = await response.json();

✅ 成功响应示例:

{  
  "success": true,  
  "message": "",  
  "data": [  
    {  
      "model_name": "gpt-3.5-turbo",  
      "count": 150,  
      "quota": 75000,  
      "token_used": 12500,  
      "created_at": 1640995200  
    },  
    {  
      "model_name": "gpt-4",  
      "count": 50,  
      "quota": 150000,  
      "token_used": 8000,  
      "created_at": 1640995200  
    }  
  ]  
}

❗ 失败响应示例:

{  
  "success": false,  
  "message": "获取统计数据失败"  
}

🧾 字段说明:


Revision #1
Created 30 October 2025 03:57:31 by Burncloud
Updated 30 October 2025 03:57:44 by Burncloud