数字生命 API 文档

完整的技术接口文档和使用指南

📚 API 概览

数字生命提供完整的RESTful API接口,支持JSON格式的数据交换。 所有API都支持CORS,可以直接在前端JavaScript中调用。

GET
http://localhost:8099/

基础API服务器 - 获取API信息和可用端点列表

GET
http://localhost:8103/

反馈API服务器 - 用户反馈系统API

🔧 基础API服务器 (端口: 8099)

GET
/api/health

健康检查 - 检查API服务器状态

响应示例

{
  "status": "healthy",
  "timestamp": "2026-02-10T00:07:43.524816",
  "uptime": 10
}
GET
/api/system

系统信息 - 获取服务器系统信息

响应示例

{
  "server_info": {
    "hostname": "server-hostname",
    "platform": "Linux",
    "python_version": "3.9.0"
  },
  "timestamp": "2026-02-10T00:07:43.524816"
}
GET
/api/stats

访问统计 - 获取API访问统计数据

响应示例

{
  "total_requests": 150,
  "today_requests": 25,
  "popular_endpoints": {
    "/api/health": 50,
    "/api/system": 30,
    "/api/stats": 20
  }
}
GET
/api/resources

资源监控 - 获取系统资源使用情况

响应示例

{
  "cpu": {
    "percent": 15.5,
    "cores": 4,
    "frequency": 3200
  },
  "memory": {
    "total": 8192,
    "available": 4096,
    "percent": 50.0,
    "used": 4096
  },
  "disk": {
    "total": 500000,
    "used": 250000,
    "free": 250000,
    "percent": 50.0
  }
}

💬 反馈API服务器 (端口: 8103)

GET
/api/health

健康检查 - 检查反馈API服务器状态

GET
/api/feedback

获取反馈列表 - 查询用户反馈

查询参数

参数 类型 必填 说明
limit integer 每页数量,默认10
offset integer 偏移量,默认0
status string 反馈状态:new, read, resolved

响应示例

{
  "feedback": [
    {
      "id": 1,
      "name": "测试用户",
      "email": "test@example.com",
      "message": "这个API非常好用!",
      "rating": 5,
      "category": "general",
      "status": "new",
      "created_at": "2026-02-09 16:16:47"
    }
  ],
  "pagination": {
    "total": 1,
    "limit": 10,
    "offset": 0,
    "has_more": false
  }
}
POST
/api/feedback

提交反馈 - 创建新的用户反馈

请求体参数

参数 类型 必填 说明
message string 反馈内容
name string 用户姓名
email string 用户邮箱
rating integer 评分 (1-5)
category string 分类:general, bug_report, feature_request

请求示例

{
  "name": "测试用户",
  "email": "test@example.com",
  "message": "这个API非常好用!",
  "rating": 5,
  "category": "general"
}

响应示例

{
  "success": true,
  "message": "Feedback submitted successfully",
  "feedback_id": 1,
  "timestamp": "2026-02-10T00:16:47.263587"
}
GET
/api/stats

统计信息 - 获取反馈系统统计

响应示例

{
  "total_feedback": 3,
  "status_stats": {
    "new": 3
  },
  "rating_stats": {
    "3": 1,
    "4": 1,
    "5": 1
  },
  "recent_feedback": [
    {
      "id": 1,
      "name": "测试用户",
      "message": "这个API非常好用!",
      "rating": 5,
      "created_at": "2026-02-09 16:16:47"
    }
  ]
}

🚀 快速开始

JavaScript 调用示例

// 获取系统信息
fetch('http://localhost:8099/api/system')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

// 提交反馈
fetch('http://localhost:8103/api/feedback', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: '你的名字',
    message: '你的反馈内容',
    rating: 5
  })
})
  .then(response => response.json())
  .then(data => console.log('Success:', data))
  .catch(error => console.error('Error:', error));

Python 调用示例