Skip to main content

unifi_protect 0.2.1 copy "unifi_protect: ^0.2.1" to clipboard
unifi_protect: ^0.2.1 copied to clipboard

Pure Dart client for the Ubiquiti UniFi Protect Integration API (v1).

example/main.dart

import 'package:unifi_protect/unifi_protect.dart';

void main() async {
  // Configure client options
  final options = const UnifiProtectOptions(
    host: '192.168.1.1',
    port: 443,
    apiKey: 'YOUR_PROTECT_API_KEY',
    allowSelfSignedCertificates: true,
  );

  final client = UnifiProtectClient(options: options);

  try {
    // 1. Fetch NVR System Info
    final meta = await client.nvr.getMetaInfo();
    print('Protect Version: ${meta.version}');

    // 2. Discover Cameras
    final cameras = await client.cameras.listCameras();
    print('Discovered ${cameras.length} cameras:');
    for (final cam in cameras) {
      print(' - ${cam.name} (${cam.type})');
      print('   Supported Detections: ${cam.supportedDetectionTypes}');
    }

    // 3. Connect to Real-time Events
    client.events.eventStream.listen((event) {
      if (event is ProtectAlertEvent) {
        print(
            '[ALERT] Camera: ${event.cameraId}, Type: ${event.detectionType.displayName}');
      }
    });
    await client.events.connect();
  } catch (e) {
    print('Error: $e');
  } finally {
    await client.close();
  }
}
1
likes
160
points
856
downloads

Documentation

API reference

Publisher

verified publisherrevivalapps.net

Weekly Downloads

Pure Dart client for the Ubiquiti UniFi Protect Integration API (v1).

Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

www.paypal.com

License

BSD-3-Clause (license)

Dependencies

http, meta, web_socket_channel

More

Packages that depend on unifi_protect