# iHeal Cube API Design Documentation
[](https://hackmd.io/inJSC8yrTlKzEWoxPW9bzw)
## Installed Software
### Tech Stack
- Python 3.9
- fast api
### Apt
- vim-nox
- tmux
- alsa-tools
- libasound2-dev
### Others
- Julius: $HOME/scott/julius
## API SPEC
### Route: `api/v1/<Category>/<Mode>/<1,2,3>`
- method: GET
### parameters
- mode: user's username or e-mail address
- email: user's e-mail address (optional)
- password: user's password
| ID | Category | Title | Note |
| -------- | -------- | -------- | -------- |
| 01-01 | LED | LEDパターン表示 | 瞑想、だんらん、睡眠 パターンをCloudからダウンロードして表示する |
| 01-02 | LED | LEDパターンSPEC | 01-01用のパターンファイルのSPEC |
| 02-01 | IR | 赤外線学習 | 自由に1-100までのSlotに赤外線信号を学習・更新・削除し、CloudにUploadする |
| 02-02 | IR | 赤外線再生 | 1-100までのSlotデータを毎回Cloudからとってきて再生 |
| 02-03 | IR | 赤外線学習ボタンのプリセットGUI | Plain、TV用、エアコン用3種類。MobileApp側で対応|
| 03-01 | CAMERA | APIで録画を開始、終了。終了したらCloudにUploadする。Live Streamingは不要 |
| 04-01 | MUSIC | 音楽を指定して、mp3かwavをCloudからとってきて再生 |
| 05-01 | VOICE | LED, IR, CAMERA, MUSIC... などできるだけ全てのAPIを音声で操作する |
| 06-01 | AROMA|噴射、噴射停止|
* 01-02 example
```txt
# ms LED1, LED2, ..., LED24
# if it supports more than on/off, add linear/ease-in/ease-out/ease-in-out.
# please copy good design from somewhere and define a better one
0 0xFFFF00,10% 0XFF0000,10% ....
```
## Camera
### API SpecsCapture Still API
`/api/v1/camera/<mode>`
* mode
* still: take a still photo
* record: start recording a video
* stop: stop recording video
* data
```json
{
"filename": "hoge.jpg" // string. if empty, it defaults to YYYYMMDD_HHMMSS.jpg or .mp4
}
```
| HTTP verb | URI Example | Data | HTTP Status Code | Note |
| -------- | -------- | -------- | -------- | -------- |
| POST | /api/v1/camera/still | { "filename": "foo.jpg" } | 201 if successful, 500 if failed | take a still photo and upload to cloud |
| POST | /api/v1/camera/start | { "filename": "bar.mp4" } | 200 if successful, 500 if failed | start recording a video |
| POST | /api/v1/camera/stop | {} | 201 if successful, 500 if failed | stop recording and upload to cloud. returns if video is not started. |
### Snippet Examples
- python3 ./Examples/camera/capture_still.py
## Music
### API
`/api/v1/camera/capture_still`
## LED
### API Specs
`/api/v1/led/pattern/<0,1,2,3>`
## 赤外線 Remote Control
### API Specs
- `api/v1/ir/<Group>/<0,1,2,3>`
## Music
### API Specs
- `api/v1/music/<verb>`
- verb: start, pause, stop
```json
{
"filename": "music.mp3" // string. if empty, it defaults to music.mp3
}
```
| HTTP verb | URI Example | Data | HTTP Status Code | Note |
| -------- | -------- | -------- | -------- | -------- |
| POST | /api/v1/music/pause | | 201 if successful, 500 if failed | take a still photo and upload to cloud |
| POST | /api/v1/music/start | { "filename": "music.mp3" } | 200 if successful, 500 if failed | start recording a video |
| POST | /api/v1/music/stop | | 201 if successful, 500 if failed | stop recording and upload to cloud. returns if video is not started. |
## Volume Control
### API Specs
- `api/v1/volume/<verb>/<value>`
- verb: up, down, mute, set
## Aroma Control
### API Specs
- `api/v1/aroma/<verb>/<value>`
- verb: start, stop, status
- value: int