API介绍
AI中医12经脉诊断系统API,提供基于舌相、血压、血氧、心率等体征数据的智能中医诊断服务。本API支持多模态数据融合分析,生成精准的12经脉诊断报告。
基础URL:
https://api.tcm-ai.org/api/v1
数据格式:所有API请求和响应都使用JSON格式。
字符编码:UTF-8
响应时间:通常在100-500ms之间,具体取决于请求复杂度。
认证方式
所有API请求都需要在HTTP Header中包含认证令牌:
Authorization: Bearer your_api_key_here
认证
了解如何获取API密钥以及认证流程。
获取API访问令牌。您需要先在AI中医平台注册账号。
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
email |
string | 是 | 注册邮箱 |
password |
string | 是 | 密码 |
device_id |
string | 否 | 设备标识符 |
请求示例
{
"email": "user@example.com",
"password": "your_password",
"device_id": "device_123"
}
响应示例
{
"success": true,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"token_type": "Bearer",
"expires_in": 86400,
"refresh_token": "def50200e9a7d8c7f...",
"user": {
"id": "user_123",
"email": "user@example.com",
"name": "张三",
"plan": "premium"
}
}
状态码
舌相分析
上传舌相图片进行AI分析,获取舌质、舌苔、舌形等详细分析结果。
分析舌相图片,返回详细的舌诊报告。支持JPG、PNG格式,最大文件大小为10MB。
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
image |
file | 是 | 舌相图片文件 |
image_type |
string | 否 | 图片类型:jpg, png |
analysis_type |
string | 否 | 分析类型:quick, standard, detailed |
include_meridian |
boolean | 否 | 是否包含经脉关联分析 |
请求示例 (cURL)
curl -X POST \
https://api.tcm-ai.org/api/v1/tongue/analyze \
-H "Authorization: Bearer your_api_key" \
-F "image=@tongue.jpg" \
-F "analysis_type=detailed" \
-F "include_meridian=true"
请求示例 (Python)
import requests
url = "https://api.tcm-ai.org/api/v1/tongue/analyze"
headers = {"Authorization": "Bearer your_api_key"}
with open("tongue.jpg", "rb") as f:
files = {"image": f}
data = {
"analysis_type": "detailed",
"include_meridian": "true"
}
response = requests.post(url, headers=headers, files=files, data=data)
if response.status_code == 200:
result = response.json()
print(f"舌质颜色: {result['tongue_color']}")
print(f"舌苔状况: {result['coating']}")
print(f"舌体形态: {result['tongue_shape']}")
else:
print(f"错误: {response.status_code}")
print(response.text)
响应示例
{
"success": true,
"analysis_id": "tongue_analysis_001",
"timestamp": "2026-01-21T10:30:00Z",
"analysis": {
"tongue_color": {
"value": "淡紫色",
"confidence": 0.92,
"interpretation": "气血运行不畅,兼有血瘀"
},
"coating": {
"value": "薄白苔",
"thickness": "薄",
"color": "白",
"moisture": "润",
"confidence": 0.88
},
"tongue_shape": {
"value": "略有齿痕",
"size": "正常",
"cracks": "无",
"teeth_marks": "轻度",
"confidence": 0.85
},
"sublingual_veins": {
"color": "淡紫",
"distension": "轻度",
"tortuosity": "无",
"confidence": 0.79
}
},
"meridian_correlation": [
{
"meridian": "手少阴心经",
"correlation_score": 0.85,
"status": "阻滞",
"description": "舌质偏紫,心经血瘀明显"
},
{
"meridian": "足太阴脾经",
"correlation_score": 0.78,
"status": "虚弱",
"description": "舌边齿痕,脾经气血不足"
}
],
"health_insights": [
"气血运行不畅,建议适当运动",
"脾胃功能偏弱,注意饮食调理"
]
}
12经脉诊断
综合舌相、生命体征、症状等多维度数据,进行全面的12经脉诊断分析。
基于多模态数据进行12经脉诊断,生成详细的经脉状态报告。
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
vital_signs |
object | 是 | 生命体征数据 |
tongue_analysis_id |
string | 否 | 舌相分析ID |
symptoms |
string | 是 | 症状描述 |
user_info |
object | 否 | 用户基本信息 |
include_treatment |
boolean | 否 | 是否包含治疗方案 |
请求示例
{
"vital_signs": {
"heart_rate": 72,
"blood_pressure": {
"systolic": 118,
"diastolic": 78
},
"blood_oxygen": 98,
"temperature": 36.5,
"recorded_at": "2026-01-21T10:00:00Z"
},
"tongue_analysis_id": "tongue_analysis_001",
"symptoms": "倦怠乏力,心悸气短,偶尔头晕,睡眠不佳",
"user_info": {
"age": 45,
"gender": "male",
"height_cm": 175,
"weight_kg": 70
},
"include_treatment": true,
"include_prognosis": true
}
响应示例
{
"success": true,
"diagnosis_id": "meridian_diagnosis_001",
"timestamp": "2026-01-21T10:35:00Z",
"overall_assessment": {
"pattern": "气虚血瘀证",
"confidence": 0.92,
"severity": "中度",
"urgency": "常规"
},
"meridian_status": [
{
"meridian": "手少阴心经",
"status": "阻滞",
"score": 0.35,
"confidence": 0.88,
"description": "心悸气短,舌质偏紫,心经血瘀明显",
"primary_symptoms": ["心悸", "气短", "失眠"]
},
{
"meridian": "足太阴脾经",
"status": "虚弱",
"score": 0.42,
"confidence": 0.85,
"description": "倦怠乏力,舌边齿痕,脾经气血不足",
"primary_symptoms": ["乏力", "食欲不振", "大便溏稀"]
},
{
"meridian": "足厥阴肝经",
"status": "偏盛",
"score": 0.68,
"confidence": 0.76,
"description": "偶尔头晕,情绪波动,肝阳偏亢",
"primary_symptoms": ["头晕", "烦躁", "胁肋胀痛"]
}
],
"network_analysis": {
"exterior_interior_imbalance": [
"手少阴心经(阻滞) - 手太阳小肠经(正常):里经阻滞,表经未受影响"
],
"generation_cycle_weakness": [
"足太阴脾经(虚弱) → 手太阴肺经(虚弱):土不生金,肺脾气虚"
],
"flow_disruptions": [
"从手少阴心经到足太阳膀胱经的气血流动受阻"
]
},
"treatments": {
"acupuncture": [
{
"points": ["HT7", "PC6", "SP6"],
"method": "补法",
"frequency": "每周2-3次",
"duration": "4周"
}
],
"herbal_medicine": [
{
"formula": "归脾汤加减",
"dosage": "每日一剂,分两次服用",
"duration": "2周"
}
],
"lifestyle": [
"适当有氧运动,如散步、太极",
"避免熬夜,保证充足睡眠",
"饮食清淡,避免油腻辛辣"
]
},
"prognosis": {
"short_term": "2周内症状可改善30-40%",
"medium_term": "1-2个月可基本恢复正常",
"recommended_followup": "2周后复诊"
}
}
健康数据上传
上传来自AI-33 Medical Watch的健康监测数据。
上传批量健康数据,支持实时同步和历史数据导入。
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
data_type |
string | 是 | 数据类型:realtime, batch |
records |
array | 是 | 健康数据记录数组 |
device_id |
string | 否 | 设备标识符 |
sync_type |
string | 否 | 同步类型:full, incremental |
请求示例
{
"data_type": "batch",
"device_id": "ai33_watch_001",
"sync_type": "incremental",
"records": [
{
"timestamp": "2026-01-21T08:00:00Z",
"heart_rate": 72,
"blood_pressure": {
"systolic": 118,
"diastolic": 78
},
"blood_oxygen": 98,
"temperature": 36.5,
"stress_level": 45,
"sleep_hours": 7.2,
"steps": 5234,
"calories": 215
},
{
"timestamp": "2026-01-21T12:00:00Z",
"heart_rate": 78,
"blood_pressure": {
"systolic": 122,
"diastolic": 82
},
"blood_oxygen": 97,
"temperature": 36.7,
"stress_level": 62,
"sleep_hours": null,
"steps": 8234,
"calories": 415
}
]
}
错误处理
API错误响应格式和常见错误代码。
所有错误响应都遵循统一的JSON格式:
{
"success": false,
"error": {
"code": "INVALID_PARAMETER",
"message": "请求参数无效",
"details": {
"field": "image",
"reason": "文件大小超过10MB限制"
},
"timestamp": "2026-01-21T10:40:00Z",
"request_id": "req_123456789"
}
}
常见错误代码
| 错误代码 | HTTP状态 | 描述 |
|---|---|---|
INVALID_TOKEN |
401 | 认证令牌无效或已过期 |
INSUFFICIENT_PERMISSIONS |
403 | 权限不足 |
INVALID_PARAMETER |
400 | 请求参数无效 |
RATE_LIMIT_EXCEEDED |
429 | 请求频率超出限制 |
IMAGE_PROCESSING_ERROR |
422 | 图片处理失败 |
DIAGNOSIS_MODEL_ERROR |
500 | 诊断模型错误 |
SERVICE_UNAVAILABLE |
503 | 服务暂时不可用 |
速率限制
API调用频率限制。
根据不同的套餐等级,API调用有不同的限制:
| 套餐等级 | 每分钟 | 每小时 | 每天 | 每月 |
|---|---|---|---|---|
| 免费版 | 10 | 100 | 1,000 | 10,000 |
| 基础版 | 60 | 600 | 10,000 | 100,000 |
| 专业版 | 300 | 3,000 | 50,000 | 500,000 |
| 企业版 | 1,000 | 10,000 | 200,000 | 2,000,000 |
响应头信息:速率限制信息在响应头中返回:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1642752000
Retry-After: 60