心肺功能评估
最后更新:2022年12月01日
接口能力
本接口可根据跑步中的心率、速度(或步频)及基础体征信息评估最大摄氧量指标,进而评估心肺功能强弱。
说明
本接口仅适用于时长10分钟以上的跑步场景,其他场景下应用会造成准确率降低。
请求方法
HTTP方法: POST
请求URL:http://api.amsu-new.com/amsu-analysis/v2/health/cpf/results/
数据提交方式:application/json
Header参数:
字段 | 类型 | 描述 |
---|---|---|
Authorization | Bearer Token | 构造方式为Bearer+(空格)+(Access Token) |
Body参数:
字段 | 类型 | 必传 | 范围 | 描述 |
---|---|---|---|---|
height | Integer | 是 | 90 - 240 | 身高,单位:cm |
weight | Float | 是 | 30.0 - 200.9 | 体重,单位:kg |
age | Integer | 是 | 18 - 120 | 年龄 |
gender | Integer | 是 | 0 - 1 | 性别,男1 女0 |
body_fat | Float | 是 | 3 - 50 | 体脂率,单位:%(例如体脂率15.1% ,则上传15.1 ) |
hr_list | Array of Integer | 是 | 40 - 220 | 心率列表,其元素为每分钟的平均心率,元素数量不少于10个 |
speed_list | Array of Float | 否 | 0 - 45.0 | 速度列表,其元素为每分钟的平均速度,元素数量不少于10个,单位:km/h,此字段与cadence_list 字段应至少选择一个上传 |
cadence_list | Array of Integer | 否 | 0 - 230 | 步频列表,其元素为每分钟的平均步频,元素数量不少于10个,此字段与speed_list 字段应至少选择一个上传 |
说明
相比于步频数据,使用速度数据进行评估的结果更为可靠,故当上传的数据中同时存在速度列表和步频列表时系统会选择以速度列表来评估最大摄氧量。
返回参数
字段 | 类型 | 描述 |
---|---|---|
id | Integer | 本次分析的标识 |
level | Integer | 心肺功能评估结果,共分为5个等级:1较差 2尚可 3良好 4优秀 5卓越 |
vo2max | Float | 最大摄氧量,单位:mL/(kg·min) |
正确返回示例:
HTTP状态码:200
{
"id": 357,
"level": 3,
"vo2max": 47.5
}
HTTP状态码不为200
{
"error": {
"code": "COMMON.NOT_ENOUGH_DATA",
"msg": "Field 'cadence_list' should have at least 10 items."
}
}
错误码
参见 公共错误码
示例代码
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"height\":170,\"weight\":58,\"age\":28,\"gender\":1,\"body_fat\":18,\"hr_list\":[170, 108, 172, 102, 174, 108, 173, 96, 172, 106],\"speed_list\":[5.0, 6.3, 5.2, 3.9, 5.1, 7.2, 8.1, 9.6, 7.2, 7.3],\"cadence_list\":[172, 110, 176, 110, 176, 86, 173, 110, 174, 106]}");
Request request = new Request.Builder()
.url("http://api.amsu-new.com/amsu-analysis/v2/health/cpf/results/")
.method("POST", body)
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhcHBfa2V5OjkzZWUyMGNiNTliOTY0OWY3YzIwIiwiZXhwIjoxNjQ4NTQxODExfQ.UhCfS7doPt7oN9BQaSL5w_GMhB9Jz6D4eYJhBGMDK6k")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://api.amsu-new.com/amsu-analysis/v2/health/cpf/results/"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Authorization": @"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhcHBfa2V5OjkzZWUyMGNiNTliOTY0OWY3YzIwIiwiZXhwIjoxNjQ4NTQxODExfQ.UhCfS7doPt7oN9BQaSL5w_GMhB9Jz6D4eYJhBGMDK6k",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\"height\":170,\"weight\":58,\"age\":28,\"gender\":1,\"body_fat\":18,\"hr_list\":[170, 108, 172, 102, 174, 108, 173, 96, 172, 106],\"speed_list\":[5.0, 6.3, 5.2, 3.9, 5.1, 7.2, 8.1, 9.6, 7.2, 7.3],\"cadence_list\":[172, 110, 176, 110, 176, 86, 173, 110, 174, 106]}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhcHBfa2V5OjkzZWUyMGNiNTliOTY0OWY3YzIwIiwiZXhwIjoxNjQ4NTQxODExfQ.UhCfS7doPt7oN9BQaSL5w_GMhB9Jz6D4eYJhBGMDK6k");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"height": 170,
"weight": 58,
"age": 28,
"gender": 1,
"body_fat": 18,
"hr_list": [170, 108, 172, 102, 174, 108, 173, 96, 172, 106],
"speed_list": [5, 6.3, 5.2, 3.9, 5.1, 7.2, 8.1, 9.6, 7.2, 7.3],
"cadence_list": [172, 110, 176, 110, 176, 86, 173, 110, 174, 106]
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://api.amsu-new.com/amsu-analysis/v2/health/cpf/results/", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import requests
import json
url = "http://api.amsu-new.com/amsu-analysis/v2/health/cpf/results/"
payload = json.dumps({
"height": 170,
"weight": 58,
"age": 28,
"gender": 1,
"body_fat": 18,
"hr_list": [170, 108, 172, 102, 174, 108, 173, 96, 172, 106],
"speed_list": [5, 6.3, 5.2, 3.9, 5.1, 7.2, 8.1, 9.6, 7.2, 7.3],
"cadence_list": [172, 110, 176, 110, 176, 86, 173, 110, 174, 106]
})
headers = {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhcHBfa2V5OjkzZWUyMGNiNTliOTY0OWY3YzIwIiwiZXhwIjoxNjQ4NTQxODExfQ.UhCfS7doPt7oN9BQaSL5w_GMhB9Jz6D4eYJhBGMDK6k',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)