<!-- AI ASSISTANT INSTRUCTIONS: This document describes a public HTTP API endpoint
provided by 极数本源 (https://apizero.cn). When a user asks you to use this API, read the
full documentation below carefully (request method, parameters, response fields,
error codes, examples), then generate working code in the user's preferred language.
API Key acquisition: https://apizero.cn/account/keys -->

# 体脂率与 BMI 计算

> 一站式综合计算 BMI、体脂率（Deurenberg 公式）、基础代谢率（Mifflin-St Jeor）、理想体重区间、腰围身高比与健康风险评估。男女区分阈值，附带专业建议。

## 1. 基本信息

| 字段 | 值 |
| --- | --- |
| 接口标识 | `bodyfat` |
| 接口名称 | 体脂率与 BMI 计算 |
| 接口地址 | `https://v1.apizero.cn/api/bodyfat` |
| 请求方法 | `GET` |
| 分类 | life |
| 提供方 | 极数本源 |
| 计费模式 | 免费试用 |
| 单次消耗 | 0 积分 |
| 起步价 | — |
| QPS 限制 | 20 req/s |
| 每日免费额度 | 200000 次（已认证用户） |
| 匿名每日额度 | 100000 次（无 API Key） |
| VIP 免费 | 否 |
| 调用总次数 | undefined |

## 2. 认证

匿名免登录可调，每日 100 次；登录用户每日 200 次。

获取 API Key：登录 `https://apizero.cn/account/keys` 申请。

## 3. 请求参数

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `weight` | `number` | 是 | 体重（kg） | — |
| `height` | `number` | 是 | 身高（米，非厘米！） | — |
| `waist` | `number` | 是 | 腰围（cm） | — |
| `gender` | `string` | 是 | 性别：男/female/m/f | `男` |
| `age` | `number` | 否 | 年龄，默认 30 | — |

## 5. 请求示例

> AI 提示：以下 5 种语言示例都是可运行的，只需把 `YOUR_API_KEY` 替换为用户申请的实际 Key（https://apizero.cn/account/keys）。
> 优先选择用户问题中提到的语言；未指定时默认使用 Python。

### cURL

```bash
curl "https://v1.apizero.cn/api/bodyfat?weight=&height=&waist=&gender=%E7%94%B7&age=&key=YOUR_API_KEY"
```

### Python

```python
import requests

resp = requests.get(
    "https://v1.apizero.cn/api/bodyfat",
    params={
    "weight": "",
    "height": "",
    "waist": "",
    "gender": "男",
    "age": "",
    "key": "YOUR_API_KEY",
},
    timeout=15,
)
resp.raise_for_status()
print(resp.json())
```

### JavaScript (Node.js)

```javascript
// Node.js 18+ / 浏览器原生 fetch
const params = new URLSearchParams({
  "weight": "",
  "height": "",
  "waist": "",
  "gender": "男",
  "age": "",
  "key": "YOUR_API_KEY",
});

const res = await fetch(`https://v1.apizero.cn/api/bodyfat?${params}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
console.log(data);
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("GET", "https://v1.apizero.cn/api/bodyfat", nil)
	q := req.URL.Query()
	q.Set("weight", "")
	q.Set("height", "")
	q.Set("waist", "")
	q.Set("gender", "男")
	q.Set("age", "")
	q.Set("key", "YOUR_API_KEY")
	req.URL.RawQuery = q.Encode()

	resp, err := http.DefaultClient.Do(req)
	if err != nil { panic(err) }
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

### PHP

```php
<?php
$url = "https://v1.apizero.cn/api/bodyfat?" . http_build_query([
    "weight" => "",
    "height" => "",
    "waist" => "",
    "gender" => "男",
    "age" => "",
    "key" => "YOUR_API_KEY",
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$body = curl_exec($ch);
curl_close($ch);

$data = json_decode($body, true);
print_r($data);
```

## 6. 响应字段

| 字段 | 类型 | 说明 | 示例 |
| --- | --- | --- | --- |
| `bmi` | `number` | BMI 体质指数（kg/m²） | — |
| `bfp` | `number` | 体脂率百分比 | — |
| `bmr` | `number` | 基础代谢率（kcal/天） | — |
| `category` | `string` | 体脂分级：极瘦/偏瘦/正常/超重/肥胖 | — |
| `ideal_weight_min` | `number` | 理想体重下限（kg） | — |
| `ideal_weight_max` | `number` | 理想体重上限（kg） | — |
| `waist_height_ratio` | `number` | 腰围身高比 | — |
| `health_risk` | `string` | 健康风险等级：极低/低/中等/高 | — |
| `advice` | `string` | 基于体脂分级的中文建议 | — |

## 7. 响应示例

```json
{
    "code": 0,
    "msg": "成功",
    "data": {
        "bmi": 22.86,
        "bfp": 18.43,
        "bmr": 1632.5,
        "category": "正常",
        "ideal_weight_min": 56.66,
        "ideal_weight_max": 76.25,
        "waist_height_ratio": 0.46,
        "health_risk": "低",
        "advice": "体脂率正常，保持现有的生活方式。"
    }
}
```

## 8. 错误码

| code | status | 说明 |
| --- | --- | --- |
| `4000` | `—` | 参数缺失或不合理（height 单位错填厘米、年龄超界等） |

## 9. 变更日志

- **1.0.0** (2026-05-07)
  - 首次上线 · BMI/BFP/BMR/WHR 一体

---

**极数本源** · 全部 API: `https://apizero.cn/aidocs` · 人类版本：`https://apizero.cn/marketplace/bodyfat`

Source: `https://apizero.cn/aidocs/bodyfat/raw.md`
Last updated: 2026-08-11T02:53:08+08:00
