ffplayout/docs/api.md

337 lines
8.1 KiB
Markdown
Raw Normal View History

### Possible endpoints
2022-06-23 16:39:13 -04:00
Run the API thru the systemd service, or like:
```BASH
2022-07-25 11:26:49 -04:00
ffpapi -l 127.0.0.1:8787
2022-06-23 16:39:13 -04:00
```
For all endpoints an (Bearer) authentication is required.\
`{id}` represent the channel id, and at default is 1.
#### User Handling
**Login**
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/auth/login/ -H "Content-Type: application/json" \
-d '{ "username": "<USER>", "password": "<PASS>" }'
```
**Response:**
2022-06-23 16:39:13 -04:00
```JSON
{
"id": 1,
"mail": "user@example.org",
"username": "<USER>",
"token": "<TOKEN>"
2022-06-23 16:39:13 -04:00
}
```
From here on all request **must** contain the authorization header:\
`"Authorization: Bearer <TOKEN>"`
**Get current User**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X GET 'http://127.0.0.1:8787/api/user' -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <TOKEN>'
```
**Update current User**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X PUT http://127.0.0.1:8787/api/user/1 -H 'Content-Type: application/json' \
2022-11-08 09:42:17 -05:00
-d '{"mail": "<MAIL>", "password": "<PASS>"}' -H 'Authorization: Bearer <TOKEN>'
2022-06-23 16:39:13 -04:00
```
**Add User**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST 'http://127.0.0.1:8787/api/user/' -H 'Content-Type: application/json' \
-d '{"mail": "<MAIL>", "username": "<USER>", "password": "<PASS>", "role_id": 1, "channel_id": 1}' \
-H 'Authorization: Bearer <TOKEN>'
```
#### ffpapi Settings
2022-07-18 16:55:18 -04:00
**Get Settings from Channel**
```BASH
2022-07-25 11:26:49 -04:00
curl -X GET http://127.0.0.1:8787/api/channel/1 -H "Authorization: Bearer <TOKEN>"
```
**Response:**
2022-06-23 16:39:13 -04:00
```JSON
{
2022-06-23 16:39:13 -04:00
"id": 1,
"name": "Channel 1",
"preview_url": "http://localhost/live/preview.m3u8",
2022-06-23 16:39:13 -04:00
"config_path": "/etc/ffplayout/ffplayout.yml",
"extra_extensions": "jpg,jpeg,png",
2022-09-04 11:07:16 -04:00
"service": "ffplayout.service",
"utc_offset": "+120"
}
```
2022-07-18 16:55:18 -04:00
**Get settings from all Channels**
```BASH
2022-07-25 11:26:49 -04:00
curl -X GET http://127.0.0.1:8787/api/channels -H "Authorization: Bearer <TOKEN>"
```
2022-07-18 16:55:18 -04:00
**Update Channel**
```BASH
2022-07-25 11:26:49 -04:00
curl -X PATCH http://127.0.0.1:8787/api/channel/1 -H "Content-Type: application/json" \
-d '{ "id": 1, "name": "Channel 1", "preview_url": "http://localhost/live/stream.m3u8", \
2022-09-04 11:07:16 -04:00
"config_path": "/etc/ffplayout/ffplayout.yml", "extra_extensions": "jpg,jpeg,png"}' \
-H "Authorization: Bearer <TOKEN>"
```
2022-07-18 16:55:18 -04:00
**Create new Channel**
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/api/channel/ -H "Content-Type: application/json" \
-d '{ "name": "Channel 2", "preview_url": "http://localhost/live/channel2.m3u8", \
2022-07-18 16:55:18 -04:00
"config_path": "/etc/ffplayout/channel2.yml", "extra_extensions": "jpg,jpeg,png",
2022-09-04 11:07:16 -04:00
"service": "ffplayout@channel2.service" }' \
2022-07-18 16:55:18 -04:00
-H "Authorization: Bearer <TOKEN>"
```
**Delete Channel**
```BASH
2022-07-25 11:26:49 -04:00
curl -X DELETE http://127.0.0.1:8787/api/channel/2 -H "Authorization: Bearer <TOKEN>"
2022-07-18 16:55:18 -04:00
```
#### ffplayout Config
**Get Config**
```BASH
2022-11-08 09:42:17 -05:00
curl -X GET http://127.0.0.1:8787/api/playout/config/1 -H 'Authorization: Bearer <TOKEN>'
2022-06-23 16:39:13 -04:00
```
Response is a JSON object from the ffplayout.yml
2022-06-23 16:39:13 -04:00
**Update Config**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X PUT http://127.0.0.1:8787/api/playout/config/1 -H "Content-Type: application/json" \
2022-11-08 09:42:17 -05:00
-d { <CONFIG DATA> } -H 'Authorization: Bearer <TOKEN>'
```
2022-06-23 16:39:13 -04:00
#### Text Presets
Text presets are made for sending text messages to the ffplayout engine, to overlay them as a lower third.
2022-06-23 16:39:13 -04:00
**Get all Presets**
```BASH
2022-07-25 11:26:49 -04:00
curl -X GET http://127.0.0.1:8787/api/presets/ -H 'Content-Type: application/json' \
2022-11-08 09:42:17 -05:00
-H 'Authorization: Bearer <TOKEN>'
```
**Update Preset**
```BASH
2022-07-25 11:26:49 -04:00
curl -X PUT http://127.0.0.1:8787/api/presets/1 -H 'Content-Type: application/json' \
2022-07-06 11:12:15 -04:00
-d '{ "name": "<PRESET NAME>", "text": "<TEXT>", "x": "<X>", "y": "<Y>", "fontsize": 24, \
"line_spacing": 4, "fontcolor": "#ffffff", "box": 1, "boxcolor": "#000000", "boxborderw": 4, "alpha": 1.0, "channel_id": 1 }' \
2022-11-08 09:42:17 -05:00
-H 'Authorization: Bearer <TOKEN>'
```
2022-07-06 11:12:15 -04:00
**Add new Preset**
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/api/presets/ -H 'Content-Type: application/json' \
2022-07-06 11:12:15 -04:00
-d '{ "name": "<PRESET NAME>", "text": "TEXT>", "x": "<X>", "y": "<Y>", "fontsize": 24, \
"line_spacing": 4, "fontcolor": "#ffffff", "box": 1, "boxcolor": "#000000", "boxborderw": 4, "alpha": 1.0, "channel_id": 1 }' \
2022-11-08 09:42:17 -05:00
-H 'Authorization: Bearer <TOKEN>'
2022-07-06 11:12:15 -04:00
```
**Delete Preset**
```BASH
2022-07-25 11:26:49 -04:00
curl -X DELETE http://127.0.0.1:8787/api/presets/1 -H 'Content-Type: application/json' \
2022-11-08 09:42:17 -05:00
-H 'Authorization: Bearer <TOKEN>'
```
### ffplayout controlling
here we communicate with the engine for:
- jump to last or next clip
- reset playlist state
- get infos about current, next, last clip
- send text to the engine, for overlaying it (as lower third etc.)
**Send Text to ffplayout**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/api/control/1/text/ \
2022-11-08 09:42:17 -05:00
-H 'Content-Type: application/json' -H 'Authorization: Bearer <TOKEN>' \
-d '{"text": "Hello from ffplayout", "x": "(w-text_w)/2", "y": "(h-text_h)/2", \
"fontsize": "24", "line_spacing": "4", "fontcolor": "#ffffff", "box": "1", \
"boxcolor": "#000000", "boxborderw": "4", "alpha": "1.0"}'
```
2022-07-06 11:12:15 -04:00
**Control Playout**
2022-06-23 16:39:13 -04:00
2022-07-06 11:12:15 -04:00
- next
- back
- reset
```BASH
curl -X POST http://127.0.0.1:8787/api/control/1/playout/ -H 'Content-Type: application/json'
2022-11-08 09:42:17 -05:00
-d '{ "command": "reset" }' -H 'Authorization: Bearer <TOKEN>'
```
**Get current Clip**
```BASH
2022-07-25 11:26:49 -04:00
curl -X GET http://127.0.0.1:8787/api/control/1/media/current
2022-11-08 09:42:17 -05:00
-H 'Content-Type: application/json' -H 'Authorization: Bearer <TOKEN>'
```
**Response:**
2022-06-23 16:39:13 -04:00
```JSON
{
"jsonrpc": "2.0",
"result": {
"current_media": {
"category": "",
"duration": 154.2,
"out": 154.2,
"seek": 0.0,
"source": "/opt/tv-media/clip.mp4"
},
"index": 39,
"play_mode": "playlist",
"played_sec": 67.80771999300123,
"remaining_sec": 86.39228000699876,
"start_sec": 24713.631999999998,
"start_time": "06:51:53.631"
},
"id": 1
2022-06-23 16:39:13 -04:00
}
```
**Get next Clip**
```BASH
2022-11-08 09:42:17 -05:00
curl -X GET http://127.0.0.1:8787/api/control/1/media/next/ -H 'Authorization: Bearer <TOKEN>'
```
**Get last Clip**
```BASH
2022-07-25 11:26:49 -04:00
curl -X GET http://127.0.0.1:8787/api/control/1/media/last/
2022-11-08 09:42:17 -05:00
-H 'Content-Type: application/json' -H 'Authorization: Bearer <TOKEN>'
```
#### ffplayout Process Control
Control ffplayout process, like:
- start
- stop
- restart
- status
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/api/control/1/process/
2022-11-08 09:42:17 -05:00
-H 'Content-Type: application/json' -H 'Authorization: Bearer <TOKEN>'
-d '{"command": "start"}'
```
#### ffplayout Playlist Operations
2022-06-23 16:39:13 -04:00
**Get playlist**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X GET http://127.0.0.1:8787/api/playlist/1?date=2022-06-20
2022-11-08 09:42:17 -05:00
-H 'Content-Type: application/json' -H 'Authorization: Bearer <TOKEN>'
```
2022-06-23 16:39:13 -04:00
**Save playlist**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/api/playlist/1/
2022-11-08 09:42:17 -05:00
-H 'Content-Type: application/json' -H 'Authorization: Bearer <TOKEN>'
-- data "{<JSON playlist data>}"
```
2022-06-23 16:39:13 -04:00
**Generate Playlist**
2022-06-23 16:39:13 -04:00
A new playlist will be generated and response.
2022-06-24 11:41:55 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X GET http://127.0.0.1:8787/api/playlist/1/generate/2022-06-20
2022-11-08 09:42:17 -05:00
-H 'Content-Type: application/json' -H 'Authorization: Bearer <TOKEN>'
```
2022-06-23 16:39:13 -04:00
**Delete Playlist**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X DELETE http://127.0.0.1:8787/api/playlist/1/2022-06-20
2022-11-08 09:42:17 -05:00
-H 'Content-Type: application/json' -H 'Authorization: Bearer <TOKEN>'
```
2022-06-23 16:39:13 -04:00
### Log file
2022-06-23 16:39:13 -04:00
**Read Log Life**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X Get http://127.0.0.1:8787/api/log/1
2022-11-08 09:42:17 -05:00
-H 'Content-Type: application/json' -H 'Authorization: Bearer <TOKEN>'
```
2022-06-23 16:39:13 -04:00
### File Operations
2022-06-23 16:39:13 -04:00
**Get File/Folder List**
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/api/file/1/browse/ -H 'Content-Type: application/json'
2022-11-08 09:42:17 -05:00
-d '{ "source": "/" }' -H 'Authorization: Bearer <TOKEN>'
```
**Create Folder**
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/api/file/1/create-folder/ -H 'Content-Type: application/json'
2022-11-08 09:42:17 -05:00
-d '{"source": "<FOLDER PATH>"}' -H 'Authorization: Bearer <TOKEN>'
```
**Rename File**
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/api/file/1/rename/ -H 'Content-Type: application/json'
2022-11-08 09:42:17 -05:00
-d '{"source": "<SOURCE>", "target": "<TARGET>"}' -H 'Authorization: Bearer <TOKEN>'
```
2022-06-23 16:39:13 -04:00
**Remove File/Folder**
2022-06-23 16:39:13 -04:00
```BASH
2022-07-25 11:26:49 -04:00
curl -X POST http://127.0.0.1:8787/api/file/1/remove/ -H 'Content-Type: application/json'
2022-11-08 09:42:17 -05:00
-d '{"source": "<SOURCE>"}' -H 'Authorization: Bearer <TOKEN>'
```
**Upload File**
```BASH
2022-11-08 09:42:17 -05:00
curl -X POST http://127.0.0.1:8787/api/file/1/upload/ -H 'Authorization: Bearer <TOKEN>'
-F "file=@file.mp4"
```
2022-10-02 16:05:01 -04:00
**Import playlist**
Import text/m3u file and convert it to a playlist
lines with leading "#" will be ignore
```BASH
2022-11-08 09:42:17 -05:00
curl -X POST http://127.0.0.1:8787/api/file/1/import/ -H 'Authorization: Bearer <TOKEN>'
2022-10-02 16:05:01 -04:00
-F "file=@list.m3u"
```