RESTful Alarms API - Python
This sample shows how to trigger and retrieve alarms from a Python application.
The sample gets an OAuth token, triggers an alarm, retrieves the alarm by id and retrieves all stored alarms with their metadata.
Prerequisites
- XProtect 2023 R2 or later.
- The API Gateway installed on the same host as the management server.
- A user with the Administrators role.
- An existing camera.
- Python version 3.7 or newer.
- The Python packages ‘requests’ and ‘requests-ntlm’. To install the
package:
- In a command prompt, enter
pip install <package-name>
. - In Visual Studio Solution Explorer, select a Python environment under Python Environments, then from the context menu select Manage Python Packages and search for <package-name>.
- In a command prompt, enter
The sample is verified with the following versions of Python packages:
- requests: 2.26.0
- requests-ntlm: 1.2.0
- urllib3: 1.26.16
Using different package versions might result in unexpected errors when running the sample.
The sample demonstrates
- How to login using OpenID Connect/OAuth2 from a Python application
- How to trigger an alarm
- How to retrieve an alarm by id
- How to retrieve all stored alarms with their metadata
- How to update an alarm state
Using
- RESTful Alarms API
Related samples
- mipsdk-samples-protocol/RestfulCommunicationPython
- mipsdk-samples-protocol/AlarmsRestApiPython
- mipsdk-samples-protocol/EventsRestApiPython
Environment
- None