---
# System prepended metadata

title: PRJ User Dashboard API Manual
tags: [Dashboard]

---

# PRJ User Dashboard API Manual

###### tags: `Dashboard`

- **purpose:** used to get the most updated recommendation content of assigned uuid
-  **api endpoint:** 
**`https://ucrepg6n17.execute-api.ap-northeast-1.amazonaws.com/PRJ_Recommendation_Handler`**
- **api key** `eh8fCiMmHvohrhPw4PdRfG90ggj1iw9QbzUY89s4w5E`
- **request method:** **`POST`**
- **most updated model version:** **`2021-04-12`**
- **contents need to be assigned in headers:**
    1. Content-Type: `application/json`
    2. UUID: uuid of user
    3. Version: current model version, only when current model version less than the most updated model version will this API return new recommendation content
    4. Signature: encrypt uuid using api_key mentioned above
- **sample code (Python 3)**
```
# set header format by bringing uuid of user, current model version of device and signature
api_key = `eh8fCiMmHvohrhPw4PdRfG90ggj1iw9QbzUY89s4w5E`
# $uuid: uuid of user
# $model_version: version of recommendation model of device with format = yyyy-mm-dd
# signature: created by api_key & uuid, used for authentication 
#how to create signature using api_key & uuid
import hashlib, hmac, base64
message = bytes($uuid, 'utf-8')
secret = bytes(api_key, 'utf-8')
signature = base64.b64encode(hmac.new(secret, message, digestmod = hashlib.sha256).digest()).decode()

# request with POST method
import requests
headers = {'Content-Type': 'application/json', 
           'UUID': $uuid, 
           'Version': $model_version,
           'Signature': signature}
endpoint = 'https://ucrepg6n17.execute-api.ap-northeast-1.amazonaws.com/PRJ_Recommendation_Handler'
rs = requests.post(endpoint, headers = headers)

response = rs.json()
```

- **response content**
```
{
"result_code": (Required, type: int, status of result) 
"error_message": (Optional, type: str, only exists while result_code != 2001, error message)
"content": (Optional, type: dict/json, only exists while result_code == 2001, content of recommendation)
"latest_version": (Optional, type: str, only exists while result_code == 2001, the latest model version)
"uuid": Optional, type: str, only exists while result_code == 2001, the uuid of requesting user)
}
```
- **type of result_code**
    - `200`: model version was already up to date 
    - **`2001`**: successfully return content of the latest model version(in this status, there exists `content` & `latest_version` , and exists no `error_meesage` in response content)
    - `400`: error request header format
    - `401`: authentication failure
    - `500`: internal error
    - `503`: request timeout

- **sample of responding content**
    - 1. result_code == 2001: 
        ```
        headers = {'Content-Type': 'application/json', 
           'UUID': 'a78f3ddd16452ddc9b87f7d1b8b1cd68', 
           'Version': '2022-04-11',
           'Signature': 'B5tbkXOnQK5IVROJh3XYS5+80RK5cVME+a5LL8ffdb0='}

        # make POST request
        rs = requests.post(endpoint, headers = headers)

        response = rs.json()
        ```
        ```
        # response content
        {'result_code': 2001,
         'content': {'Label': 'Pic mode', 'Reminder': 'sRGB Mode'},
         'uuid': 'a78f3ddd16452ddc9b87f7d1b8b1cd68',
         'latest_version': '2022-04-12'}
        ```
     - 2. result_code == 200: 
        ```
        headers = {'Content-Type': 'application/json', 
           'UUID': 'a78f3ddd16452ddc9b87f7d1b8b1cd68', 
           'Version': '2022-04-12',
           'Signature': 'B5tbkXOnQK5IVROJh3XYS5+80RK5cVME+a5LL8ffdb0='}

        # make POST request
        rs = requests.post(endpoint, headers = headers)

        response = rs.json()
        ```
        ```
        # response content
        {'result_code': 200, 'error_message': 'model already up tp date'}
        ```
        
- **valid uuids for testing**
    ```
    2179f02cc41412ac234e48a54368b2ef
    a78f3ddd16452ddc9b87f7d1b8b1cd68
    a08ae84095b1acdefd7bab675f7670
    3717a3e6e29b373fb2138e76c628b2d
    2cf03f24d81d0f840e78649c6304f3d
    c5426941ce3ccc8afe47df69ce387d2
    ```