獲取Jawbone UP中的個人數據(二)非官方API, Part 5

5. 鍛鍊情況細節——Workouts

鍛鍊使用戶標註的某段時間的運動。通過“記錄鍛鍊情況”菜單完成。

Meals

除了前面介紹的 user/%userXid%/social 等用戶行爲概述 API 之外,與鍛鍊相關的 API 還有以下幾個:

user/%userXid%/workouts
workouts/%evtXid%
workouts/%evtXid%/snapshot

從 user/%userXid%/social 結果中的 "data"."feed"."xid"; 從 user/%userXid%/workouts 結果中的 "data"."items"."xid" 獲得 %evtXid% , 用於調用 workouts/%evtXid% 和 workouts/%evtXid%/snapshot 。

並非所有的 workouts/%evtXid%/snapshot 都會返回詳細的數據,一些鍛鍊方式,如:步行、跑步等,使用 snapshot 能夠返回細節運動數據;而另一些鍛鍊方式,如:瑜伽,則沒有細節運動數據。

Meals

user/%userXid%/workouts

這個 API 能夠返回個人的鍛鍊概括數據列表。在Jawbone UP 的手機應用界面中並沒有對應的界面輸出。

Request:

GET
https://jawbone.com/nudge/api/users/@me/workouts?start_time=1370707200&limit=100
https://jawbone.com/nudge/api/users/RGaCBFg9CsDYVvm2kchbcw/workouts?start_time=1370707200&limit=100

Params:

'start_time' : startTime, #start_time爲 long 型時間,即從1970年以來的秒數,可以不填
'end_time' : endTime,     #end_time爲 long 型時間,即從1970年以來的秒數,可以不填
'limit' : limit           #最多返回結果條數限制

Return :

{
    "meta": {
        "code": 200, 
        "message": "OK", 
        "user_xid": "RGaCBFg9CsDYVvm2kchbcw", 
        "time": 1372472625
    }, 
    "data": {
        "items": [
            {
                "user": {
                    "xid": "RGaCBFg9CsDYVvm2kchbcw", 
                    "image": "user/image/i/51b4916b03eb185d1c1948a5_RGaCBFg9CsDYVvm2kchbcw_137078820345_2781804_photo.jpeg", 
                    "type": "user"
                }, 
                "reaction": null, 
                "time_completed": 1370730615, 
                "xid": "EJpCkyAtwoPa1a-leTNHQg", 
                "band_ids": [], 
                "title": "\u745c\u4f3d", 
                "snapshot_image": "", 
                "route": "", 
                "networks": [], 
                "time_created": 1370728815, 
                "sub_type": 6, 
                "date": 20130609, 
                "app_generated": false, 
                "time_updated": 1370732478, 
                "time_removed": 0, 
                "image": "", 
                "is_manual": true, 
                "shared": true, 
                "type": "workout", 
                "is_complete": true, 
                "details": {
                    "tz": "Asia/Shanghai", 
                    "goal": 0, 
                    "calories": 89.4861169007, 
                    "km": 0.0, 
                    "bmr": 37.8849980137, 
                    "intensity": 1, 
                    "bg_calories": 0, 
                    "meters": 0, 
                    "time": 1800, 
                    "bg_active_time": 0, 
                    "steps": 0, 
                    "bmr_calories": 27.4861169007
                }
            }, 
            {
                "user": {
                    "xid": "RGaCBFg9CsDYVvm2kchbcw", 
                    "image": "user/image/i/51b4916b03eb185d1c1948a5_RGaCBFg9CsDYVvm2kchbcw_137078820345_2781804_photo.jpeg", 
                    "type": "user"
                }, 
                "reaction": null, 
                "time_completed": 1371016848, 
                "xid": "EJpCkyAtwoPXN30hjKufWg", 
                "band_ids": [], 
                "title": "\u6b65\u884c", 
                "snapshot_image": "/nudge/image/e/1371044854/EJpCkyAtwoPXN30hjKufWg.png", 
                "route": "", 
                "networks": [], 
                "time_created": 1371006048, 
                "sub_type": 1, 
                "date": 20130612, 
                "app_generated": false, 
                "time_updated": 1371044854, 
                "time_removed": 0, 
                "image": "", 
                "is_manual": true, 
                "shared": true, 
                "type": "workout", 
                "is_complete": true, 
                "details": {
                    "tz": "Asia/Shanghai", 
                    "goal": 0, 
                    "calories": 802.075100205, 
                    "km": 2.249, 
                    "bmr": 164.075100205, 
                    "intensity": 1, 
                    "bg_calories": 127.953000784, 
                    "meters": 2249, 
                    "time": 10800, 
                    "bg_active_time": 1871, 
                    "steps": 3372, 
                    "bmr_calories": 164.075100205
                }
            }
        ], 
        "size": 2
    }
}

workouts/%evtXid%

從 user/%userXid%/social 結果中的 "data"."feed"."xid"; 從 user/%userXid%/workouts 結果中的 "data"."items"."xid" 獲得 %evtXid% , 用於調用 workouts/%evtXid% 。

Request:

GET
https://jawbone.com/nudge/api/workouts/EJpCkyAtwoPa1a-leTNHQg

Params:

Return :

{
    "meta": {
        "code": 200, 
        "message": "OK", 
        "user_xid": "RGaCBFg9CsDYVvm2kchbcw", 
        "time": 1372431987
    }, 
    "data": {
        "image": "", 
        "time_removed": 0, 
        "emotions": {
            "items": [], 
            "size": 0
        }, 
        "snapshot_image": "/nudge/image/e/1371044854/EJpCkyAtwoPXN30hjKufWg.png", 
        "networks": [], 
        "time_completed": 1371016848, 
        "xid": "EJpCkyAtwoPXN30hjKufWg", 
        "title": "\u6b65\u884c", 
        "comments": {
            "items": [], 
            "size": 0
        }, 
        "details": {
            "tz": "Asia/Shanghai", 
            "goal": 0, 
            "calories": 802.075100205, 
            "km": 2.249, 
            "bmr": 164.075100205, 
            "intensity": 1, 
            "bg_calories": 127.953000784, 
            "meters": 2249, 
            "time": 10800, 
            "bg_active_time": 1871, 
            "steps": 3372, 
            "bmr_calories": 164.075100205
        }, 
        "shared": true, 
        "type": "workout", 
        "band_ids": [], 
        "user": {
            "xid": "RGaCBFg9CsDYVvm2kchbcw", 
            "name": "Tester VisHealth", 
            "short_name": "Tester", 
            "image": "user/image/i/51b4916b03eb185d1c1948a5_RGaCBFg9CsDYVvm2kchbcw_137078820345_2781804_photo.jpeg", 
            "last": "VisHealth", 
            "type": "user", 
            "first": "Tester"
        }, 
        "date": 20130612, 
        "sub_type": 1, 
        "reaction": null, 
        "time_updated": 1371044854, 
        "route": "", 
        "app_generated": false, 
        "time_created": 1371006048, 
        "is_manual": true, 
        "is_complete": true, 
        "goals": {
            "steps": 10000, 
            "workout_time": null
        }
    }
}

workouts/%evtXid%/snapshot

從 user/%userXid%/social 結果中的 "data"."feed"."xid"; 從 user/%userXid%/workouts 結果中的 "data"."items"."xid" 獲得 %evtXid% , 用於調用 workouts/%evtXid%/snapshot 。

並非所有的 workouts/%evtXid%/snapshot 都會返回詳細的數據,一些鍛鍊方式,如:步行、跑步等,使用 snapshot 能夠返回細節運動數據;而另一些鍛鍊方式,如:瑜伽,則沒有細節運動數據。

Request:

GET
https://jawbone.com/nudge/api/workouts/EJpCkyAtwoPa1a-leTNHQg/snapshot  #瑜伽,無詳情
https://jawbone.com/nudge/api/workouts/EJpCkyAtwoPXN30hjKufWg/snapshot?bucket=600  #步行,有詳情

Params:

'bucket' : bucket # 運動數據彙總時間顆粒度,以秒爲單位,最小取值爲 60 

Return :

無詳情的“瑜伽”結果示例如下:

{
    "meta": {
        "code": 200, 
        "message": "OK", 
        "user_xid": "RGaCBFg9CsDYVvm2kchbcw", 
        "time": 1372473235
    }, 
    "data": []
}

有詳情的“步行”結果示例如下:

{
    "meta": {
        "code": 200, 
        "message": "OK", 
        "user_xid": "RGaCBFg9CsDYVvm2kchbcw", 
        "time": 1372473234
    }, 
    "data": [
        [
            1371006588, 
            0
        ], 
        [
            1371007188, 
            262.6
        ], 
        [
            1371007788, 
            356.4
        ], 
        [
            1371008388, 
            0
        ], 
        [
            1371008988, 
            537.0
        ], 
        [
            1371009588, 
            712.2
        ], 
        [
            1371010188, 
            320.8
        ], 
        [
            1371010788, 
            229.0
        ], 
        [
            1371011388, 
            0
        ], 
        [
            1371011988, 
            164.0
        ], 
        [
            1371012588, 
            115.4
        ], 
        [
            1371013188, 
            102.6
        ], 
        [
            1371013788, 
            38.2
        ], 
        [
            1371014388, 
            39.8
        ], 
        [
            1371014988, 
            292.0
        ], 
        [
            1371015588, 
            54.0
        ], 
        [
            1371016188, 
            0
        ], 
        [
            1371016788, 
            106.0
        ], 
        [
            1371017388, 
            42.0
        ]
    ]
}
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章