API genеral description
General description
API (Application Programming Interface) is a set of rules, methods, and functions that enable different software applications to communicate with each other. An API defines how applications can request and receive data, as well as perform specific actions. It includes:
Operations to be performed (methods). This refers to the set of actions or tasks that an application can carry out through the API.
Requests. This is the information that an application sends to the API to initiate a specific operation. It could be in the form of parameters, arguments, or data structures.
Responses. This is the information that the API sends back to the application in response to a request. This could be the requested data, a status indicating whether the operation was successful, or error messages if something went wrong.
All requests should contain the following header: Content-Type: application/json
. This is necessary for the server (backend) to understand whether the client supports JSON-formatted responses. If this header is missing, the server might return a response in an incompatible format – errors could be returned as an HTML page.
The Mediaserver configuration file is the central control hub, governing every aspect of its operation. This includes everything from how it handles incoming requests to the setup of its security and authentication features. For a complete breakdown of all available settings and their functions, consult the Configuration and the first run section within the official documentation.
Authentication
To carry out API requests, authorization is required. Authorization is done with an API Access Token. For details on how to get the API token, see this API authorization guide.
Sharing of your token with third parties may result in the loss of your data and service instability.
Once an API Access Token is received, all subsequent requests should include this token either in the HTTP header or as a URL parameter.
A 401 Unauthorized error means your API request was denied because of an authentication issue. This typically happens for one of two reasons: either you didn't include an authentication token, or the token you provided was invalid. To fix this, verify that your token is correct and present, then retry your request with the updated information.
The example of the token use
Authorization: 3rADAV_TZTh4eD4SCvb-dYHy-SMw76X5NB2hTLfm0G6iXeTMCxhE
curl--request POST \
--url 'https:/mediaserver.vsaas.com:8776/api/' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer 3rADAV_TZTh4eD4SCvb-dYHy-SMw76X5NB2hTLfm0G6iXeTMCxhE' \
--data '{
"jsonrpc": "2.0",
"method": "Stream.Dvr.Ranges",
"params": [
"camera-uid5065687-primary"
],
"id": 1
}'