膳食营养素参考摄入量API

获取22种人群的40种营养素参考摄入量数据

API概览

本API提供权威的膳食营养素参考摄入量数据,基于最新营养学研究成果,为不同年龄段、不同生理状态的人群提供科学的营养指导。

核心功能:

身份验证

使用API前需要获取API Key和App Key,确保数据安全和访问控制。

认证方式:HTTP Header认证

X-App-Key: 您的App Key

X-API-Key: 您的API Key

API接口

查询营养素参考摄入量

GET /nutrition/references
GET

请求参数

参数名 类型 必填 说明
demographic string 人群分类标识(见下文人群分类表)
nutrients array 营养素列表,不传则返回全部营养素数据
unit_system string 单位制式:metric(公制,默认)| imperial(英制)

获取人群分类列表

GET /nutrition/demographics
GET

获取所有支持的人群分类信息

获取营养素列表

GET /nutrition/nutrients
GET

获取所有支持的营养素指标信息

人群分类

支持22种不同人群分类,覆盖全生命周期各个阶段:

婴幼儿

0-6月龄婴儿
infant_0_6months

婴幼儿

7-12月龄婴儿
infant_7_12months

幼儿

1-3岁幼儿
toddler_1_3years

学龄前

4-6岁学龄前儿童
preschool_4_6years

学龄儿童

7-8岁学龄儿童
school_7_8years

学龄儿童

9-11岁学龄儿童
school_9_11years

青少年

12-14岁青少年
teen_12_14years

青少年

15-17岁青少年
teen_15_17years

成年男性

18-29岁成年男性
adult_male_18_29

成年女性

18-29岁成年女性
adult_female_18_29

成年男性

30-49岁成年男性
adult_male_30_49

成年女性

30-49岁成年女性
adult_female_30_49

成年男性

50-64岁成年男性
adult_male_50_64

成年女性

50-64岁成年女性
adult_female_50_64

孕期女性

18-49岁孕期女性(孕早期)
pregnant_early

孕期女性

18-49岁孕期女性(孕中期)
pregnant_middle

孕期女性

18-49岁孕期女性(孕晚期)
pregnant_late

哺乳期女性

18-49岁哺乳期女性
lactating

老年男性

65-74岁老年男性
senior_male_65_74

老年女性

65-74岁老年女性
senior_female_65_74

老年男性

75岁以上老年男性
senior_male_75plus

老年女性

75岁以上老年女性
senior_female_75plus

营养素指标

支持40种营养素的参考摄入量查询:

能量
MJ/(kg.d) | kcal/(kg.d)
蛋白质
g
总碳水化合物
g
总脂肪
%E
亚油酸
%E
α-亚麻酸
%E
DHA
g/d
mL/d
mg/d
mg/d
mg/d
mg/d
mg/d
mg/d
mg/d
μg/d
mg/d
μg/d
mg/d
mg/d
μg/d
mg/d
μg/d
维生素A
μgRAE/d
维生素D
μg/d
维生素E
mgα-TE/d
维生素K
μg/d
维生素B₁
mg/d
维生素B₂
mg/d
烟酸
mg NE/d
维生素B₆
mg/d
叶酸
μgDFE/d
维生素B₁₂
μg/d
泛酸
mg/d
生物素
μg/d
胆碱
mg/d
维生素C
mg/d

返回数据结构

成功响应

{
  "code": 0,
  "message": "success",
  "data": {
    "demographic": "adult_male_18_29",
    "nutrients": [
      {
        "name": "能量",
        "unit": "kcal/(kg.d)",
        "value": 35,
        "range": "25-45",
        "notes": "基于体重计算"
      },
      {
        "name": "蛋白质",
        "unit": "g",
        "value": 65,
        "range": "55-75",
        "notes": "优质蛋白质"
      },
      {
        "name": "钙",
        "unit": "mg/d",
        "value": 800,
        "range": "700-1000",
        "notes": "成人推荐摄入量"
      },
      // 其他营养素...
    ]
  }
}

错误响应

{
  "code": 40001,
  "message": "无效的API Key",
  "data": null
}
错误码 错误信息 可能原因
0 success 请求成功
40001 无效的API Key API Key错误或已过期
40002 无效的App Key App Key错误或未注册
40003 参数错误 缺少必填参数或参数格式错误
40401 人群分类不存在 指定的人群分类标识无效
50001 服务器错误 内部服务器错误,请稍后重试

使用示例

获取18-29岁成年男性营养素参考摄入量

curl -X GET "https://api.nutrition.example.com/nutrition/references?demographic=adult_male_18_29" \
-H "X-App-Key: 您的App Key" \
-H "X-API-Key: 您的API Key"

获取4-6岁学龄前儿童的钙和维生素D摄入量

curl -X GET "https://api.nutrition.example.com/nutrition/references?demographic=preschool_4_6years&nutrients=钙,维生素D" \
-H "X-App-Key: 您的App Key" \
-H "X-API-Key: 您的API Key"

JavaScript 示例

const fetchNutritionData = async (demographic) => {
  const response = await fetch(
    `https://api.nutrition.example.com/nutrition/references?demographic=${demographic}`,
    {
      headers: {
        'X-App-Key': '您的App Key',
        'X-API-Key': '您的API Key'
      }
    }
  );
  
  if (!response.ok) {
    throw new Error('网络响应错误');
  }
  
  const data = await response.json();
  return data;
};

// 使用示例
fetchNutritionData('adult_female_30_49')
  .then(data => console.log(data))
  .catch(error => console.error(error));

Python 示例

import requests

def get_nutrition_data(demographic):
    url = f"https://api.nutrition.example.com/nutrition/references?demographic={demographic}"
    headers = {
        'X-App-Key': '您的App Key',
        'X-API-Key': '您的API Key'
    }
    
    response = requests.get(url, headers=headers)
    
    if response.status_code == 200:
        return response.json()
    else:
        response.raise_for_status()

# 使用示例
try:
    data = get_nutrition_data('teen_15_17years')
    print(data)
except requests.RequestException as e:
    print(f"请求错误: {e}")

性能与限制

响应速度

• 平均响应时间: < 100ms

• 99% 请求: < 300ms

• 支持高并发访问

安全保障

• HTTPS 加密传输

• 双重密钥认证

• IP 白名单支持

更新频率

• 数据更新: 每季度同步

• 基础设施: 7x24 监控

• 可用性: 99.9%