> For the complete documentation index, see [llms.txt](https://magicweaver-inc.gitbook.io/magicweaver/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://magicweaver-inc.gitbook.io/magicweaver/api-functions.md).

# MW API DOCUMENTATION

## Get Term Condition

<mark style="color:blue;">`GET`</mark> `API_END_POINT/mw_term_condition/`

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

#### Terminology:

* MW: the short name of MagicWeaver
* CP: the short name of Client Partner who is a business client of MagicWeaver
* MW-X-SECRET: A long secret/password string, provided by MW. It is shared by MW and CP for authenticating sign-in and sign-up requests and passing user information from CP sides to MW with encryption.&#x20;
* JWT: an encrypted token generate with jwt module of Python or other software with same algorithm&#x20;
* MW-JWT: is generated by MW server, used for authenticating service access and identifying user
* MW-X-JWT: is generated by MW server or/and CP server with exactly same algorithm and secret key string. MW and CP use it for identifying each other for data and information exchange. For example, MW uses it to identify a CP and authenticate service access.
* CP-JWT: is generated by CP server, used for authenticating their service access and identifying user account

## Sign up

<mark style="color:green;">`POST`</mark> `API_END_POINT/sign_up/<partner>/`

This endpoint allows you to get free cakes.

#### Path Parameters

| Name    | Type   | Description                  |
| ------- | ------ | ---------------------------- |
| partner | string | partner short name e.g. 'MW' |

#### Request Body

| Name   | Type   | Description                                          |
| ------ | ------ | ---------------------------------------------------- |
| "json" | string | {“email”: “<xxx@xxx.xxx>”, ”password”: “xxxxxxxxxx”} |

{% tabs %}
{% tab title="200 Signed up successfully." %}

```javascript
{ 
“status”: 200, 
   	“msg”: “successfully signed up”,
	“code”: 1000
}

```

{% endtab %}
{% endtabs %}

## Sign in from mw app&#x20;

<mark style="color:green;">`POST`</mark> `API_END_POINT/sign_in/<partner>`

#### Path Parameters

| Name    | Type   | Description                  |
| ------- | ------ | ---------------------------- |
| partner | string | partner short name e.g. 'MW' |

#### Request Body

| Name   | Type   | Description                                          |
| ------ | ------ | ---------------------------------------------------- |
| "json" | string | {"email": "<xxx@xxx.xxx>", "password": "xxxxxxxxxx"} |

{% tabs %}
{% tab title="200 " %}

```
{ 
   “status”: 200, 
   “mw_jwt”: “MW-JWT string”,
   “mode”:  "NORMAL" | "DEVELOPER",
	 “code”: 1000
}

```

{% endtab %}
{% endtabs %}

## &#x20;Sign in from CP app

<mark style="color:green;">`POST`</mark> `API_END_POINT/sign_in/<partner>`

#### Path Parameters

| Name    | Type   | Description                  |
| ------- | ------ | ---------------------------- |
| partner | string | partner short name e.g. 'MW' |

#### Request Body

| Name   | Type   | Description                     |
| ------ | ------ | ------------------------------- |
| "json" | string | {"mw\_x\_jwt": MW-X-JWT string} |

{% tabs %}
{% tab title="200 " %}

```
{ 
   “status”: 200, 
   “mw_jwt”: “MW-JWT string”,
   “mode”:  "NORMAL" | "DEVELOPER",
	 “code”: 1000
}

```

{% endtab %}
{% endtabs %}

## Reset Password

<mark style="color:green;">`POST`</mark> `API_END_POINT/request_reset_passwd/<partner>/`

#### Path Parameters

| Name    | Type   | Description                  |
| ------- | ------ | ---------------------------- |
| partner | string | partner short name e.g. 'MW' |

#### Request Body

| Name   | Type   | Description                      |
| ------ | ------ | -------------------------------- |
| "json" | string | {"email": "<useremail@xxx.com>"} |

{% tabs %}
{% tab title="200 " %}

```
{ 
   “status”: 200, 
   “msg”: “A reset password email has been sent to your email: 
           useremail@xxx.com”,
   “code”: 1000
}

```

{% endtab %}
{% endtabs %}

<mark style="color:green;">`POST`</mark> `API_END_POINT/change_passwd/`

#### Request Body

| Name   | Type   | Description                                                                      |
| ------ | ------ | -------------------------------------------------------------------------------- |
| "json" | string | { "old\_password": "test", "new\_password": "Wide", "confirm\_password": "Wide"} |

{% tabs %}
{% tab title="200 " %}

```
{
  	"msg": "Successfully updated your password.",
  	"status": 200,
	  “code”: 1000
}

```

{% endtab %}
{% endtabs %}

## Create Profile

<mark style="color:green;">`POST`</mark> `API_END_POINT/create_profile/`

#### Headers

| Name     | Type   | Description                             |
| -------- | ------ | --------------------------------------- |
| "mw-jwt" | string | `"MW-JWT string" obtained when sign in` |

#### Request Body

| Name | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ---- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| json | string | <p><code>{</code> <br><code>"profile": {</code><br><code>"front\_gyro\_z": 0,</code> <br><code>"gender": "m",</code> <br><code>"unit":  "cm/kg",</code><br><code>"meta": {</code> <br><code>"app\_version": "2.9.92-dev",</code> <br><code>"app\_os": "android",</code> <br><code>"app\_os\_version": "9",</code> <br><code>"front": {</code> <br><code>"focal\_length": 4.3,</code><br><code>"focal\_length\_35mm": 26,</code> <br><code>"rotation": \[ 90.91763305664062, 90.97338104248047 ],</code> <br><code>"aperture": 1.16,</code> <br><code>"camera\_name": "SM-G960U",</code> <br><code>"resolution": \[ 2880, 2160 ] },</code><br><code>"side": {</code><br><code>"focal\_length": 4.3,</code> <br><code>"focal\_length\_35mm": 26,</code> <br><code>"rotation": \[ 90.31617736816406, 92.4752197265625 ],</code> <br><code>"aperture": 1.16,</code> <br><code>"camera\_name": "SM-G960U",</code> <br><code>"resolution": \[ 2880, 2160 ]</code> <br><code>}</code> <br><code>},</code><br><code>"side\_photo": (str) Side photo png base64 stream,</code> <br><code>"name": "delete me pls",</code> <br><code>"reference": "letter",</code><br><code>"side\_gyro\_x": 0,</code> <br><code>"fit": "regular",</code> <br><code>"side\_gyro\_y": 0,</code><br><code>"side\_gyro\_z": 0,</code> <br><code>"front\_photo": (str) Front photo png base64 stream,</code> <br><code>"front\_gyro\_x": 0,</code> <br><code>"height\_guess": 1.73,</code><br><code>"front\_gyro\_y": 0,</code><br><code>"weight\_guess": 80</code> <br><code>}</code></p> |

{% tabs %}
{% tab title="200 " %}

```
{
 "msg": "successfully created a profile",
  "status": 200
}
```

{% endtab %}
{% endtabs %}

## Delete profile

<mark style="color:green;">`POST`</mark> `API_END_POINT/delete_profile_by_id/<profile_id>/`

#### Path Parameters

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| profile\_id | string |             |

#### Headers

| Name   | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| mw-jwt | string | MW\_JWT string(obtained when sign in) |

{% tabs %}
{% tab title="200 " %}

```
{
  "msg": "successfully deleted profile",
  "status": 200,
  “code”: 1000
}
```

{% endtab %}
{% endtabs %}

## Update profile

<mark style="color:green;">`POST`</mark> `API_END_POINT/update_profile/<profile_id>`

#### Path Parameters

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| profile\_id | string |             |

#### Headers

| Name   | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| mw-jwt | string | MW\_JWT string(obtained when sign in) |

#### Request Body

| Name | Type   | Description                                                                                                                       |                                              |                                                                       |                          |                                                               |                   |                                                         |
| ---- | ------ | --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | --------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------- | ----------------- | ------------------------------------------------------- |
| json | string | <p><code>{</code> <br><code>"profile":{</code><br><code>"name": (str) Name of new measurement profile "gender": (str) Gender ("m" | "f")</code> <br><code>“unit”: (str) ("cm/kg” | “ft-in/lb"),</code><br><code>"height\_guess": (float) Height in meter | foot inches, e.g. 1.79 m | 5'-10''</code><br><code>"weight\_guess": (float) Weight in kg | pound, e.g. 80 kg | 176.6 lb</code><br><code>}</code><br><code>}</code></p> |

{% tabs %}
{% tab title="200 " %}

```
{
  "profile_info": {
    "fit": "regular",
    "gender": "m",
    "height_guess": 1.7,
    "measure_config": "default",
    "name": "Chen test upload",
    "reference": "letter",
    "status": 200,
    "unit": "ft-in/lb",
    "weight_guess": 77.11
  },
  "reprocess": false,   
  "status": 200,
  “code”: 1000
}

```

{% endtab %}
{% endtabs %}

## Update measurements

<mark style="color:green;">`POST`</mark> `API_END_POINT/update_measurements/<profile_id>/`

#### Path Parameters

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| profile\_id | string |             |

#### Headers

| Name   | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| mw-jwt | string | MW\_JWT string(obtained when sign in) |

#### Request Body

| Name | Type   | Description                                                                                                                                                                                                                                                                                     |
| ---- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| json | string | <p><code>{</code><br><code>"profile": {</code> <br><code>"measurements": {</code><br><code>key-value pairs of body part names and raw measurement values</code> <br><code>arm: 55,</code> <br><code>hip: 90,</code> <br><code>chest: 93, ... }</code> <br><code>}</code> <br><code>}</code></p> |

{% tabs %}
{% tab title="200 " %}

```
 {
    "status": 200,
    "measurement": current measurement dict
    “code”:1000
  }	
```

{% endtab %}
{% endtabs %}

## Show 3D Model

<mark style="color:blue;">`GET`</mark> `API_END_POINTshow_3d_models_in_js_viewer_by_profile_id/<profile_id>/`

#### Path Parameters

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| profile\_id | string |             |

#### Headers

| Name   | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| mw-jwt | string | MW\_JWT string(obtained when sign in) |

{% tabs %}
{% tab title="200 " %}

```
redirect url response
```

{% endtab %}
{% endtabs %}

## Ger Profile Measurements

<mark style="color:green;">`POST`</mark> `API_END_POINT/get_measurements_by_profile_id/<profile_id>/`

#### Path Parameters

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| profile\_id | string |             |

#### Headers

| Name   | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| mw-jwt | string | MW\_JWT string(obtained when sign in) |

#### Request Body

| Name | Type   | Description                                                                        |
| ---- | ------ | ---------------------------------------------------------------------------------- |
| json | string | <p>{<br>"parts": \[], # names of body parts to calculate measurement for <br>}</p> |

{% tabs %}
{% tab title="200 " %}

```
{
  "measurements": {
    "arm_length": 0.643,
    "back_shoulder": 0.478,
    "bicep": 0.444,
    "chest": 1.088,
    "height": 1.796,
    "hip": 1.091,
    "knee": 0.445,
    "neck": 0.434,
    "pants_outseam": 0.99,
    "stomach": 0.992,
    "waist": 1.036
 		 },
  "status": 200,
  “code”: 1000
}

```

{% endtab %}
{% endtabs %}

## Get Profile Info

<mark style="color:blue;">`GET`</mark> `API_END_POINT/get_profile_info_by_id/<profile_id>/`

#### Path Parameters

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| profile\_id | string |             |

#### Headers

| Name   | Type   | Description                          |
| ------ | ------ | ------------------------------------ |
| mw-jwt | string | MW\_JWT string(obtained when sign in |

{% tabs %}
{% tab title="200 " %}

```
{
  "profile_info": {
    "fit": "regular",
    "gender": "m",
    "height_guess": 1.75,
    "measure_config": "default",
    "profile_name": "我的裤子1",
    "reference": "letter",
    "unit": "cm/kg",
    "weight_guess": 80
  },
  "status": 200,
  “code”: 1000
}

```

{% endtab %}
{% endtabs %}

## List Profiles

<mark style="color:blue;">`GET`</mark> `API_END_POINT/list_profiles/app_list/<sort_method>/`

#### Path Parameters

| Name         | Type   | Description                           |
| ------------ | ------ | ------------------------------------- |
| sort\_method | string | "time" or "name" or "process\_status" |

#### Headers

| Name   | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| mw-jwt | string | MW\_JWT string(obtained when sign in) |

{% tabs %}
{% tab title="200 " %}

```
{
  "profiles": [
{
      "comments": "",
      "complete_time": [
        "2018-12-12",
        "14:36:56"
      ],
      "photos": {
                      "front_photo_small": front_photo_url,
          "side_photo_small": side_photo_url,

              },
      "process_status": true | false,
      "profile_id": "profile_2018-12-10_T_12-32-47",
      "profile_name": "test",
      "profile_process_status": "MW_COMPLETE" | "MW_FAILED"
                                "MW_INPROGRESS"| 

}
],
“status”: 200,
“code”: 1000
}

```

{% endtab %}
{% endtabs %}

## Get Single Profile

<mark style="color:blue;">`GET`</mark> `API_END_POINT/list_profiles/app_list/<sort_method>/`

#### Path Parameters

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| profile\_id | string |             |

#### Headers

| Name   | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| mw-jwt | string | MW\_JWT string(obtained when sign in) |

{% tabs %}
{% tab title="200 " %}

```
{
  "profiles": {
    "complete_time": [
      "2019-04-28",
      "04:15:40"
    ],
    "photos": {
      "front_photo": "image path",
      "front_photo_medium": "image path",
      "front_photo_small": "image path",
      "side_photo": "image path",
      "side_photo_medium": "image path",
      "side_photo_small": "image path"
    },
    "process_status": true,
    "profile_id": "profile_2019-04-28_T_03-39-54",
    "profile_name": "test",
    "profile_process_status": "MW_COMPLETE"
  },
  "status": 200,
  “code”: 1000
}

```

{% endtab %}
{% endtabs %}

<mark style="color:blue;">`GET`</mark> `API_END_POINT/get_app_config`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```
{
  "msg": {
    "app_notification_msg": "under maintenance due to amazon aws cn-north-1 server down",
    "app_notification_status": "True",
    "camera_pitch_constrain": 3.0,
    "camera_rotation_constrain": {
      "pitch": 3.0,
      "yaw": 3.0
    },
    "camera_yaw_constrain": 3.0,
    "js_viewer_url": {
      "cn": "ec2-52-81-30-241.cn-north-1.compute.amazonaws.com.cn:3132",
      "us": "ec2-54-144-93-102.compute-1.amazonaws.com:3132"
    },
    "measurement_translation": {
      "translation": {
        "en": {
          "measurement": {
            "ankle": "Ankle",
            "arm2": "Arm Length",
            "arm_absolute": "MW Arm Abs",
            "arm_length": "Sleeve Length",
            "back_jacket_length": "Back Jacket",
            "back_length": "Back Length",
            "back_shoulder": "Back Shoulder",
            "bicep": "Bicep",
            "calf": "Calf",
            "chest": "Chest",
            "front_shoulder": "Front Shoulder",
            "front_shoulder_to_stomach": "Front Shoulder to Stomach",
            "height": "Height",
            "highest_point_of_stomach": "Highest Point of Stomach",
            "hip": "Hip",
            "knee": "Knee",
            "nape_to_stomach": "Nape to Stomach",
            "neck": "Neck",
            "pants_inseam": "Inseam",
            "pants_outseam": "Outseam",
            "pants_u-rise": "U-Rise",
            "shoulder_absolute": "MW Shoulder Abs",
            "stomach": "Stomach",
            "stomach_to_back_waist": "Stomach to Back Waist",
            "stomach_to_front_waist": "Stomach to Front Waist",
            "thigh": "Thigh",
            "waist": "Natural Waist",
            "wrist": "Wrist"
          }
        },
        "zh": {
          "measurement": {
            "ankle": "脚踝围",
            "arm2": "臂长",
            "arm_absolute": "MW绝对臂长",
            "arm_length": "袖长",
            "back_jacket_length": "后衣长",
            "back_length": "后衣长",
            "back_shoulder": "后肩宽",
            "bicep": "上臂围",
            "calf": "小腿围",
            "chest": "胸围",
            "front_shoulder": "前肩宽",
            "front_shoulder_to_stomach": "前腰节长",
            "height": "身高",
            "highest_point_of_stomach": "中腰围",
            "hip": "臀围",
            "knee": "膝盖围",
            "nape_to_stomach": "后腰节长",
            "neck": "颈围",
            "pants_inseam": "裤子内缝长",
            "pants_outseam": "外裤长",
            "pants_u-rise": "通裆",
            "shoulder_absolute": "MW绝对肩宽",
            "stomach": "腹围",
            "stomach_to_back_waist": "后腰高",
            "stomach_to_front_waist": "前腰高",
            "thigh": "大腿跟围",
            "waist": "腰围",
            "wrist": "手腕围"
          }
        }
      }
    },
    "overlap_config": {
      "front": {
        "H_OFFSET": 0,
        "X_MARGIN": 0.05,
        "Y_OFFSET": 0.1
      },
      "side": {
        "H_OFFSET": 0,
        "Y_OFFSET": 0.1
      }
    }
  },
  "status": 200,
  “code”: 1000
}

```

{% endtab %}
{% endtabs %}
