An open API service indexing awesome lists of open source software.

https://github.com/rasmusrynell/ax-devil-device-api

A Python library for interacting with Axis device APIs. Provides a type-safe interface with tools for device management, configuration, and integration.
https://github.com/rasmusrynell/ax-devil-device-api

api ax-devil axis axis-communications axis-scene-description axis-scene-metadata camera cli device-apis library metadata python python3

Last synced: 12 months ago
JSON representation

A Python library for interacting with Axis device APIs. Provides a type-safe interface with tools for device management, configuration, and integration.

Awesome Lists containing this project

README

          

# ax-devil-device-api

[![Python 3.8+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Type Hints](https://img.shields.io/badge/Type%20Hints-Strict-brightgreen.svg)](https://www.python.org/dev/peps/pep-0484/)

A Python library for interacting with Axis device APIs. Provides a type-safe interface with tools for device management, configuration, and integration.

See also: [ax-devil-mqtt](https://github.com/rasmusrynell/ax-devil-mqtt) for using MQTT with an Axis device.

---

## 📋 Contents

- [Feature Overview](#-feature-overview)
- [Quick Start](#-quick-start)
- [Usage Examples](#-usage-examples)
- [Disclaimer](#-disclaimer)
- [License](#-license)

---

## 🔍 Feature Overview



Feature
Description
Python API
CLI Tool




📱 Device Information
Get device details, check health status, and restart device
client.device
ax-devil-device-api-device-info


🔧 Device Debugging
Download server reports, crash reports, and run diagnostics
client.device_debug
ax-devil-device-api-device-debug


📷 Media Operations
Capture snapshots from device cameras
client.media
ax-devil-device-api-media


🔐 SSH Management
Add, list, modify, and remove SSH users
client.ssh
ax-devil-device-api-ssh


📡 MQTT Client
Configure, activate, deactivate, and check MQTT client status
client.mqtt_client
ax-devil-device-api-mqtt-client


📊 Analytics MQTT
Manage analytics data sources and publishers for MQTT
client.analytics_mqtt
ax-devil-device-api-analytics-mqtt


🔎 API Discovery
List and inspect available APIs on the device
client.discovery
ax-devil-device-api-discovery


🌍 Geocoordinates
Get and set device location and orientation
client.geocoordinates
ax-devil-device-api-geocoordinates


🚩 Feature Flags
List, get, and set device feature flags
client.feature_flags
ax-devil-device-api-feature-flags


🌐 Network
Get network interface information
client.network
ax-devil-device-api-network

---

## 🚀 Quick Start

### Installation

```bash
pip install ax-devil-device-api
```

### Environment Variables
For an easier experience, you can set the following environment variables:
```bash
export AX_DEVIL_TARGET_ADDR=
export AX_DEVIL_TARGET_USER=
export AX_DEVIL_TARGET_PASS=
export AX_DEVIL_USAGE_CLI="safe" # Set to "unsafe" to skip SSL certificate verification for CLI calls
```

---

## 💻 Usage Examples

### Python API Usage

```python
import json
from ax_devil_device_api import Client, DeviceConfig

# Initialize client (recommended way using context manager)
config = DeviceConfig.https("192.168.1.81", "root", "pass", verify_ssl=False)
with Client(config) as client:
device_info = client.device.get_info()
print(json.dumps(device_info, indent=4))

# Alternative: Manual resource management (not recommended)
client = Client(config)
try:
device_info = client.mqtt_client.get_state()
print(json.dumps(device_info, indent=4))
finally:
client.close() # Always close the client when done
```

### CLI Usage Examples

📱 Device Information

```bash
# Get device information
ax-devil-device-api-device-info --device-ip 192.168.1.10 --username admin --password secret info

# Check device health
ax-devil-device-api-device-info --device-ip 192.168.1.10 --username admin --password secret health

# Restart device
ax-devil-device-api-device-info --device-ip 192.168.1.10 --username admin --password secret restart
```

🔧 Device Debugging

```bash
# Download server report
ax-devil-device-api-device-debug --device-ip 192.168.1.10 --username admin --password secret download_server_report report.tar.gz

# Download crash report
ax-devil-device-api-device-debug --device-ip 192.168.1.10 --username admin --password secret download_crash_report crash.tar.gz
```

📷 Media Operations

```bash
# Capture snapshot
ax-devil-device-api-media --device-ip 192.168.1.10 --username admin --password secret --output image.jpg snapshot
```

🔐 SSH Management

```bash
# List SSH users
ax-devil-device-api-ssh --device-ip 192.168.1.10 --username admin --password secret list

# Add SSH user
ax-devil-device-api-ssh --device-ip 192.168.1.10 --username admin --password secret add new-user password123

# Remove SSH user
ax-devil-device-api-ssh --device-ip 192.168.1.10 --username admin --password secret remove user123
```

📡 MQTT Client

```bash
# Activate MQTT client
ax-devil-device-api-mqtt-client --device-ip 192.168.1.10 --username admin --password secret activate

# Deactivate MQTT client
ax-devil-device-api-mqtt-client --device-ip 192.168.1.10 --username admin --password secret deactivate
```

📊 Analytics MQTT

```bash
# List available analytics data sources
ax-devil-device-api-analytics-mqtt --device-ip 192.168.1.10 --username admin --password secret sources

# List configured publishers
ax-devil-device-api-analytics-mqtt --device-ip 192.168.1.10 --username admin --password secret list
```

🔎 API Discovery

```bash
# List available APIs
ax-devil-device-api-discovery --device-ip 192.168.1.10 --username admin --password secret list

# Get API info
ax-devil-device-api-discovery --device-ip 192.168.1.10 --username admin --password secret info vapix
```

🌍 Geocoordinates

```bash
# Get current location coordinates
ax-devil-device-api-geocoordinates --device-ip 192.168.1.10 --username admin --password secret location get

# Set location coordinates
ax-devil-device-api-geocoordinates --device-ip 192.168.1.10 --username admin --password secret location set 59.3293 18.0686
```

🚩 Feature Flags

```bash
# List all feature flags
ax-devil-device-api-feature-flags --device-ip 192.168.1.10 --username admin --password secret list

# Set feature flags
ax-devil-device-api-feature-flags --device-ip 192.168.1.10 --username admin --password secret set feature_name=true
```

🌐 Network

```bash
# Get network interface information
ax-devil-device-api-network --device-ip 192.168.1.10 --username admin --password secret info
```

> **Note:** For more CLI examples, check the [examples directory](src/ax_devil_device_api/examples) in the source code.

---

## ⚠️ Disclaimer

This project is an independent, community-driven implementation and is **not** affiliated with or endorsed by Axis Communications AB. For official APIs and development resources, please refer to [Axis Developer Community](https://www.axis.com/en-us/developer).

## 📄 License

MIT License - See LICENSE file for details.