Body Fat Scale Open APIs

Last Updated on : 2023-07-18 09:40:07download

This topic describes the APIs of body fat scale.

API list

Request method API Description
POST /v1.0/scales/{device_id}/analysis-reports Generate body fat report
GET /v1.0/scales/{device_id}/datas/history Get weighing records
PUT /v1.0/scales/{device_id}/users/{user_id}/datas/{id} Bind weighing records to users
DELETE /v1.0/scales/{device_id}/datas/{id} Delete weighing records
DELETE /v1.0/scales/{device_id}/users/{user_id}/datas Delete weighing records
GET /v1.0/scales/{device_id}/users/{user_id}/trend-datasing Get the trending data of users

Generate body fat report

Function description

Generate body fat report.

API address

POST /v1.0/scales/{device_id}/analysis-reports

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID Yes
height Double Boby Height (cm) Yes
weight Double Boby Weight (kg) Yes
age Integer Boby Age Yes
sex Integer Boby Gender
  • 1: male
  • 2: female
Yes
resistance String Boby Electrical resistance of body fat scale Yes

Return parameter

Parameter name Data type Description
code Integer Refer to Error Code.
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Object Return result.

Result

Parameter name Data type Description
Boby_type Integer Body shape type:
  • 0: underweight
  • 1: normal
  • 2: overwight
  • 3: obese
  • 4: severely obese
weight Double Weight
ffm String Lean body mass
water String Body water
Boby_score String Body score
bones String Bone mass
muscle String Muscle mass
protein String Proteins
fat String Body fat
metabolism String Basel metabolism rate
visceral_fat String Visceral fat rating
Boby_age String Physical age
bmi String BMI

Request example

POST /v1.0/scales/xxx/analysis-reports { "height":178, "weight":78.3, "resistance":718, "age":26, "sex":1 }

Return example

{
  "success": true,
  "t": 1540955256215,
  "result": {
    "Boby_type": 2,
    "weight": 78.3,
    "ffm": "58.3",
    "water": "51.4",
    "Boby_score": "82.1",
    "bones": "3.6",
    "muscle": "54.9",
    "protein": "18.5",
    "fat": "25.5",
    "Boby_age": "29",
    "metabolism": "1778",
    "visceral_fat": "9.3",
    "bmi": "27.1"
  }
}

Get weighing records

Function description

Get weighing records.

API address

GET /v1.0/scales/{device_id}/datas/history

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID Yes
page_no Integer URL The page number of the list Yes
page_size Integer URL The number of rows per page Yes
user_id String URL Tuya user ID No
start_time Long URL The 13-bit timestamp of start time No
end_time Long URL The 13-bit timestamp of end time. No

Return parameter

Parameter name Data type Description
code Integer Refer to Error Code.
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Object Weighing records

Result

Parameter name Parameter type Description
total Integer The total number of pages
records List Weighing records

Records

Parameter name Parameter type Description
device_id String Device ID
id String Data ID
user_id String Associated user ID
nick_name String Associated user name
create_time Long Create time
weight Double Weight (kg)
height Double Height (cm)

Request example

GET /v1.0/scales/48264660bcddc215e183/datas/history? page_no=1&page_size=10

Return example

{
  "success": true,
  "t": 1573441137,
  "result": {
    "total": 2,
    "records": [
      {
        "device_id": "xxx",
        "id": "0020y",
        "user_id": "00234",
        "nick_name": "yangyc",
        "create_time": 1573441137
      },
      {
        "device_id": "xxx",
        "id": "0020z",
        "user_id": "00233",
        "nick_name": "yangyc2",
        "create_time": 1573441137
      }
    ]
  }
}

Bind weighing records to users

Function description

Bind weighing records to users

API address

PUT /v1.0/scales/{device_id}/users/{user_id}/datas/{id}

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID Yes
user_id String URI Bound user ID Yes
id String URI Data ID Yes

Return parameter

Parameter name Data type Description
code Integer Refer to Error Code.
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Boolean The returned result if the binding is successful.

Request example

POST /v1.0/scales/ve1231023o120/users/97/datas/xxxx0001

Return example

{
  "success": true,
  "t": 1573441137,
  "result": true
}

Delete weighing records

Function description

Delete weighing records.

API address

DELETE /v1.0/scales/{device_id}/datas/{id}

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID Yes
id String URI Data ID Yes

Return parameter

Parameter name Data type Description
code Integer Refer to Error Code.
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Boolean The returned result if the binding is successful.

Request example

DELETE /v1.0/scales/ve12023131/datas/1

Return example

{
  "success": true,
  "t": 1573441137,
  "result": true
}

Delete weighing records

Function description

Delete weighing records.

API address

DELETE /v1.0/scales/{device_id}/users/{user_id}/datas

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID Yes
user_id String URI Tuya user ID Yes

Return parameter

Parameter name Data type Description
code Integer Refer to Error Code.
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Boolean Return result.

Request example

DELETE /v1.0/scales/ve123891293/users/97/datas

Return example

{
  "success": true,
  "t": 1573441137,
  "result": true
}

Get the trending data of users

Function description

Get the trending data of users. It shows the trending data of the current week by default.

API address

GET /v1.0/scales/{device_id}/users/{user_id}/trend-datas

Request parameter

Parameter name Data type Parameter type Description Required
device_id String URI Device ID. Yes
user_id String URI Bound user ID. Yes
start_day String URL The start date in the format of yyyyMMdd. No
end_day String URL The end date in the format of yyyyMMdd. No

Return parameter

Parameter name Data type Description
code Integer Refer to Error Code.
success Boolean Whether the operation is successful.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Array Trending lists

Result

Parameter name Parameter type Description
day String Recording period(in days)
value String The latest weighting record every day.

Request example

GET /v1.0/scales/ve1231231/users/1/trend-datas? start_day=20190802&end_day=20191103

Return example

{
  "success": true,
  "t": 1573441137,
  "result": [
    {
      "value": "50.0",
      "day": "20190102"
    },
    {
      "value": "51.0",
      "day": "20190103"
    }
  ]
}