示例
DeepoMe API使用示例,涵盖常见场景的完整代码,帮助开发者快速上手。
更新时间:2026-06-03
API示例代码示例Python示例JavaScript示例快速开始
示例1:完整的衰老检测流程
Python
from deepome import DeepoMeClient
client = DeepoMeClient(api_key="YOUR_API_KEY")
# Step 1: 创建检测订单
order = client.samples.create(
user_id="USER_001",
sample_type="saliva",
test_items=["epigenetic_age", "organ_age", "pathway"]
)
# Step 2: 等待检测完成(通常5-7个工作日)
import time
while True:
status = client.samples.get_status(order.sample_id)
if status.status == "completed":
break
time.sleep(3600) # 每小时检查一次
# Step 3: 获取完整报告
report = client.samples.get_report(order.sample_id)
# Step 4: 获取药物推荐
screening = client.screening.create(
sample_id=order.sample_id,
categories=["aging_intervention", "metabolic"]
)
# Step 5: 输出结果
print(f"=== DeepoMe 衰老检测报告 ===")
print(f"日历年龄: {report.chronological_age}")
print(f"生物年龄: {report.biological_age}")
print(f"年龄差异: {report.biological_age - report.chronological_age:+.1f} 岁")
print()
print("器官衰老评估:")
for organ in report.organ_ages:
status = "正常" if abs(organ.offset) <= 2 else "注意"
print(f" {organ.name}: {organ.age} 岁 ({status})")
print()
print("推荐药物 TOP 5:")
for drug in screening.candidates[:5]:
print(f" {drug.name} - 匹配度: {drug.match_score:.1%}")
示例2:批量通路分析
sample_ids = ["CAP-2024-001", "CAP-2024-002", "CAP-2024-003"]
results = client.moa.batch_pathway_analysis(
sample_ids=sample_ids,
pathways=["mTOR", "AMPK", "NF_KB", "SIRT1"]
)
for result in results:
print(f"\n样本 {result.sample_id}:")
for pathway, score in result.pathway_scores.items():
print(f" {pathway}: 活性={score.activity}, 偏移={score.aging_offset:+.1f}")
示例3:Webhook集成
# 注册Webhook接收检测完成通知
client.webhooks.create(
url="https://your-app.com/api/webhooks/deepome",
events=["sample.completed", "screening.completed"]
)
参考资料
- DeepoMe API 完整文档
- SDK API 参考