CoolCooool / Coolcool-Back

Coolcool Backend Repository
0 stars 0 forks source link

[docs] 생체데이터 API #89

Open seongs1024 opened 1 year ago

seongs1024 commented 1 year ago

생체데이터(Biometric) 도메인

엔터티 참고:
기능 협의 참고:

Base URI

https://api.coolcool.com/v1/biometrics

Date 리소스

리소스 정의:

Methods

Method Name HTTP Method Endpoint Description
getDates GET /dates 생체데이터(바이탈, 수면요약)가 존재하는 모든 날짜 컬렉션 조회

Vital 리소스

리소스 정의:

Methods

Method Name HTTP Method Endpoint Description
createVital POST /vital 매 초 BLE 장비에서 생성된 바이탈을 백엔드로 보내주는 기능
getVitals GET /vitals 특정 날짜의 바이탈 컬렉션을 조회(기존 협의안)
getVitals GET /vitals/:yyyy-mm-dd 특정 날짜의 바이탈 컬렉션을 조회(대안1)
getVitals GET /vitals/yyyy/mm/dd 특정 날짜의 바이탈 컬렉션을 조회(대안2)

SleepSummary 리소스

리소스 정의:

Methods

Method Name HTTP Method Endpoint Description
createSleepSummary POST /sleep-summary 수면요약 생성(측정 종료 시 콜)
getSleepSummary GET /sleep-summary 특정 날짜의 수면요약 조회(기존 협의안)
getSleepSummary GET /sleep-summary/:yyyy-mm-dd 특정 날짜의 수면요약 조회(대안1)
getSleepSummary GET /sleep-summary/yyyy/mm/dd 특정 날짜의 수면요약 조회(대안2)

담당자: @Kim-Eun-Bin @chanwoong1

seongs1024 commented 1 year ago

createVital

Request

http method and endpoint
POST /vital
headers
Content-Type: application/json
Authorization: <type> <credentials>
payload
{
  "measureTime": "YYYY-MM-DD HH:mm:ss",
  "spo2": <value>,
  "pulse": <value>,
  "startTime": "YYYY-MM-DD HH:mm:ss"
}

Response

headers
Content-Type: application/json
payload
{}
normal response
HTTP Status Code Status Description
200 OK 요청 성공
errors
HTTP Status Code Error Code Error Message Description
400 BAD_REQUEST Invalid request body The request body is malformed or missing required fields.
404 NOT_FOUND Resource not found The specified resource or endpoint could not be found.
500 SERVER_ERROR Internal server error An unexpected error occurred on the server.

Examples

Request
POST /vital
Host: 
Content-Type: application/json
Authorization: Basic owkdkvwe1293309qjrpotsjigfkspJPu938

{
  "measureTime": "2023-04-13 10:30:00",
  "spo2": 99,
  "pulse": 80,
  "startTime": "2023-04-13 10:30:00"
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{}
seongs1024 commented 1 year ago

getVitals

Request

http method and endpoint
GET /vitals
headers
Content-Type: application/json
Authorization: <type> <credentials>
payload
{
  "date": "YYYY-MM-DD",
  "step": "5m", // "30s", "1m", "3m", "5m", "15m", "30m", "1H"
}

Response

headers
Content-Type: application/json
payload
{
   "data": [
      {
        "label": [ "2023/04/13 10:30:00", "2023/04/13 10:35:00", "2023/04/13 10:40:00", ... ],
        "spo2": [ 94, 94, 94, ... ],
        "pulse": [ 65, 65, 65, ],
      },
      {
        "label": [ "2023/04/13 22:30:00", "2023/04/13 22:35:00", "2023/04/13 22:40:00", ... ],
        "spo2": [ 94, 94, 94, ... ],
        "pulse": [ 65, 65, 65, ],
      },
    ],
}
normal response
HTTP Status Code Status Description
200 OK 요청 성공
errors
HTTP Status Code Error Code Error Message Description
400 BAD_REQUEST Invalid request body The request body is malformed or missing required fields.
404 NOT_FOUND Resource not found The specified resource or endpoint could not be found.
500 SERVER_ERROR Internal server error An unexpected error occurred on the server.

Examples

Request
GET /vitals
Host: 
Content-Type: application/json
Authorization: Basic owkdkvwe1293309qjrpotsjigfkspJPu938

{
  "date": "2023-04-20",
  "step": "5m",
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
   "data": [
      {
        "label": [ "2023/04/13 10:30:00", "2023/04/13 10:35:00", "2023/04/13 10:40:00", ... ],
        "spo2": [ 94, 94, 94, ... ],
        "pulse": [ 65, 65, 65, ],
      },
      {
        "label": [ "2023/04/13 22:30:00", "2023/04/13 22:35:00", "2023/04/13 22:40:00", ... ],
        "spo2": [ 94, 94, 94, ... ],
        "pulse": [ 65, 65, 65, ],
      },
    ],
}
seongs1024 commented 1 year ago

getDates

Request

http method and endpoint
GET /dates
headers
Content-Type: application/json
Authorization: <type> <credentials>
payload
{}

Response

headers
Content-Type: application/json
payload
{
    "data": [dates collection in descending order]
}
normal response
HTTP Status Code Status Description
200 OK 요청 성공
errors
HTTP Status Code Error Code Error Message Description
400 BAD_REQUEST Invalid request body The request body is malformed or missing required fields.
404 NOT_FOUND Resource not found The specified resource or endpoint could not be found.
500 SERVER_ERROR Internal server error An unexpected error occurred on the server.

Examples

Request
GET /dates
Host: 
Content-Type: application/json
Authorization: Basic owkdkvwe1293309qjrpotsjigfkspJPu938

{}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "data": [ "2023-04-17", "2023-04-14", "2023-04-15", ..., "2023-04-01" ]
}