---
# System prepended metadata

title: DataAI API 格式 (2023/06/02)

---

# DataAI API 格式 (2023/06/02)

## Object Management API


#### **[POST]** /v2/data-ai/model/start  **:fire:1.4 version update** <br> <sub>Create a sensor from RTM in a device (automatically start train and inference scheduling) [[ref]](https://advantecho365.sharepoint.com/:x:/r/sites/DataAI2/_layouts/15/Doc.aspx?sourcedoc=%7B603AF11B-38A0-417A-8409-9B9B529D3FD2%7D&file=20230616_PHM%20Model%20Setting%20Spec_v1.0.xlsx&action=default&mobileredirect=true) [[ref2]](https://www.figma.com/file/WodxCyTr67s3LVRes5n5pi/DataAI-Flow?type=whiteboard&node-id=0-1&t=msLWSs9e2jp8EbXb-0) </sub>

<details><summary><sup>Request</sup></summary>
    
```jsonld
{
    "project_id": int,
    "model": {
        "device_id": string,
        "device_name": string,  #new?
        "sensor_ids": string[], #machine_id in RTM
        "model_id": string,
        "model_name": string,
        "type": string,  #machine foundation
        "category": string,  #machine type 
        "signal": string,
        "model": string,  #sensor type
        "model_setting": {   # null or {} if the model is WISE-2410
            "description": string,
            "sampling_rate": int,
            "samples": int,
            "frequency": float,
            "interval": float,
            "sensitivity": float,
            "energy": float,
            "windows": [{
                            "start": float,
                            "end": float,
                            "peak_a": float,
                            "rms": float,
                        }, {...}, ...]
        }
    }
}                                   
```
    
```yaml
foundation:
- "rigid"
- "flexible"
    
type:
- 0  # 馬力大於15kW泵浦(Pump>15kW)
- 1  # 馬力15kW至300kW電機設備(medium size machine 15kW<P<300kW)
- 2  # 馬力300kW至50MW電機設備(large machine 300kW<P<50MW)
- 3  # 整合驅動馬達(Integrated driver)
- 4  # 外接驅動馬達(External driver)
- 5  # 軸高160mm至315mm馬達(motors 160mm<H<315mm)
- 6  # 軸高高於315mm馬達(motors 315mm<H)

signal:
- "vibration"  # 振動
- "current"    # 電流
                                   
model:
- "WISE-2410"
- "PCIE-1803"

```
</details>

<details><summary><sup>Response</sup></summary>
    
```jsonld
#success ->
{
    "errCode": 200,
    "data": "success"
}
    
#Error ->    
{  
    "errCode": 400,
    "data": str #Error message
}
```
</details>
    
#### ~~**[PUT]** /v2/data-ai/model/{model_id} <br> <sub>Modify model</sub>~~
    
~~<sup>Same as **/v2/data-ai/model/start**</sup>~~
~~<SUP>*Note: {model_id} should exist beforehand. model_id parameter inside the request JSON can be used to rename the model_id*</SUP>~~
    
#### **[POST]** /v2/data-ai/model/list <br> <sub>Get the list of model</sub>

<details><summary><sup>Request</sup></summary>
    
```jsonld
}
    "model_ids": str[]
}                                
```
</details>
    
<details><summary><sup>Response</sup></summary>
    
```jsonld
{
    "errCode": 200,
    "data": {
        "models": [
            {"model_id": str, "model_name": str, "task": str, "status": str},
            ...
        ]
    }
}   
```
</details>

#### **[POST]** /v2/data-ai/model/status  **:fire:1.4 version update** <br> <sub>Get the status of model</sub>

<details><summary><sup>Request</sup></summary>
    
```jsonld
{
    "model_ids": str[]
}
```
</details>

<details><summary><sup>Response</sup></summary>
    
```jsonld
{
    "errCode": 200,
    "data": {
        "model_status": [
            { "model_id": str,
              "training": {"status": str, "last_finish_time": str, "result": str},
              "inference": {"status": str, "last_finish_time": str, "result": str} 
              "machine": {  //device
                          "type": str,  //foundation
                          "category": str  //type
                         }, 
                            
              "data_collection": {  //sensor
                                  "signal": str, 
                                  "model": str
                                 }, 
              "setting": { //model_setting
                          "description": str, //device_description
                          "sampling_rate": int,
                          "samples": int,
                          "frequency": int, //checking_frequency
                          "interval": int, //storage_interval
                          "sensitivity": int,
                          "energy": int,
                          "windows": [{
                                          "start": int,
                                          "end": int,
                                          "peak_a": int,
                                          "rms": int,
                                      }, ...]
                         } | {}  # if not PCIE-1803
            
        ]
    }
}
```
</details>

#### **[DELETE]** /v2/data-ai/model/*{model_id}* <br> <sub>Delete the sensor in a device</sub>

<details><summary><sup>Response</sup></summary>
    
```jsonld
{  #success
  "errCode": 200,
  "data": "success"
}
{  #Error
  "errCode": 400,
  "data": str #Error message
}
```
</details>
    
## Setting List

#### 🔥 **[GET]** /v2/data-ai/setting/spectrum  **:fire:08/23 updated** <br> <sub>Setting</sub>

<details><summary><sup>Response</sup></summary>
    
```jsonld
{
  "errCode": 200,
  "data": {
        "storage_criteria": str[], #soon deprecated
        "device_description": str[]
    }
}
```
</details>
    
#### 🔥 **[GET]** /v2/data-ai/setting/device <br> <sub>Setting</sub>

<details><summary><sup>Response</sup></summary>
    
```jsonld
{
  "errCode": 200,
  "data": {
        "foundation": str[],
        "type": str[]
    }
}
```
</details>
    
#### 🔥 **[GET]** /v2/data-ai/setting/sensor <br> <sub>Setting</sub>

<details><summary><sup>Response</sup></summary>
    
```jsonld
{
  "errCode": 200,
  "data": {
        "signal": str[],
        "model": str[]
    }
}
```
</details>