### Possible endpoints Run the API thru the systemd service, or like: ```BASH ffpapi -l 127.0.0.1:8000 ``` For all endpoints an (Bearer) authentication is required.\ `{id}` represent the channel id, and at default is 1. #### User Handling **Login** ```BASH curl -X POST http://127.0.0.1:8000/auth/login/ -H "Content-Type: application/json" \ -d '{ "username": "", "password": "" }' ``` **Response:** ```JSON { "id": 1, "mail": "user@example.org", "username": "", "token": "" } ``` From here on all request **must** contain the authorization header:\ `"Authorization: Bearer "` **Get current User** ```BASH curl -X GET 'http://localhost:8000/api/user' -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' ``` **Update current User** ```BASH curl -X PUT http://localhost:8000/api/user/1 -H 'Content-Type: application/json' \ -d '{"mail": "", "password": ""}' -H 'Authorization: ' ``` **Add User** ```BASH curl -X POST 'http://localhost:8000/api/user/' -H 'Content-Type: application/json' \ -d '{"mail": "", "username": "", "password": "", "role_id": 1, "channel_id": 1}' \ -H 'Authorization: Bearer ' ``` #### ffpapi Settings **Get Settings from Channel** ```BASH curl -X GET http://127.0.0.1:8000/api/channel/1 -H "Authorization: Bearer " ``` **Response:** ```JSON { "id": 1, "name": "Channel 1", "preview_url": "http://localhost/live/preview.m3u8", "config_path": "/etc/ffplayout/ffplayout.yml", "extra_extensions": "jpg,jpeg,png", "timezone": "UTC", "service": "ffplayout.service" } ``` **Get settings from all Channels** ```BASH curl -X GET http://127.0.0.1:8000/api/channels -H "Authorization: Bearer " ``` **Update Channel** ```BASH curl -X PATCH http://127.0.0.1:8000/api/channel/1 -H "Content-Type: application/json" \ -d '{ "id": 1, "name": "Channel 1", "preview_url": "http://localhost/live/stream.m3u8", \ "config_path": "/etc/ffplayout/ffplayout.yml", "extra_extensions": "jpg,jpeg,png", "timezone": "Europe/Berlin"}' \ -H "Authorization: Bearer " ``` **Create new Channel** ```BASH curl -X POST http://127.0.0.1:8000/api/channel/ -H "Content-Type: application/json" \ -d '{ "name": "Channel 2", "preview_url": "http://localhost/live/channel2.m3u8", \ "config_path": "/etc/ffplayout/channel2.yml", "extra_extensions": "jpg,jpeg,png", "timezone": "Europe/Berlin", "service": "ffplayout@channel2.service" }' \ -H "Authorization: Bearer " ``` **Delete Channel** ```BASH curl -X DELETE http://127.0.0.1:8000/api/channel/2 -H "Authorization: Bearer " ``` #### ffplayout Config **Get Config** ```BASH curl -X GET http://localhost:8000/api/playout/config/1 -H 'Authorization: ' ``` Response is a JSON object from the ffplayout.yml **Update Config** ```BASH curl -X PUT http://localhost:8000/api/playout/config/1 -H "Content-Type: application/json" \ -d { } -H 'Authorization: ' ``` #### Text Presets Text presets are made for sending text messages to the ffplayout engine, to overlay them as a lower third. **Get all Presets** ```BASH curl -X GET http://localhost:8000/api/presets/ -H 'Content-Type: application/json' \ -H 'Authorization: ' ``` **Update Preset** ```BASH curl -X PUT http://localhost:8000/api/presets/1 -H 'Content-Type: application/json' \ -d '{ "name": "", "text": "", "x": "", "y": "", "fontsize": 24, \ "line_spacing": 4, "fontcolor": "#ffffff", "box": 1, "boxcolor": "#000000", "boxborderw": 4, "alpha": 1.0, "channel_id": 1 }' \ -H 'Authorization: ' ``` **Add new Preset** ```BASH curl -X POST http://localhost:8000/api/presets/ -H 'Content-Type: application/json' \ -d '{ "name": "", "text": "TEXT>", "x": "", "y": "", "fontsize": 24, \ "line_spacing": 4, "fontcolor": "#ffffff", "box": 1, "boxcolor": "#000000", "boxborderw": 4, "alpha": 1.0, "channel_id": 1 }' \ -H 'Authorization: ' ``` **Delete Preset** ```BASH curl -X DELETE http://localhost:8000/api/presets/1 -H 'Content-Type: application/json' \ -H 'Authorization: ' ``` ### 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** ```BASH curl -X POST http://localhost:8000/api/control/1/text/ \ -H 'Content-Type: application/json' -H 'Authorization: ' \ -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"}' ``` **Control Playout** - next - back - reset ```BASH curl -X POST http://localhost:8000/api/control/1/playout/next/ -H 'Content-Type: application/json' -d '{ "command": "reset" }' -H 'Authorization: ' ``` **Get current Clip** ```BASH curl -X GET http://localhost:8000/api/control/1/media/current -H 'Content-Type: application/json' -H 'Authorization: ' ``` **Response:** ```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 } ``` **Get next Clip** ```BASH curl -X GET http://localhost:8000/api/control/1/media/next/ -H 'Authorization: ' ``` **Get last Clip** ```BASH curl -X GET http://localhost:8000/api/control/1/media/last/ -H 'Content-Type: application/json' -H 'Authorization: ' ``` #### ffplayout Process Control Control ffplayout process, like: - start - stop - restart - status ```BASH curl -X POST http://localhost:8000/api/control/1/process/ -H 'Content-Type: application/json' -H 'Authorization: ' -d '{"command": "start"}' ``` #### ffplayout Playlist Operations **Get playlist** ```BASH curl -X GET http://localhost:8000/api/playlist/1?date=2022-06-20 -H 'Content-Type: application/json' -H 'Authorization: ' ``` **Save playlist** ```BASH curl -X POST http://localhost:8000/api/playlist/1/ -H 'Content-Type: application/json' -H 'Authorization: ' -- data "{}" ``` **Generate Playlist** A new playlist will be generated and response. ```BASH curl -X GET http://localhost:8000/api/playlist/1/generate/2022-06-20 -H 'Content-Type: application/json' -H 'Authorization: ' ``` **Delete Playlist** ```BASH curl -X DELETE http://localhost:8000/api/playlist/1/2022-06-20 -H 'Content-Type: application/json' -H 'Authorization: ' ``` ### Log file **Read Log Life** ```BASH curl -X Get http://localhost:8000/api/log/1 -H 'Content-Type: application/json' -H 'Authorization: ' ``` ### File Operations **Get File/Folder List** ```BASH curl -X POST http://localhost:8000/api/file/1/browse/ -H 'Content-Type: application/json' -d '{ "source": "/" }' -H 'Authorization: ' ``` **Create Folder** ```BASH curl -X POST http://localhost:8000/api/file/1/create-folder/ -H 'Content-Type: application/json' -d '{"source": ""}' -H 'Authorization: ' ``` **Rename File** ```BASH curl -X POST http://localhost:8000/api/file/1/rename/ -H 'Content-Type: application/json' -d '{"source": "", "target": ""}' -H 'Authorization: ' ``` **Remove File/Folder** ```BASH curl -X POST http://localhost:8000/api/file/1/remove/ -H 'Content-Type: application/json' -d '{"source": ""}' -H 'Authorization: ' ``` **Upload File** ```BASH curl -X POST http://localhost:8000/api/file/1/upload/ -H 'Authorization: ' -F "file=@file.mp4" ```