With this article, you can send some basic API commands using Postman. We start by creating the authorization token. After that, you can send the commands. Such as toggling LIVE on/off, selecting a scenario, preset, or camera you want to choose.
Base url: http://{ip}/api
Action | HTTP Method | Endpoint |
Authentication | POST | /manager/auth |
Turning into live mode | POST | /on |
Turning into edit mode | POST | /off |
Switch to scenario | POST | /switch/scenario/{id} |
Switch to preset | POST | /switch/preset/{id} |
Switch to camera output | POST | /switch/camera/{id} |
Ask active camera | GET | /active-camera |
API Authentication
All the endpoints of the CamDirector are protected by JWT authentication. This means that you need to supply an authentication token to each HTTP request.
The following steps will explain how to authenticate with the API and supply the JWT token to you next request. This tutorial makes use of Postman v11.29.3 for sending HTTP requests. Postman has an interactive UI for sending requests and simplifies the authentication process.
Login with credentials
To retrieve a JWT token you need to make a request to the authentication endpoint. The Authorization type is a Bearer Token. This is a HTTP POST request and requires a JSON body with the username and password fields (don't forget the comma after "admin") of the CamDirector.
Using your JWT token
After pressing the send button, you will receive a token. And the "200 OK". And everyone who was logged in via the WebGUI will be logged out.
The new token appears in the body window under. Open tab Authentication. You can open the token window. The token should be supplied in the request header as a Bearer Token. It needs to be copied into the token window.
The lifetime of the token is supplied in seconds and is 3600, which means the token is valid for one hour.
Only one user can be authenticated at the same time, so when another client logs in, other tokens become invalid and you receive "401 Unauthorized". And you have to generate a new one.
In practice
If you want to turn off "LIVE," you can do so with:
POST http://172.26.41.20/api/off.
After pressing "SEND," you will receive the response.
If someone opens the WebGUI, the token will be invalid and you received "401 Unauthorized"
Find the ID numbersYou can find the ID numbers by turning off LIVE mode. The ID numbers will appear in the Scenarios, Presets, and Cameras under Switcher.
You can find the ID numbers by turning off LIVE mode. The ID numbers will appear in the Scenarios, Presets, and Cameras under Switcher.