reolink

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 11 Imported by: 0

README

Go Reference Go Report Card

Production-ready Go SDK for the Reolink Camera HTTP API with 100% API coverage.

Features

  • 100% API Coverage - All 130 endpoints across 11 modules
  • Type-Safe - Comprehensive Go types for all API requests and responses
  • Well-Tested - 269 unit tests with 60% coverage
  • Hardware-Validated - Tested on real Reolink cameras
  • Context-Aware - Full context.Context support for timeouts and cancellation
  • Production-Ready - Used in production environments
  • Comprehensive Documentation - Complete API documentation and examples

Installation

go get github.com/mosleyit/reolink_api_wrapper

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/mosleyit/reolink_api_wrapper"
)

func main() {
    // Create client
    client := reolink.NewClient("192.168.1.100",
        reolink.WithCredentials("admin", "password"))

    // Authenticate
    ctx := context.Background()
    if err := client.Login(ctx); err != nil {
        log.Fatal(err)
    }
    defer client.Logout(ctx)

    // Get device information
    info, err := client.System.GetDeviceInfo(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Camera: %s (Firmware: %s)\n", info.Model, info.FirmVer)
}

API Modules

The SDK is organized into 11 domain-specific modules:

Module Description Endpoints
System Device info, time, maintenance, reboot, firmware 15
Security Users, authentication, certificates, sessions 12
Network Network config, WiFi, DDNS, NTP, Email, FTP, Push 10
Video OSD, image settings, ISP, privacy mask, crop 13
Encoding Stream configuration, snapshots, video encoding 6
Recording Recording config, search, download, playback 10
PTZ Pan/Tilt/Zoom control, presets, patrols, guard 18
Alarm Motion detection, AI alarms, audio alarms, buzzer 24
LED IR lights, white LED, power LED control 6
AI AI detection, auto-tracking, auto-focus 13
Streaming RTSP, RTMP, FLV URL helpers 3

Examples

See the examples/ directory for complete working examples:

  • basic - Simple example showing authentication and device info
  • debug_test - Debug tool for testing API calls
  • hardware_test - Comprehensive hardware validation suite

Documentation

Repository Structure

reolink_api_wrapper/
├── *.go                           # SDK source files (root package)
├── *_test.go                      # Unit tests
├── api/                           # API-specific packages
│   └── common/                    # Shared types and utilities
├── pkg/                           # Public packages
│   └── logger/                    # Logger interface and implementations
├── examples/                      # Ready-to-run examples
│   ├── basic/                     # Simple usage example
│   ├── debug_test/                # Debug tool
│   └── hardware_test/             # Hardware validation
├── docs/                          # Documentation files
│   ├── reolink-camera-api-openapi.yaml    # OpenAPI 3.0.3 spec
│   └── ...                        # Additional documentation
├── LICENSE                        # MIT License
├── CHANGELOG.md                   # Version history
└── README.md                      # This file

Configuration Options

The client supports various configuration options:

client := reolink.NewClient("192.168.1.100",
    reolink.WithCredentials("admin", "password"),
    reolink.WithHTTPS(true),
    reolink.WithTimeout(30*time.Second),
    reolink.WithLogger(myLogger),
)

Development

Quick Start with Make

This project includes a comprehensive Makefile for common development tasks:

# Show all available commands
make help

# Run tests
make test

# Build all examples
make build

# Run linter
make lint

# Format code
make fmt

# Run all checks (format, lint, test) and build
make all
Common Make Targets
Target Description
make test Run all tests
make test-coverage Run tests with coverage report
make build Build all example binaries
make lint Run linter
make fmt Format all code
make clean Remove built binaries and coverage files
make verify Run all verification checks (CI-friendly)
make install-tools Install development tools

Run make help to see all 37 available targets.

Manual Testing

You can also run tests directly with Go:

# Run all tests
go test ./...

# Run tests with coverage
go test -cover ./...

# Run tests with race detector
go test -race ./...

Hardware Compatibility

The SDK has been tested and validated on real Reolink hardware:

  • Reolink IPC cameras (various models)
  • Reolink NVR systems
  • Firmware versions 8.x and later

OpenAPI Specification

The complete API specification is available in docs/reolink-camera-api-openapi.yaml:

  • 110+ API endpoints fully documented
  • Complete request/response schemas with types and constraints
  • Working examples for every command
  • Error codes (-1 to -507) categorized
  • Streaming protocol details (RTSP, RTMP, FLV)
View Online

Live Documentation: https://mosleyit.github.io/reolink_api_wrapper/

Generate Clients in Other Languages

Use OpenAPI Generator to create clients in your language:

# Python
openapi-generator-cli generate -i docs/reolink-camera-api-openapi.yaml -g python -o ./python-client

# TypeScript/Axios
openapi-generator-cli generate -i docs/reolink-camera-api-openapi.yaml -g typescript-axios -o ./ts-client

# Java
openapi-generator-cli generate -i docs/reolink-camera-api-openapi.yaml -g java -o ./java-client

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Use the OpenAPI specification to implement your own client, or see the examples/ for reference implementations.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

Version History

See CHANGELOG.md for version history and migration guides.

  • OpenAPI Specification: Complete API documentation in docs/

Documentation

Overview

Package reolink provides a Go client for the Reolink Camera HTTP API.

The client supports all API endpoints including system management, PTZ control, motion detection, AI features, and video streaming.

Basic usage:

client := reolink.NewClient("192.168.1.100",
    reolink.WithCredentials("admin", "password"))

ctx := context.Background()
if err := client.Login(ctx); err != nil {
    log.Fatal(err)
}
defer client.Logout(ctx)

info, err := client.System.GetDeviceInfo(ctx)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Camera: %s\n", info.Model)

For more examples, see the examples/ directory.

Package reolink provides a Go client for the Reolink Camera HTTP API.

The SDK supports all Reolink camera API endpoints including system management, PTZ control, motion detection, AI features, and video streaming.

Installation

go get github.com/mosleyit/reolink_api_wrapper

Quick Start

Basic usage example:

package main

import (
    "context"
    "fmt"
    "log"
    "github.com/mosleyit/reolink_api_wrapper"
)

func main() {
    // Create client
    client := reolink.NewClient("192.168.1.100",
        reolink.WithCredentials("admin", "password"))

    // Authenticate
    ctx := context.Background()
    if err := client.Login(ctx); err != nil {
        log.Fatal(err)
    }
    defer client.Logout(ctx)

    // Get device information
    info, err := client.System.GetDeviceInfo(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Camera: %s, Firmware: %s\n", info.Model, info.FirmVer)
}

API Modules

The SDK is organized into domain-specific modules:

  • System: Device info, time, maintenance, reboot, firmware updates
  • Security: Users, authentication, certificates, online sessions
  • Network: Network config, WiFi, DDNS, NTP, Email, FTP, Push notifications
  • Video: OSD, image settings, ISP, privacy mask, crop
  • Encoding: Stream configuration, snapshots, video encoding
  • Recording: Recording config, search, download, playback
  • PTZ: Pan/Tilt/Zoom control, presets, patrols, guard positions
  • Alarm: Motion detection, AI alarms, audio alarms, buzzer
  • LED: IR lights, white LED, power LED control
  • AI: AI detection, auto-tracking, auto-focus
  • Streaming: RTSP, RTMP, FLV URL helpers

Configuration Options

The client supports various configuration options:

client := reolink.NewClient("192.168.1.100",
    reolink.WithCredentials("admin", "password"),
    reolink.WithHTTPS(true),
    reolink.WithTimeout(30*time.Second),
    reolink.WithLogger(myLogger),
)

Authentication

The SDK handles authentication automatically:

// Login to obtain token
if err := client.Login(ctx); err != nil {
    log.Fatal(err)
}

// Token is automatically included in subsequent requests
info, err := client.System.GetDeviceInfo(ctx)

// Logout when done
defer client.Logout(ctx)

Error Handling

The SDK provides comprehensive error handling:

info, err := client.System.GetDeviceInfo(ctx)
if err != nil {
    // Check if it's an API error
    if apiErr, ok := err.(*reolink.APIError); ok {
        fmt.Printf("API Error: %s (code: %d)\n", apiErr.Message, apiErr.Code)
    } else {
        fmt.Printf("Network Error: %v\n", err)
    }
    return
}

Streaming

Get streaming URLs for RTSP, RTMP, or FLV:

// RTSP URL for main stream (channel 0)
rtspURL := client.Streaming.GetRTSPURL(reolink.StreamMain, 0)
fmt.Printf("RTSP: %s\n", rtspURL)

// RTMP URL for sub stream
rtmpURL := client.Streaming.GetRTMPURL(reolink.StreamSub, 0)
fmt.Printf("RTMP: %s\n", rtmpURL)

PTZ Control

Control Pan/Tilt/Zoom operations:

// Move camera right
err := client.PTZ.PtzCtrl(ctx, "Right", 32, 0, 1)

// Go to preset position
err := client.PTZ.SetPtzPreset(ctx, "call", 1, "Preset1")

Motion Detection

Configure and monitor motion detection:

// Get motion detection state
state, err := client.Alarm.GetMdState(ctx, 0)
if state.State == 1 {
    fmt.Println("Motion detected!")
}

// Configure motion detection
alarm := reolink.MdAlarm{
    Enable:    1,
    Sensitivity: 50,
}
err := client.Alarm.SetMdAlarm(ctx, alarm)

Recording

Search and download recordings:

// Search for recordings
results, err := client.Recording.Search(ctx, searchParams)

// Download recording
data, err := client.Recording.Download(ctx, fileName, 0)

Context Support

All API calls support context for timeout and cancellation:

// With timeout
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

info, err := client.System.GetDeviceInfo(ctx)

Logging

Enable logging for debugging:

logger := reolink.NewStdLogger(os.Stderr)
client := reolink.NewClient("192.168.1.100",
    reolink.WithCredentials("admin", "password"),
    reolink.WithLogger(logger),
)

Hardware Compatibility

The SDK has been tested and validated on real Reolink hardware:

  • Reolink IPC cameras (various models)
  • Reolink NVR systems
  • Firmware versions 8.x and later

API Coverage

The SDK provides 100% coverage of the Reolink HTTP API:

  • 130 API endpoints implemented
  • 11 API modules
  • 269 unit tests
  • 60.5% test coverage
  • Hardware validated

Documentation

Complete API documentation is available at:

Version

Current SDK version: 2.0.0

License

MIT License - see LICENSE file for details

Index

Constants

View Source
const (
	// Success
	ErrCodeSuccess = 0

	// General Errors (-1 to -49)
	ErrCodeMissingParameters      = -1
	ErrCodeUsedUpMemory           = -2
	ErrCodeCheckError             = -3
	ErrCodeParametersError        = -4
	ErrCodeMaxSessionNumber       = -5
	ErrCodeLoginRequired          = -6
	ErrCodeLoginError             = -7
	ErrCodeOperationTimeout       = -8
	ErrCodeNotSupported           = -9
	ErrCodeProtocolError          = -10
	ErrCodeFailedReadOperation    = -11
	ErrCodeFailedGetConfiguration = -12
	ErrCodeFailedSetConfiguration = -13
	ErrCodeFailedApplyMemory      = -14
	ErrCodeFailedCreateSocket     = -15
	ErrCodeFailedSendData         = -16
	ErrCodeFailedReceiveData      = -17
	ErrCodeFailedOpenFile         = -18
	ErrCodeFailedReadFile         = -19
	ErrCodeFailedWriteFile        = -20
	ErrCodeTokenError             = -21
	ErrCodeStringLengthExceeded   = -22
	ErrCodeMissingParametersAlt   = -23
	ErrCodeCommandError           = -24
	ErrCodeInternalError          = -25
	ErrCodeAbilityError           = -26
	ErrCodeInvalidUser            = -27
	ErrCodeUserAlreadyExists      = -28
	ErrCodeMaxUsersReached        = -29
	ErrCodeVersionIdentical       = -30
	ErrCodeUpgradeBusy            = -31
	ErrCodeIPConflict             = -32
	ErrCodeCloudBindEmailFirst    = -34
	ErrCodeCloudUnbindCamera      = -35
	ErrCodeCloudInfoTimeout       = -36
	ErrCodeCloudPasswordError     = -37
	ErrCodeCloudUIDError          = -38
	ErrCodeCloudUserNotExist      = -39
	ErrCodeCloudUnbindFailed      = -40
	ErrCodeCloudNotSupported      = -41
	ErrCodeCloudServerFailed      = -42
	ErrCodeCloudBindFailed        = -43
	ErrCodeCloudUnknownError      = -44
	ErrCodeCloudNeedVerifyCode    = -45
	ErrCodeDigestAuthFailed       = -46
	ErrCodeDigestNonceExpires     = -47
	ErrCodeSnapFailed             = -48
	ErrCodeChannelInvalid         = -49
	ErrCodeDeviceOffline          = -99
	ErrCodeTestFailed             = -100

	// Upgrade Errors (-101 to -105)
	ErrCodeUpgradeCheckFailed    = -101
	ErrCodeUpgradeDownloadFailed = -102
	ErrCodeUpgradeStatusFailed   = -103
	ErrCodeFrequentLogins        = -105

	// Video Recording Errors (-220 to -222)
	ErrCodeVideoDownloadError = -220
	ErrCodeVideoBusy          = -221
	ErrCodeVideoNotExist      = -222

	// Authentication Errors (-301, -310)
	ErrCodeDigestNonceError = -301
	ErrCodeAESDecryptFailed = -310

	// FTP Errors (-451 to -454)
	ErrCodeFTPLoginFailed     = -451
	ErrCodeFTPCreateDirFailed = -452
	ErrCodeFTPUploadFailed    = -453
	ErrCodeFTPConnectFailed   = -454

	// Email Errors (-480 to -485)
	ErrCodeEmailUndefined     = -480
	ErrCodeEmailConnectFailed = -481
	ErrCodeEmailAuthFailed    = -482
	ErrCodeEmailNetworkError  = -483
	ErrCodeEmailServerError   = -484
	ErrCodeEmailMemoryError   = -485

	// Login Errors (-500 to -507)
	ErrCodeIPLimitReached      = -500
	ErrCodeUserLocked          = -501
	ErrCodeUserNotOnline       = -502
	ErrCodeInvalidUsername     = -503
	ErrCodeInvalidPassword     = -504
	ErrCodeUserAlreadyLoggedIn = -505
	ErrCodeAccountLocked       = -506
	ErrCodeAccountNotActivated = -507
)

Error codes from the Reolink API specification

View Source
const (
	LEDStateAuto = "Auto"
	LEDStateOn   = "On"
	LEDStateOff  = "Off"
)

LED state constants

View Source
const (
	PTZOpStop        = "Stop"
	PTZOpLeft        = "Left"
	PTZOpRight       = "Right"
	PTZOpUp          = "Up"
	PTZOpDown        = "Down"
	PTZOpLeftUp      = "LeftUp"
	PTZOpLeftDown    = "LeftDown"
	PTZOpRightUp     = "RightUp"
	PTZOpRightDown   = "RightDown"
	PTZOpZoomInc     = "ZoomInc"
	PTZOpZoomDec     = "ZoomDec"
	PTZOpFocusInc    = "FocusInc"
	PTZOpFocusDec    = "FocusDec"
	PTZOpIrisInc     = "IrisInc"
	PTZOpIrisDec     = "IrisDec"
	PTZOpAuto        = "Auto"
	PTZOpToPos       = "ToPos"
	PTZOpStartPatrol = "StartPatrol"
	PTZOpStopPatrol  = "StopPatrol"
)

PTZ operation constants

View Source
const Version = "1.0.0"

Version is the current SDK version following semantic versioning

Variables

This section is empty.

Functions

func UserAgent

func UserAgent() string

UserAgent returns the user agent string for HTTP requests

Types

type AIAPI

type AIAPI struct {
	// contains filtered or unexported fields
}

AIAPI provides access to AI detection and tracking API endpoints

func (*AIAPI) GetAiCfg

func (a *AIAPI) GetAiCfg(ctx context.Context, channel int) (*AiCfg, error)

GetAiCfg gets AI configuration

func (*AIAPI) GetAiState

func (a *AIAPI) GetAiState(ctx context.Context, channel int) (*AiState, error)

GetAiState gets AI alarm state

func (*AIAPI) SetAiCfg

func (a *AIAPI) SetAiCfg(ctx context.Context, config AiCfg) error

SetAiCfg sets AI configuration

type APIError

type APIError struct {
	Code    int    // Response code from API
	RspCode int    // Detailed error code (from error.rspCode)
	Detail  string // Error detail message
	Cmd     string // Command that caused the error
}

APIError represents an error returned by the Reolink API

func NewAPIError

func NewAPIError(cmd string, code, rspCode int, detail string) *APIError

NewAPIError creates a new APIError

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface

func (*APIError) Is

func (e *APIError) Is(target error) bool

Is implements error comparison for errors.Is

type Ability

type Ability struct {
	AbilityInfo map[string]interface{} `json:"Ability"`
}

Ability represents system capabilities

type AbilityValue

type AbilityValue struct {
	Ability Ability `json:"Ability"`
}

AbilityValue wraps Ability for API response

type AddUserParam

type AddUserParam struct {
	User User `json:"User"`
}

AddUserParam represents parameters for AddUser

type AiAlarm

type AiAlarm struct {
	Channel         int     `json:"channel"`
	AiType          string  `json:"ai_type"`           // people, vehicle, dog_cat, face
	Sensitivity     int     `json:"sensitivity"`       // Sensitivity level
	StayTime        int     `json:"stay_time"`         // Stay time in seconds
	Width           int     `json:"width"`             // Detection area width
	Height          int     `json:"height"`            // Detection area height
	Scope           *Scope  `json:"scope,omitempty"`   // Detection scope/area
	MinTargetHeight float64 `json:"min_target_height"` // Minimum target height (0.0-1.0)
	MaxTargetHeight float64 `json:"max_target_height"` // Maximum target height (0.0-1.0)
	MinTargetWidth  float64 `json:"min_target_width"`  // Minimum target width (0.0-1.0)
	MaxTargetWidth  float64 `json:"max_target_width"`  // Maximum target width (0.0-1.0)
}

AiAlarm represents AI-based alarm configuration

type AiAlarmParam

type AiAlarmParam struct {
	Channel int     `json:"channel"`
	AiAlarm AiAlarm `json:"AiAlarm"`
}

AiAlarmParam represents parameters for SetAiAlarm

type AiAlarmValue

type AiAlarmValue struct {
	AiAlarm AiAlarm `json:"AiAlarm"`
}

AiAlarmValue wraps AiAlarm for API response

type AiCfg

type AiCfg struct {
	Channel      int          `json:"channel"`      // Channel number
	AiTrack      int          `json:"aiTrack"`      // AI tracking switch (0=off, 1=on)
	AiDetectType AiDetectType `json:"AiDetectType"` // AI detection types
	TrackType    AiTrackType  `json:"trackType"`    // AI tracking types
}

AiCfg represents AI configuration

type AiDetectState

type AiDetectState struct {
	AlarmState int `json:"alarm_state"` // 0=no alarm, 1=alarm detected
	Support    int `json:"support"`     // 0=not supported, 1=supported
}

AiDetectState represents AI detection state for a specific type

type AiDetectType

type AiDetectType struct {
	People  int `json:"people"`  // 0=disabled, 1=enabled
	Vehicle int `json:"vehicle"` // 0=disabled, 1=enabled
	DogCat  int `json:"dog_cat"` // 0=disabled, 1=enabled
	Face    int `json:"face"`    // 0=disabled, 1=enabled
}

AiDetectType represents AI detection type configuration

type AiState

type AiState struct {
	Channel int           `json:"channel"` // Channel number
	People  AiDetectState `json:"people"`  // People detection state
	Vehicle AiDetectState `json:"vehicle"` // Vehicle detection state
	DogCat  AiDetectState `json:"dog_cat"` // Dog/cat detection state
	Face    AiDetectState `json:"face"`    // Face detection state
}

AiState represents AI alarm state

type AiTrackType

type AiTrackType struct {
	People  int `json:"people"`  // 0=disabled, 1=enabled
	Vehicle int `json:"vehicle"` // 0=disabled, 1=enabled
	DogCat  int `json:"dog_cat"` // 0=disabled, 1=enabled
	Face    int `json:"face"`    // 0=disabled, 1=enabled
}

AiTrackType represents AI tracking type configuration

type Alarm

type Alarm struct {
	Channel int      `json:"channel"` // Channel number
	Type    string   `json:"type"`    // Alarm type (e.g., "md" for motion detection)
	Enable  int      `json:"enable"`  // 0=disabled, 1=enabled
	Scope   MdScope  `json:"scope"`   // Detection area
	Sens    []MdSens `json:"sens"`    // Time-based sensitivity settings
}

Alarm represents general alarm configuration

type AlarmAPI

type AlarmAPI struct {
	// contains filtered or unexported fields
}

AlarmAPI provides access to alarm and motion detection API endpoints

func (*AlarmAPI) AudioAlarmPlay

func (a *AlarmAPI) AudioAlarmPlay(ctx context.Context, param AudioAlarmPlayParam) error

AudioAlarmPlay plays audio alarm sound

func (*AlarmAPI) GetAlarm

func (a *AlarmAPI) GetAlarm(ctx context.Context, channel int, alarmType string) (*Alarm, error)

GetAlarm gets general alarm configuration

func (*AlarmAPI) GetAudioAlarm

func (a *AlarmAPI) GetAudioAlarm(ctx context.Context, channel int) (*AudioAlarm, error)

GetAudioAlarm gets audio detection alarm configuration

func (*AlarmAPI) GetAudioAlarmV20

func (a *AlarmAPI) GetAudioAlarmV20(ctx context.Context, channel int) (*AudioAlarm, error)

GetAudioAlarmV20 gets audio detection alarm configuration (v2.0)

func (*AlarmAPI) GetBuzzerAlarmV20

func (a *AlarmAPI) GetBuzzerAlarmV20(ctx context.Context, channel int) (*BuzzerAlarm, error)

GetBuzzerAlarmV20 gets buzzer alarm configuration (v2.0)

func (*AlarmAPI) GetMdAlarm

func (a *AlarmAPI) GetMdAlarm(ctx context.Context, channel int) (*MdAlarm, error)

GetMdAlarm gets motion detection alarm configuration

func (*AlarmAPI) GetMdState

func (a *AlarmAPI) GetMdState(ctx context.Context, channel int) (int, error)

GetMdState gets current motion detection state

func (*AlarmAPI) SetAlarm

func (a *AlarmAPI) SetAlarm(ctx context.Context, alarm Alarm) error

SetAlarm sets general alarm configuration

func (*AlarmAPI) SetAudioAlarm

func (a *AlarmAPI) SetAudioAlarm(ctx context.Context, audioAlarm AudioAlarm) error

SetAudioAlarm sets audio detection alarm configuration

func (*AlarmAPI) SetAudioAlarmV20

func (a *AlarmAPI) SetAudioAlarmV20(ctx context.Context, audioAlarm AudioAlarm) error

SetAudioAlarmV20 sets audio detection alarm configuration (v2.0)

func (*AlarmAPI) SetBuzzerAlarmV20

func (a *AlarmAPI) SetBuzzerAlarmV20(ctx context.Context, buzzerAlarm BuzzerAlarm) error

SetBuzzerAlarmV20 sets buzzer alarm configuration (v2.0)

func (*AlarmAPI) SetMdAlarm

func (a *AlarmAPI) SetMdAlarm(ctx context.Context, config MdAlarm) error

SetMdAlarm sets motion detection alarm configuration

type AlarmValue

type AlarmValue struct {
	Alarm Alarm `json:"Alarm"`
}

AlarmValue wraps Alarm for API response

type AudioAlarm

type AudioAlarm struct {
	Channel     int                `json:"channel"`     // Channel number
	Enable      int                `json:"enable"`      // 0=disabled, 1=enabled
	Sensitivity int                `json:"sensitivity"` // Audio sensitivity (0-100)
	Schedule    AudioAlarmSchedule `json:"schedule"`    // Schedule configuration
}

AudioAlarm represents audio detection alarm configuration

type AudioAlarmPlayParam

type AudioAlarmPlayParam struct {
	Channel      int    `json:"channel"`       // Channel number
	AlarmMode    string `json:"alarm_mode"`    // Alarm mode
	ManualSwitch int    `json:"manual_switch"` // 0=off, 1=on
	Times        int    `json:"times"`         // Number of times to play
}

AudioAlarmPlayParam represents parameters for AudioAlarmPlay

type AudioAlarmSchedule

type AudioAlarmSchedule struct {
	Enable int         `json:"enable"` // 0=disabled, 1=enabled
	Table  interface{} `json:"table"`  // string for v1, map for v2.0
}

AudioAlarmSchedule represents audio alarm schedule

type AudioAlarmValue

type AudioAlarmValue struct {
	AudioAlarm AudioAlarm `json:"AudioAlarm"`
}

AudioAlarmValue wraps AudioAlarm for API response

type AutoFocus

type AutoFocus struct {
	Channel int `json:"channel"` // Channel number
	Disable int `json:"disable"` // 0=enable autofocus, 1=forbid autofocus
}

AutoFocus represents auto focus configuration

type AutoFocusValue

type AutoFocusValue struct {
	AutoFocus AutoFocus `json:"AutoFocus"`
}

AutoFocusValue wraps AutoFocus for API response

type AutoMaint

type AutoMaint struct {
	Enable  int    `json:"enable"`
	WeekDay string `json:"weekDay"` // "Everyday", "Sunday", "Monday", etc.
	Hour    int    `json:"hour"`    // 0-23
	Min     int    `json:"min"`     // 0-59
	Sec     int    `json:"sec"`     // 0-59
}

AutoMaint represents automatic maintenance configuration

type AutoMaintParam

type AutoMaintParam struct {
	AutoMaint AutoMaint `json:"AutoMaint"`
}

AutoMaintParam represents parameters for SetAutoMaint

type AutoMaintValue

type AutoMaintValue struct {
	AutoMaint AutoMaint `json:"AutoMaint"`
}

AutoMaintValue wraps AutoMaint for API response

type AutoUpgrade

type AutoUpgrade struct {
	Enable int `json:"enable"` // 0=disabled, 1=enabled
}

AutoUpgrade represents automatic upgrade configuration

type AutoUpgradeValue

type AutoUpgradeValue struct {
	AutoUpgrade AutoUpgrade `json:"AutoUpgrade"`
}

AutoUpgradeValue wraps AutoUpgrade for API response

type BuzzerAlarm

type BuzzerAlarm struct {
	Channel  int                 `json:"channel"`  // Channel number
	Enable   int                 `json:"enable"`   // 0=disabled, 1=enabled
	Schedule BuzzerAlarmSchedule `json:"schedule"` // Schedule configuration
}

BuzzerAlarm represents buzzer alarm configuration

type BuzzerAlarmSchedule

type BuzzerAlarmSchedule struct {
	Enable int         `json:"enable"` // 0=disabled, 1=enabled
	Table  interface{} `json:"table"`  // string for v1, map for v2.0
}

BuzzerAlarmSchedule represents buzzer alarm schedule

type BuzzerAlarmValue

type BuzzerAlarmValue struct {
	BuzzerAlarm BuzzerAlarm `json:"BuzzerAlarm"`
}

BuzzerAlarmValue wraps BuzzerAlarm for API response

type CertificateInfo

type CertificateInfo struct {
	Enable  int    `json:"enable"`  // 0=disabled, 1=enabled
	CrtName string `json:"crtName"` // Certificate file name
	KeyName string `json:"keyName"` // Private key file name
}

CertificateInfo represents SSL certificate information

type CertificateInfoValue

type CertificateInfoValue struct {
	CertificateInfo CertificateInfo `json:"CertificateInfo"`
}

CertificateInfoValue wraps CertificateInfo for API response

type Channel

type Channel struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	Online int    `json:"online"` // 1 = online, 0 = offline
	Status string `json:"status"`
}

Channel represents a camera channel

type ChannelStatus

type ChannelStatus struct {
	Channel  int    `json:"channel"`
	Name     string `json:"name"`
	Online   int    `json:"online"`   // 0=offline, 1=online
	TypeInfo string `json:"typeInfo"` // Camera model/type
}

ChannelStatus represents status of a single channel

type ChannelStatusValue

type ChannelStatusValue struct {
	Count  int             `json:"count"`
	Status []ChannelStatus `json:"status"`
}

ChannelStatusValue wraps channel status for API response

type Client

type Client struct {

	// API modules
	System    *SystemAPI
	Security  *SecurityAPI
	Network   *NetworkAPI
	Video     *VideoAPI
	Encoding  *EncodingAPI
	Recording *RecordingAPI
	PTZ       *PTZAPI
	Alarm     *AlarmAPI
	LED       *LEDAPI
	AI        *AIAPI
	Streaming *StreamingAPI
	// contains filtered or unexported fields
}

Client represents a Reolink camera API client

func NewClient

func NewClient(host string, opts ...Option) *Client

NewClient creates a new Reolink API client

func (*Client) BaseURL

func (c *Client) BaseURL() string

BaseURL returns the base API URL

func (*Client) GetToken

func (c *Client) GetToken() string

GetToken returns the current authentication token

func (*Client) Host

func (c *Client) Host() string

Host returns the camera host address

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

IsAuthenticated returns true if the client has a valid token

func (*Client) Login

func (c *Client) Login(ctx context.Context) error

Login authenticates with the camera and obtains a token

func (*Client) Logout

func (c *Client) Logout(ctx context.Context) error

Logout invalidates the current token

func (*Client) SetToken

func (c *Client) SetToken(token string)

SetToken sets the authentication token manually

type Crop

type Crop struct {
	Channel      int `json:"channel"`      // Channel number
	ScreenWidth  int `json:"screenWidth"`  // Screen width
	ScreenHeight int `json:"screenHeight"` // Screen height
	CropWidth    int `json:"cropWidth"`    // Width of crop area
	CropHeight   int `json:"cropHeight"`   // Height of crop area
	TopLeftX     int `json:"topLeftX"`     // Distance from left boundary
	TopLeftY     int `json:"topLeftY"`     // Distance from top boundary
}

Crop represents video crop/zoom configuration

type CropValue

type CropValue struct {
	Crop Crop `json:"Crop"`
}

CropValue represents the response value for GetCrop

type DNSConfig

type DNSConfig struct {
	Auto int    `json:"auto"` // 0=manual, 1=auto
	DNS1 string `json:"dns1"` // Primary DNS server
	DNS2 string `json:"dns2"` // Secondary DNS server
}

DNSConfig represents DNS configuration

type Ddns

type Ddns struct {
	Enable   int    `json:"enable"`   // 0=disabled, 1=enabled
	Type     string `json:"type"`     // "3322" or "Dyndns"
	UserName string `json:"userName"` // DDNS username
	Password string `json:"password"` // DDNS password
	Domain   string `json:"domain"`   // Domain name
}

Ddns represents DDNS configuration

type DdnsValue

type DdnsValue struct {
	Ddns Ddns `json:"Ddns"`
}

DdnsValue represents the response value for GetDdns

type DelUserParam

type DelUserParam struct {
	User User `json:"User"`
}

DelUserParam represents parameters for DelUser

type DeviceInfo

type DeviceInfo struct {
	B485         int    `json:"B485"`
	IOInputNum   int    `json:"IOInputNum"`
	IOOutputNum  int    `json:"IOOutputNum"`
	AudioNum     int    `json:"audioNum"`
	BuildDay     string `json:"buildDay"`
	CfgVer       string `json:"cfgVer"`
	ChannelNum   int    `json:"channelNum"`
	Detail       string `json:"detail"`
	DiskNum      int    `json:"diskNum"`
	ExactType    string `json:"exactType"`
	FirmVer      string `json:"firmVer"`
	FrameworkVer int    `json:"frameworkVer"`
	HardVer      string `json:"hardVer"`
	Model        string `json:"model"`
	Name         string `json:"name"`
	PakSuffix    string `json:"pakSuffix"`
	Serial       string `json:"serial"`
	Type         string `json:"type"`
	Wifi         int    `json:"wifi"`
}

DeviceInfo represents device information from GetDevInfo

type DeviceInfoValue

type DeviceInfoValue struct {
	DevInfo DeviceInfo `json:"DevInfo"`
}

DeviceInfoValue wraps DeviceInfo for API response

type DeviceName

type DeviceName struct {
	Name string `json:"name"`
}

DeviceName represents device name from GetDevName

type DeviceNameParam

type DeviceNameParam struct {
	DevName DeviceName `json:"DevName"`
}

DeviceNameParam represents parameters for SetDevName

type DeviceNameValue

type DeviceNameValue struct {
	DevName DeviceName `json:"DevName"`
}

DeviceNameValue wraps DeviceName for API response

type DisconnectParam

type DisconnectParam struct {
	User struct {
		UserName string `json:"userName"`
	} `json:"User"`
}

DisconnectParam represents parameters for Disconnect

type DstConfig

type DstConfig struct {
	Enable    int `json:"enable"`
	Offset    int `json:"offset"`
	BeginMon  int `json:"beginMon"`
	BeginWeek int `json:"beginWeek"`
	BeginDay  int `json:"beginDay"`
	BeginHour int `json:"beginHour"`
	EndMon    int `json:"endMon"`
	EndWeek   int `json:"endWeek"`
	EndDay    int `json:"endDay"`
	EndHour   int `json:"endHour"`
}

DstConfig represents daylight saving time configuration

type Email

type Email struct {
	SMTPServer string        `json:"smtpServer"` // SMTP server address
	SMTPPort   int           `json:"smtpPort"`   // SMTP port (default: 25, 465 for SSL)
	UserName   string        `json:"userName"`   // Email username
	Password   string        `json:"password"`   // Email password
	Addr1      string        `json:"addr1"`      // Recipient email 1
	Addr2      string        `json:"addr2"`      // Recipient email 2
	Addr3      string        `json:"addr3"`      // Recipient email 3
	Interval   int           `json:"interval"`   // Email interval in seconds
	Schedule   EmailSchedule `json:"schedule"`   // Email schedule
}

Email represents email configuration

type EmailSchedule

type EmailSchedule struct {
	Enable int         `json:"enable"` // 0=disabled, 1=enabled
	Table  interface{} `json:"table"`  // string for v1, EmailScheduleTable for v2.0
}

EmailSchedule represents email schedule configuration

type EmailScheduleTable

type EmailScheduleTable struct {
	MD        string `json:"MD,omitempty"`         // Motion detection schedule
	TIMING    string `json:"TIMING,omitempty"`     // Timing schedule
	AIPeople  string `json:"AI_PEOPLE,omitempty"`  // AI people detection schedule
	AIVehicle string `json:"AI_VEHICLE,omitempty"` // AI vehicle detection schedule
	AIDogCat  string `json:"AI_DOG_CAT,omitempty"` // AI dog/cat detection schedule
}

EmailScheduleTable represents v2.0 email schedule with multiple alarm types

type EmailValue

type EmailValue struct {
	Email Email `json:"Email"`
}

EmailValue represents the response value for GetEmail

type EncConfig

type EncConfig struct {
	Audio      int    `json:"audio"`      // 0=disabled, 1=enabled
	Channel    int    `json:"channel"`    // Channel number
	MainStream Stream `json:"mainStream"` // Main stream configuration
	SubStream  Stream `json:"subStream"`  // Sub stream configuration
}

EncConfig represents encoding configuration

type EncParam

type EncParam struct {
	Enc EncConfig `json:"Enc"`
}

EncParam represents parameters for SetEnc

type EncValue

type EncValue struct {
	Enc EncConfig `json:"Enc"`
}

EncValue wraps EncConfig for API response

type EncodingAPI

type EncodingAPI struct {
	// contains filtered or unexported fields
}

EncodingAPI provides access to encoding/video stream configuration endpoints

func (*EncodingAPI) GetEnc

func (e *EncodingAPI) GetEnc(ctx context.Context, channel int) (*EncConfig, error)

GetEnc gets encoding configuration for a channel

func (*EncodingAPI) SetEnc

func (e *EncodingAPI) SetEnc(ctx context.Context, config EncConfig) error

SetEnc sets encoding configuration for a channel

func (*EncodingAPI) Snap

func (e *EncodingAPI) Snap(ctx context.Context, channel int) ([]byte, error)

Snap captures a snapshot image from the specified channel Returns the image data as a byte slice

type ErrorDetail

type ErrorDetail struct {
	RspCode int    `json:"rspCode"` // Detailed error code
	Detail  string `json:"detail"`  // Error detail message
}

ErrorDetail represents detailed error information in a response

type FirmwareCheck

type FirmwareCheck struct {
	NewFirmware int `json:"newFirmware"` // 0=no new firmware, 1=new firmware available
}

FirmwareCheck represents firmware check result

type FormatParam

type FormatParam struct {
	Hdd struct {
		ID int `json:"id"`
	} `json:"Hdd"`
}

FormatParam represents parameters for Format command

type Ftp

type Ftp struct {
	Server    string      `json:"server"`              // FTP server address
	Port      int         `json:"port"`                // FTP port (default: 21)
	UserName  string      `json:"userName"`            // FTP username
	Password  string      `json:"password"`            // FTP password
	RemoteDir string      `json:"remoteDir,omitempty"` // Remote directory
	Schedule  FtpSchedule `json:"schedule"`            // FTP schedule
}

Ftp represents FTP configuration

type FtpSchedule

type FtpSchedule struct {
	Enable int         `json:"enable"` // 0=disabled, 1=enabled
	Table  interface{} `json:"table"`  // string for v1, FtpScheduleTable for v2.0
}

FtpSchedule represents FTP schedule configuration

type FtpScheduleTable

type FtpScheduleTable struct {
	MD        string `json:"MD,omitempty"`         // Motion detection schedule
	TIMING    string `json:"TIMING,omitempty"`     // Timing schedule
	AIPeople  string `json:"AI_PEOPLE,omitempty"`  // AI people detection schedule
	AIVehicle string `json:"AI_VEHICLE,omitempty"` // AI vehicle detection schedule
	AIDogCat  string `json:"AI_DOG_CAT,omitempty"` // AI dog/cat detection schedule
}

FtpScheduleTable represents v2.0 FTP schedule with multiple alarm types

type FtpValue

type FtpValue struct {
	Ftp Ftp `json:"Ftp"`
}

FtpValue represents the response value for GetFtp

type HddInfo

type HddInfo struct {
	Capacity int    `json:"capacity"` // Total capacity in MB
	Format   int    `json:"format"`   // Format status
	Mount    int    `json:"mount"`    // Mount status
	Size     int    `json:"size"`     // Used size in MB
	Status   string `json:"status"`   // "ok", "error", etc.
}

HddInfo represents hard disk information

type HddInfoValue

type HddInfoValue struct {
	HddInfo []HddInfo `json:"HddInfo"`
}

HddInfoValue wraps HDD array for API response

type Image

type Image struct {
	Channel    int `json:"channel"`    // Channel number
	Bright     int `json:"bright"`     // Brightness (0-255, default 128)
	Contrast   int `json:"contrast"`   // Contrast (0-255, default 128)
	Saturation int `json:"saturation"` // Saturation (0-255, default 128)
	Hue        int `json:"hue"`        // Hue (0-255, default 128)
	Sharpen    int `json:"sharpen"`    // Sharpness (0-255, default 128)
}

Image represents image quality settings

type ImageValue

type ImageValue struct {
	Image Image `json:"Image"`
}

ImageValue represents the response value for GetImage

type IrLights

type IrLights struct {
	State string `json:"state"` // Auto, On, Off
}

IrLights represents IR lights configuration

type IrLightsParam

type IrLightsParam struct {
	IrLights struct {
		Channel int    `json:"channel"` // Channel number
		State   string `json:"state"`   // Auto, On, Off
	} `json:"IrLights"`
}

IrLightsParam represents parameters for SetIrLights

type IrLightsValue

type IrLightsValue struct {
	IrLights IrLights `json:"IrLights"`
}

IrLightsValue wraps IrLights for API response

type Isp

type Isp struct {
	Channel     int     `json:"channel"`     // Channel number
	AntiFlicker string  `json:"antiFlicker"` // "Outdoor", "50Hz", "60Hz"
	Exposure    string  `json:"exposure"`    // "Auto", "Manual"
	Gain        IspGain `json:"gain"`        // Gain range (min/max)
	DayNight    string  `json:"dayNight"`    // "Auto", "Color", "Black&White"
	BackLight   string  `json:"backLight"`   // "Off", "BackLightControl", "DynamicRangeControl", "Off"
	Blc         int     `json:"blc"`         // Backlight compensation (0-255)
	Drc         int     `json:"drc"`         // Dynamic range control (0-255)
	Rotation    int     `json:"rotation"`    // Rotation angle (0, 90, 180, 270)
	Mirroring   int     `json:"mirroring"`   // Mirror (0=off, 1=on)
	Nr3d        int     `json:"nr3d"`        // 3D noise reduction (0-100)
}

Isp represents Image Signal Processor settings

type IspGain

type IspGain struct {
	Min int `json:"min"` // Minimum gain value
	Max int `json:"max"` // Maximum gain value
}

IspGain represents gain range settings

type IspValue

type IspValue struct {
	Isp Isp `json:"Isp"`
}

IspValue represents the response value for GetIsp

type LEDAPI

type LEDAPI struct {
	// contains filtered or unexported fields
}

LEDAPI provides access to LED and light control API endpoints

func (*LEDAPI) GetAiAlarm

func (l *LEDAPI) GetAiAlarm(ctx context.Context, channel int, aiType string) (*AiAlarm, error)

GetAiAlarm gets AI-based alarm configuration

func (*LEDAPI) GetIrLights

func (l *LEDAPI) GetIrLights(ctx context.Context) (*IrLights, error)

GetIrLights gets IR lights configuration

func (*LEDAPI) GetPowerLed

func (l *LEDAPI) GetPowerLed(ctx context.Context, channel int) (*PowerLed, error)

GetPowerLed gets power LED configuration

func (*LEDAPI) GetWhiteLed

func (l *LEDAPI) GetWhiteLed(ctx context.Context, channel int) (*WhiteLed, error)

GetWhiteLed gets white LED configuration

func (*LEDAPI) SetAiAlarm

func (l *LEDAPI) SetAiAlarm(ctx context.Context, channel int, alarm AiAlarm) error

SetAiAlarm sets AI-based alarm configuration

func (*LEDAPI) SetAlarmArea

func (l *LEDAPI) SetAlarmArea(ctx context.Context, params map[string]interface{}) error

SetAlarmArea sets alarm detection area/zone

func (*LEDAPI) SetIrLights

func (l *LEDAPI) SetIrLights(ctx context.Context, channel int, state string) error

SetIrLights sets IR lights configuration

func (*LEDAPI) SetPowerLed

func (l *LEDAPI) SetPowerLed(ctx context.Context, channel int, state string) error

SetPowerLed sets power LED configuration

func (*LEDAPI) SetWhiteLed

func (l *LEDAPI) SetWhiteLed(ctx context.Context, config WhiteLed) error

SetWhiteLed sets white LED configuration

type LocalLink struct {
	Type   string    `json:"type"`   // "DHCP" or "Static"
	Static StaticIP  `json:"static"` // Static IP configuration
	DNS    DNSConfig `json:"dns"`    // DNS configuration
}

LocalLink represents local network configuration

type LocalLinkValue

type LocalLinkValue struct {
	LocalLink LocalLink `json:"LocalLink"`
}

LocalLinkValue represents the response value for GetLocalLink

type LoginParam

type LoginParam struct {
	User LoginUser `json:"User"`
}

LoginParam represents the parameters for the Login command

type LoginUser

type LoginUser struct {
	UserName string `json:"userName"`
	Password string `json:"password"`
	Version  string `json:"Version,omitempty"` // "0": no encryption, "1": private encryption
}

LoginUser represents user credentials for login

type LoginValue

type LoginValue struct {
	Token TokenInfo `json:"Token"`
}

LoginValue represents the response value from a Login command

type Mask

type Mask struct {
	Channel int        `json:"channel"` // Channel number
	Enable  int        `json:"enable"`  // 0=disabled, 1=enabled
	Area    []MaskArea `json:"area"`    // Privacy mask areas (up to 4)
}

Mask represents privacy mask configuration

type MaskArea

type MaskArea struct {
	Screen MaskScreen `json:"screen"` // Screen dimensions
	X      int        `json:"x"`      // X coordinate
	Y      int        `json:"y"`      // Y coordinate
	Width  int        `json:"width"`  // Width
	Height int        `json:"height"` // Height
}

MaskArea represents a single privacy mask area

type MaskScreen

type MaskScreen struct {
	Height int `json:"height"` // Screen height
	Width  int `json:"width"`  // Screen width
}

MaskScreen represents screen dimensions for mask area

type MaskValue

type MaskValue struct {
	Mask Mask `json:"Mask"`
}

MaskValue represents the response value for GetMask

type MdAlarm

type MdAlarm struct {
	Channel int       `json:"channel"` // Channel number
	Scope   MdScope   `json:"scope"`   // Detection area
	NewSens MdNewSens `json:"newSens"` // Time-based sensitivity
}

MdAlarm represents motion detection alarm configuration

type MdAlarmParam

type MdAlarmParam struct {
	MdAlarm MdAlarm `json:"MdAlarm"`
}

MdAlarmParam represents parameters for SetMdAlarm

type MdAlarmValue

type MdAlarmValue struct {
	MdAlarm MdAlarm `json:"MdAlarm"`
}

MdAlarmValue wraps MdAlarm for API response

type MdNewSens

type MdNewSens struct {
	Sens []MdSensitivity `json:"sens"` // Array of up to 4 time periods
}

MdNewSens wraps sensitivity array

type MdScope

type MdScope struct {
	Cols  int    `json:"cols"`  // Number of columns in grid (typically 80)
	Rows  int    `json:"rows"`  // Number of rows in grid (typically 60 or 45)
	Table string `json:"table"` // Grid string of 1s and 0s (length = cols × rows)
}

MdScope represents motion detection scope/area

type MdSens

type MdSens struct {
	BeginHour   int `json:"beginHour"`   // Start hour (0-23)
	BeginMin    int `json:"beginMin"`    // Start minute (0-59)
	EndHour     int `json:"endHour"`     // End hour (0-23)
	EndMin      int `json:"endMin"`      // End minute (0-59)
	Sensitivity int `json:"sensitivity"` // Sensitivity (0-100)
}

MdSens represents simplified sensitivity settings for GetAlarm

type MdSensitivity

type MdSensitivity struct {
	ID          int `json:"id"`          // Time period ID (0-3)
	BeginHour   int `json:"beginHour"`   // Start hour (0-23)
	BeginMin    int `json:"beginMin"`    // Start minute (0-59)
	EndHour     int `json:"endHour"`     // End hour (0-23)
	EndMin      int `json:"endMin"`      // End minute (0-59)
	Enable      int `json:"enable"`      // 0=disabled, 1=enabled
	Priority    int `json:"priority"`    // Priority level
	Sensitivity int `json:"sensitivity"` // Sensitivity (0-100, higher = more sensitive)
}

MdSensitivity represents time-based sensitivity settings

type MdStateValue

type MdStateValue struct {
	State int `json:"state"` // 0=no motion, 1=motion detected
}

MdStateValue represents motion detection state

type ModifyUserParam

type ModifyUserParam struct {
	User User `json:"User"`
}

ModifyUserParam represents parameters for ModifyUser

type NetPort

type NetPort struct {
	HTTPEnable  int `json:"httpEnable"`  // 0=disabled, 1=enabled
	HTTPPort    int `json:"httpPort"`    // HTTP port (default: 80)
	HTTPSEnable int `json:"httpsEnable"` // 0=disabled, 1=enabled
	HTTPSPort   int `json:"httpsPort"`   // HTTPS port (default: 443)
	MediaPort   int `json:"mediaPort"`   // Media port (default: 9000)
	OnvifEnable int `json:"onvifEnable"` // 0=disabled, 1=enabled
	OnvifPort   int `json:"onvifPort"`   // ONVIF port (default: 8000)
	RTMPEnable  int `json:"rtmpEnable"`  // 0=disabled, 1=enabled
	RTMPPort    int `json:"rtmpPort"`    // RTMP port (default: 1935)
	RTSPEnable  int `json:"rtspEnable"`  // 0=disabled, 1=enabled
	RTSPPort    int `json:"rtspPort"`    // RTSP port (default: 554)
}

NetPort represents network port configuration

type NetPortValue

type NetPortValue struct {
	NetPort NetPort `json:"NetPort"`
}

NetPortValue represents the response value for GetNetPort

type NetworkAPI

type NetworkAPI struct {
	// contains filtered or unexported fields
}

NetworkAPI provides methods for network configuration

func (*NetworkAPI) GetDdns

func (n *NetworkAPI) GetDdns(ctx context.Context) (*Ddns, error)

GetDdns gets DDNS configuration

func (*NetworkAPI) GetEmail

func (n *NetworkAPI) GetEmail(ctx context.Context) (*Email, error)

GetEmail gets email configuration

func (*NetworkAPI) GetEmailV20

func (n *NetworkAPI) GetEmailV20(ctx context.Context, channel int) (*Email, error)

GetEmailV20 gets email configuration (v2.0 with enhanced features)

func (*NetworkAPI) GetFtp

func (n *NetworkAPI) GetFtp(ctx context.Context) (*Ftp, error)

GetFtp gets FTP configuration

func (*NetworkAPI) GetFtpV20

func (n *NetworkAPI) GetFtpV20(ctx context.Context, channel int) (*Ftp, error)

GetFtpV20 gets FTP configuration (v2.0 with enhanced features)

func (n *NetworkAPI) GetLocalLink(ctx context.Context) (*LocalLink, error)

GetLocalLink gets local network configuration

func (*NetworkAPI) GetNetPort

func (n *NetworkAPI) GetNetPort(ctx context.Context) (*NetPort, error)

GetNetPort gets network port configuration

func (*NetworkAPI) GetNtp

func (n *NetworkAPI) GetNtp(ctx context.Context) (*Ntp, error)

GetNtp gets NTP configuration

func (*NetworkAPI) GetP2p

func (n *NetworkAPI) GetP2p(ctx context.Context) (*P2p, error)

GetP2p gets P2P configuration

func (*NetworkAPI) GetPush

func (n *NetworkAPI) GetPush(ctx context.Context) (*Push, error)

GetPush gets push notification configuration

func (*NetworkAPI) GetPushCfg

func (n *NetworkAPI) GetPushCfg(ctx context.Context) (*PushCfg, error)

GetPushCfg gets push configuration details

func (*NetworkAPI) GetPushV20

func (n *NetworkAPI) GetPushV20(ctx context.Context, channel int) (*Push, error)

GetPushV20 gets push notification configuration (v2.0 with enhanced features)

func (*NetworkAPI) GetRtspUrl

func (n *NetworkAPI) GetRtspUrl(ctx context.Context, channel int) (*RtspUrl, error)

GetRtspUrl gets RTSP streaming URL from the camera

func (*NetworkAPI) GetUpnp

func (n *NetworkAPI) GetUpnp(ctx context.Context) (*Upnp, error)

GetUpnp gets UPnP configuration

func (*NetworkAPI) GetWifi

func (n *NetworkAPI) GetWifi(ctx context.Context) (*Wifi, error)

GetWifi gets WiFi configuration

func (*NetworkAPI) GetWifiSignal

func (n *NetworkAPI) GetWifiSignal(ctx context.Context) (*WifiSignal, error)

GetWifiSignal gets current WiFi signal strength

func (*NetworkAPI) ScanWifi

func (n *NetworkAPI) ScanWifi(ctx context.Context) ([]WifiNetwork, error)

ScanWifi scans for available WiFi networks

func (*NetworkAPI) SetDdns

func (n *NetworkAPI) SetDdns(ctx context.Context, ddns Ddns) error

SetDdns sets DDNS configuration

func (*NetworkAPI) SetEmail

func (n *NetworkAPI) SetEmail(ctx context.Context, email Email) error

SetEmail sets email configuration

func (*NetworkAPI) SetEmailV20

func (n *NetworkAPI) SetEmailV20(ctx context.Context, channel int, email Email) error

SetEmailV20 sets email configuration (v2.0 with enhanced features)

func (*NetworkAPI) SetFtp

func (n *NetworkAPI) SetFtp(ctx context.Context, ftp Ftp) error

SetFtp sets FTP configuration

func (*NetworkAPI) SetFtpV20

func (n *NetworkAPI) SetFtpV20(ctx context.Context, channel int, ftp Ftp) error

SetFtpV20 sets FTP configuration (v2.0 with enhanced features)

func (n *NetworkAPI) SetLocalLink(ctx context.Context, localLink LocalLink) error

SetLocalLink sets local network configuration

func (*NetworkAPI) SetNetPort

func (n *NetworkAPI) SetNetPort(ctx context.Context, netPort NetPort) error

SetNetPort sets network port configuration

func (*NetworkAPI) SetNtp

func (n *NetworkAPI) SetNtp(ctx context.Context, ntp Ntp) error

SetNtp sets NTP configuration

func (*NetworkAPI) SetP2p

func (n *NetworkAPI) SetP2p(ctx context.Context, p2p P2p) error

SetP2p sets P2P configuration

func (*NetworkAPI) SetPush

func (n *NetworkAPI) SetPush(ctx context.Context, push Push) error

SetPush sets push notification configuration

func (*NetworkAPI) SetPushCfg

func (n *NetworkAPI) SetPushCfg(ctx context.Context, pushCfg PushCfg) error

SetPushCfg sets push configuration details

func (*NetworkAPI) SetPushV20

func (n *NetworkAPI) SetPushV20(ctx context.Context, channel int, push Push) error

SetPushV20 sets push notification configuration (v2.0 with enhanced features)

func (*NetworkAPI) SetUpnp

func (n *NetworkAPI) SetUpnp(ctx context.Context, upnp Upnp) error

SetUpnp sets UPnP configuration

func (*NetworkAPI) SetWifi

func (n *NetworkAPI) SetWifi(ctx context.Context, wifi Wifi) error

SetWifi sets WiFi configuration

func (*NetworkAPI) TestEmail

func (n *NetworkAPI) TestEmail(ctx context.Context) error

TestEmail sends a test email

func (*NetworkAPI) TestFtp

func (n *NetworkAPI) TestFtp(ctx context.Context) error

TestFtp tests FTP connection

func (*NetworkAPI) TestWifi

func (n *NetworkAPI) TestWifi(ctx context.Context) error

TestWifi tests WiFi connection

type Ntp

type Ntp struct {
	Enable   int    `json:"enable"`   // 0=disabled, 1=enabled
	Server   string `json:"server"`   // NTP server address
	Port     int    `json:"port"`     // NTP server port (default: 123)
	Interval int    `json:"interval"` // Sync interval in seconds (0=immediate, 10-65535)
}

Ntp represents NTP configuration

type NtpValue

type NtpValue struct {
	Ntp Ntp `json:"Ntp"`
}

NtpValue represents the response value for GetNtp

type OnlineUser

type OnlineUser struct {
	UserName  string `json:"userName"`
	IP        string `json:"ip"`
	LoginTime string `json:"loginTime"`
}

OnlineUser represents an online user session

type OnlineUserList

type OnlineUserList struct {
	Users []OnlineUser `json:"User"`
}

OnlineUserList represents a list of online users

type OnlineValue

type OnlineValue struct {
	Online OnlineUserList `json:"Online"`
}

OnlineValue wraps OnlineUserList for API response

type Option

type Option func(*Client)

Option is a functional option for configuring the Client

func WithCredentials

func WithCredentials(username, password string) Option

WithCredentials sets the username and password for authentication

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets a custom HTTP client

func WithHTTPS

func WithHTTPS(useHTTPS bool) Option

WithHTTPS enables or disables HTTPS

func WithInsecureSkipVerify

func WithInsecureSkipVerify(skip bool) Option

WithInsecureSkipVerify sets whether to skip TLS certificate verification

func WithLogger

func WithLogger(log logger.Logger) Option

WithLogger sets a custom logger for the client

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) Option

WithTLSConfig sets a custom TLS configuration

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the HTTP client timeout

func WithToken

func WithToken(token string) Option

WithToken sets an existing authentication token

type Osd

type Osd struct {
	Channel    int        `json:"channel"`    // Channel number
	BgColor    int        `json:"bgcolor"`    // Background color (0=transparent, 1=black)
	OsdChannel OsdChannel `json:"osdChannel"` // Camera name display settings
	OsdTime    OsdTime    `json:"osdTime"`    // Timestamp display settings
	Watermark  int        `json:"watermark"`  // Watermark enable (0=off, 1=on)
}

Osd represents On-Screen Display configuration

type OsdChannel

type OsdChannel struct {
	Enable int    `json:"enable"` // 0=disabled, 1=enabled
	Name   string `json:"name"`   // Camera name
	Pos    string `json:"pos"`    // Position: "Upper Left", "Upper Right", "Lower Left", "Lower Right", "Top Center", "Bottom Center"
}

OsdChannel represents camera name display settings

type OsdTime

type OsdTime struct {
	Enable int    `json:"enable"` // 0=disabled, 1=enabled
	Pos    string `json:"pos"`    // Position: "Upper Left", "Upper Right", "Lower Left", "Lower Right", "Top Center", "Bottom Center"
}

OsdTime represents timestamp display settings

type OsdValue

type OsdValue struct {
	Osd Osd `json:"Osd"`
}

OsdValue represents the response value for GetOsd

type P2p

type P2p struct {
	Enable int    `json:"enable"` // 0=disabled, 1=enabled
	UID    string `json:"uid"`    // P2P UID
}

P2p represents P2P configuration

type P2pValue

type P2pValue struct {
	P2p P2p `json:"P2p"`
}

P2pValue represents the response value for GetP2p

type PTZAPI

type PTZAPI struct {
	// contains filtered or unexported fields
}

PTZAPI provides access to Pan-Tilt-Zoom control endpoints

func (*PTZAPI) GetAutoFocus

func (p *PTZAPI) GetAutoFocus(ctx context.Context, channel int) (*AutoFocus, error)

GetAutoFocus gets auto focus configuration

func (*PTZAPI) GetPtzCheckState

func (p *PTZAPI) GetPtzCheckState(ctx context.Context, channel int) (*PtzCheckState, error)

GetPtzCheckState gets PTZ calibration check state

func (*PTZAPI) GetPtzGuard

func (p *PTZAPI) GetPtzGuard(ctx context.Context, channel int) (*PtzGuard, error)

GetPtzGuard gets PTZ guard/home position configuration

func (*PTZAPI) GetPtzPatrol

func (p *PTZAPI) GetPtzPatrol(ctx context.Context, channel int) (*PtzPatrol, error)

GetPtzPatrol gets PTZ patrol/tour configuration

func (*PTZAPI) GetPtzPreset

func (p *PTZAPI) GetPtzPreset(ctx context.Context, channel int) ([]PtzPreset, error)

GetPtzPreset gets PTZ preset positions

func (*PTZAPI) GetPtzSerial

func (p *PTZAPI) GetPtzSerial(ctx context.Context, channel int) (*PtzSerial, error)

GetPtzSerial gets PTZ serial port configuration

func (*PTZAPI) GetPtzTattern

func (p *PTZAPI) GetPtzTattern(ctx context.Context, channel int) (*PtzTattern, error)

GetPtzTattern gets PTZ pattern/track configuration

func (*PTZAPI) GetZoomFocus

func (p *PTZAPI) GetZoomFocus(ctx context.Context, channel int) (*ZoomFocus, error)

GetZoomFocus gets current zoom and focus position

func (*PTZAPI) PtzCheck

func (p *PTZAPI) PtzCheck(ctx context.Context, channel int) error

PtzCheck performs PTZ calibration check

func (*PTZAPI) PtzCtrl

func (p *PTZAPI) PtzCtrl(ctx context.Context, param PtzCtrlParam) error

PtzCtrl controls PTZ movement

func (*PTZAPI) SetAutoFocus

func (p *PTZAPI) SetAutoFocus(ctx context.Context, autoFocus AutoFocus) error

SetAutoFocus sets auto focus configuration

func (*PTZAPI) SetPtzGuard

func (p *PTZAPI) SetPtzGuard(ctx context.Context, guard PtzGuard) error

SetPtzGuard sets PTZ guard/home position configuration

func (*PTZAPI) SetPtzPatrol

func (p *PTZAPI) SetPtzPatrol(ctx context.Context, patrol PtzPatrol) error

SetPtzPatrol sets PTZ patrol/tour configuration

func (*PTZAPI) SetPtzPreset

func (p *PTZAPI) SetPtzPreset(ctx context.Context, preset PtzPreset) error

SetPtzPreset sets or calls a PTZ preset position

func (*PTZAPI) SetPtzSerial

func (p *PTZAPI) SetPtzSerial(ctx context.Context, serial PtzSerial) error

SetPtzSerial sets PTZ serial port configuration

func (*PTZAPI) SetPtzTattern

func (p *PTZAPI) SetPtzTattern(ctx context.Context, channel int, tattern PtzTattern) error

SetPtzTattern sets PTZ pattern/track configuration

func (*PTZAPI) StartZoomFocus

func (p *PTZAPI) StartZoomFocus(ctx context.Context, channel int, op string, pos int) error

StartZoomFocus starts zoom or focus operation op: ZoomInc, ZoomDec, FocusInc, FocusDec pos: target position (optional, set to 0 if not used)

type PowerLed

type PowerLed struct {
	State string `json:"state"` // Auto, Off
}

PowerLed represents power LED configuration

type PowerLedParam

type PowerLedParam struct {
	PowerLed struct {
		Channel int    `json:"channel"` // Channel number
		State   string `json:"state"`   // Auto, Off
	} `json:"PowerLed"`
}

PowerLedParam represents parameters for SetPowerLed

type PowerLedValue

type PowerLedValue struct {
	PowerLed PowerLed `json:"PowerLed"`
}

PowerLedValue wraps PowerLed for API response

type PtzCheckState

type PtzCheckState struct {
	Status int `json:"status"` // Check state status (0=idle, 1=checking)
}

PtzCheckState represents PTZ calibration check state

type PtzCtrlParam

type PtzCtrlParam struct {
	Channel int    `json:"channel"`         // Channel number
	Op      string `json:"op"`              // Operation (use PTZOp* constants)
	Speed   int    `json:"speed,omitempty"` // Speed (1-64, optional)
	ID      int    `json:"id,omitempty"`    // Preset/Patrol ID (optional)
}

PtzCtrlParam represents parameters for PtzCtrl command

type PtzGuard

type PtzGuard struct {
	Channel         int    `json:"channel"`         // Channel number
	CmdStr          string `json:"cmdStr"`          // Command string
	BEnable         int    `json:"benable"`         // 0=disabled, 1=enabled
	BExistPos       int    `json:"bexistPos"`       // Whether guard position exists
	Timeout         int    `json:"timeout"`         // Timeout in seconds (typically 60)
	BSaveCurrentPos int    `json:"bSaveCurrentPos"` // 1=save current position as guard
}

PtzGuard represents PTZ guard/home position configuration

type PtzGuardParam

type PtzGuardParam struct {
	PtzGuard PtzGuard `json:"PtzGuard"`
}

PtzGuardParam represents parameters for SetPtzGuard

type PtzGuardValue

type PtzGuardValue struct {
	PtzGuard PtzGuard `json:"PtzGuard"`
}

PtzGuardValue wraps guard for API response

type PtzPatrol

type PtzPatrol struct {
	Channel int               `json:"channel"` // Channel number
	Enable  int               `json:"enable"`  // 0=disabled, 1=enabled
	ID      int               `json:"id"`      // Patrol ID
	Running int               `json:"running"` // 0=stopped, 1=running
	Name    string            `json:"name"`    // Patrol name
	Preset  []PtzPatrolPreset `json:"preset"`  // List of presets (max 16)
}

PtzPatrol represents a PTZ patrol/tour configuration

type PtzPatrolParam

type PtzPatrolParam struct {
	PtzPatrol PtzPatrol `json:"PtzPatrol"`
}

PtzPatrolParam represents parameters for SetPtzPatrol

type PtzPatrolPreset

type PtzPatrolPreset struct {
	ID        int `json:"id"`        // Preset ID (1-64)
	DwellTime int `json:"dwellTime"` // Dwell time at preset (seconds)
	Speed     int `json:"speed"`     // Movement speed
}

PtzPatrolPreset represents a preset in a patrol

type PtzPatrolValue

type PtzPatrolValue struct {
	PtzPatrol PtzPatrol `json:"PtzPatrol"`
}

PtzPatrolValue wraps patrol for API response

type PtzPreset

type PtzPreset struct {
	Enable int    `json:"enable"` // 0=disabled, 1=enabled
	ID     int    `json:"id"`     // Preset ID (1-64)
	Name   string `json:"name"`   // Preset name
}

PtzPreset represents a PTZ preset position

type PtzPresetParam

type PtzPresetParam struct {
	PtzPreset PtzPreset `json:"PtzPreset"`
}

PtzPresetParam represents parameters for SetPtzPreset

type PtzPresetValue

type PtzPresetValue struct {
	PtzPreset []PtzPreset `json:"PtzPreset"`
}

PtzPresetValue wraps preset array for API response

type PtzSerial

type PtzSerial struct {
	Channel      int    `json:"channel"`      // Channel number
	BaudRate     int    `json:"baudRate"`     // Baud rate (1200, 2400, 4800, 9600)
	CtrlAddr     int    `json:"ctrlAddr"`     // Control address (1-64)
	CtrlProtocol string `json:"ctrlProtocol"` // Control protocol (PELCO_D, PELCO_P)
	DataBit      string `json:"dataBit"`      // Data bits (CS5, CS6, CS7, CS8)
	FlowCtrl     string `json:"flowCtrl"`     // Flow control (none, hard, xon, xoff)
	Parity       string `json:"parity"`       // Parity (none, odd, even)
	StopBit      int    `json:"stopBit"`      // Stop bits (1, 2)
}

PtzSerial represents PTZ serial port configuration

type PtzSerialValue

type PtzSerialValue struct {
	PtzSerial PtzSerial `json:"PtzSerial"`
}

PtzSerialValue wraps PtzSerial for API response

type PtzTattern

type PtzTattern struct {
	Enable int `json:"enable"` // 0=disabled, 1=enabled
	ID     int `json:"id"`     // Track ID (1-6)
}

PtzTattern represents PTZ pattern/track configuration Note: API uses "Tattern" (typo) instead of "Pattern"

type PtzTatternValue

type PtzTatternValue struct {
	PtzTattern PtzTattern `json:"PtzTattern"`
}

PtzTatternValue wraps PtzTattern for API response

type Push

type Push struct {
	Schedule PushSchedule `json:"schedule"` // Push schedule
}

Push represents push notification configuration

type PushCfg

type PushCfg struct {
	Enable int    `json:"enable"` // 0=disabled, 1=enabled
	Token  string `json:"token"`  // Push token
}

PushCfg represents push configuration details

type PushCfgValue

type PushCfgValue struct {
	PushCfg PushCfg `json:"PushCfg"`
}

PushCfgValue represents the response value for GetPushCfg

type PushSchedule

type PushSchedule struct {
	Enable int         `json:"enable"` // 0=disabled, 1=enabled
	Table  interface{} `json:"table"`  // string for v1, PushScheduleTable for v2.0
}

PushSchedule represents push schedule configuration

type PushScheduleTable

type PushScheduleTable struct {
	MD        string `json:"MD,omitempty"`         // Motion detection schedule
	TIMING    string `json:"TIMING,omitempty"`     // Timing schedule
	AIPeople  string `json:"AI_PEOPLE,omitempty"`  // AI people detection schedule
	AIVehicle string `json:"AI_VEHICLE,omitempty"` // AI vehicle detection schedule
	AIDogCat  string `json:"AI_DOG_CAT,omitempty"` // AI dog/cat detection schedule
}

PushScheduleTable represents v2.0 push schedule with multiple alarm types

type PushValue

type PushValue struct {
	Push Push `json:"Push"`
}

PushValue represents the response value for GetPush

type Rec

type Rec struct {
	Channel   int         `json:"channel"`
	Overwrite int         `json:"overwrite"`         // 0=stop when full, 1=overwrite oldest
	PostRec   string      `json:"postRec"`           // Post-recording duration: "30 Seconds", "1 Minute", etc.
	PreRec    int         `json:"preRec"`            // Pre-recording: 0=off, 1=on
	SaveDay   int         `json:"saveDay,omitempty"` // Days to keep recordings (v2.0 only)
	Schedule  RecSchedule `json:"schedule"`
}

Rec represents recording configuration

type RecSchedule

type RecSchedule struct {
	Enable  int         `json:"enable"`            // 0=disabled, 1=enabled
	Channel int         `json:"channel,omitempty"` // Channel number (v2.0 only)
	Table   interface{} `json:"table"`             // string for v1, RecScheduleTable for v2.0
}

RecSchedule represents recording schedule configuration

type RecScheduleTable

type RecScheduleTable struct {
	MD        string `json:"MD,omitempty"`         // Motion detection schedule (168 chars)
	TIMING    string `json:"TIMING,omitempty"`     // Timing schedule (168 chars)
	AIPeople  string `json:"AI_PEOPLE,omitempty"`  // AI people detection schedule (168 chars)
	AIVehicle string `json:"AI_VEHICLE,omitempty"` // AI vehicle detection schedule (168 chars)
	AIDogCat  string `json:"AI_DOG_CAT,omitempty"` // AI dog/cat detection schedule (168 chars)
}

RecScheduleTable represents v2.0 schedule with multiple alarm types

type RecValue

type RecValue struct {
	Rec Rec `json:"Rec"`
}

RecValue represents the response value for GetRec/GetRecV20

type RecordingAPI

type RecordingAPI struct {
	// contains filtered or unexported fields
}

RecordingAPI provides methods for recording configuration and playback

func (*RecordingAPI) Download

func (r *RecordingAPI) Download(source, output string) string

Download downloads a recording file Returns the URL to download the file via GET request

func (*RecordingAPI) GetRec

func (r *RecordingAPI) GetRec(ctx context.Context, channel int) (*Rec, error)

GetRec gets recording configuration (v1.0)

func (*RecordingAPI) GetRecV20

func (r *RecordingAPI) GetRecV20(ctx context.Context, channel int) (*Rec, error)

GetRecV20 gets recording configuration (v2.0 with enhanced features)

func (*RecordingAPI) NvrDownload

func (r *RecordingAPI) NvrDownload(ctx context.Context, params map[string]interface{}) error

NvrDownload downloads a recording from NVR This is a placeholder - actual implementation depends on NVR-specific parameters

func (*RecordingAPI) Playback

func (r *RecordingAPI) Playback(source, output string) string

Playback returns the URL for streaming playback of a recording

func (*RecordingAPI) Search

func (r *RecordingAPI) Search(ctx context.Context, channel int, startTime, endTime time.Time, streamType string) ([]SearchResult, error)

Search searches for recordings by time range

func (*RecordingAPI) SetRec

func (r *RecordingAPI) SetRec(ctx context.Context, rec Rec) error

SetRec sets recording configuration (v1.0)

func (*RecordingAPI) SetRecV20

func (r *RecordingAPI) SetRecV20(ctx context.Context, rec Rec) error

SetRecV20 sets recording configuration (v2.0 with enhanced features)

type Request

type Request struct {
	Cmd    string      `json:"cmd"`              // Command name
	Action int         `json:"action,omitempty"` // 0: get value only, 1: get initial, range, and value
	Param  interface{} `json:"param,omitempty"`  // Command-specific parameters
	Token  string      `json:"token,omitempty"`  // Authentication token (added by client)
}

Request represents a single API request command

type Response

type Response struct {
	Cmd     string          `json:"cmd"`               // Command name
	Code    int             `json:"code"`              // Response code (0 = success)
	Value   json.RawMessage `json:"value,omitempty"`   // Response data (present when code = 0)
	Error   *ErrorDetail    `json:"error,omitempty"`   // Error details (present when error occurs)
	Initial json.RawMessage `json:"initial,omitempty"` // Initial/default values (when action = 1)
	Range   json.RawMessage `json:"range,omitempty"`   // Valid ranges/options (when action = 1)
}

Response represents a single API response

func (*Response) ToAPIError

func (r *Response) ToAPIError() *APIError

ToAPIError converts a Response to an APIError if it contains an error

type RtspUrl

type RtspUrl struct {
	Channel    int    `json:"channel"`    // Channel number
	MainStream string `json:"mainStream"` // RTSP URL for main stream
	SubStream  string `json:"subStream"`  // RTSP URL for sub stream
}

RtspUrl represents RTSP URL information

type RtspUrlValue

type RtspUrlValue struct {
	RtspUrl RtspUrl `json:"rtspUrl"`
}

RtspUrlValue represents the response value for GetRtspUrl

type Schedule

type Schedule struct {
	Enable int        `json:"enable"`
	Table  [][]string `json:"table"` // 7x48 array representing week schedule
}

Schedule represents a time schedule configuration

type Scope

type Scope struct {
	Area string `json:"area"` // Detection grid (width × height characters)
}

Scope represents detection scope/area

type SearchCriteria

type SearchCriteria struct {
	Channel    int       `json:"channel"`
	OnlyStatus int       `json:"onlyStatus"` // 0=main stream, 1=sub stream
	StartTime  time.Time `json:"startTime"`
	EndTime    time.Time `json:"endTime"`
	StreamType string    `json:"streamType,omitempty"` // "main" or "sub"
}

SearchCriteria represents search criteria for recordings

type SearchParam

type SearchParam struct {
	Search SearchCriteria `json:"Search"`
}

SearchParam represents parameters for searching recordings

type SearchResult

type SearchResult struct {
	Channel   int       `json:"channel"`
	FileName  string    `json:"fileName"`
	FileSize  int64     `json:"fileSize"`
	StartTime time.Time `json:"startTime"`
	EndTime   time.Time `json:"endTime"`
	Type      string    `json:"type"` // "MD", "TIMING", "AI_PEOPLE", etc.
}

SearchResult represents a search result

type SearchValue

type SearchValue struct {
	SearchResult []SearchResult `json:"SearchResult"`
}

SearchValue represents the response value for Search

type SecurityAPI

type SecurityAPI struct {
	// contains filtered or unexported fields
}

SecurityAPI provides access to security and user management API endpoints

func (*SecurityAPI) AddUser

func (s *SecurityAPI) AddUser(ctx context.Context, user User) error

AddUser adds a new user

func (*SecurityAPI) CertificateClear

func (s *SecurityAPI) CertificateClear(ctx context.Context) error

CertificateClear clears SSL certificate

func (*SecurityAPI) DeleteUser

func (s *SecurityAPI) DeleteUser(ctx context.Context, username string) error

DeleteUser deletes a user

func (*SecurityAPI) DisconnectUser

func (s *SecurityAPI) DisconnectUser(ctx context.Context, username string) error

DisconnectUser disconnects a user session

func (*SecurityAPI) GetCertificateInfo

func (s *SecurityAPI) GetCertificateInfo(ctx context.Context) (*CertificateInfo, error)

GetCertificateInfo gets SSL certificate information

func (*SecurityAPI) GetOnlineUsers

func (s *SecurityAPI) GetOnlineUsers(ctx context.Context) ([]OnlineUser, error)

GetOnlineUsers retrieves the list of currently online users

func (*SecurityAPI) GetSysCfg

func (s *SecurityAPI) GetSysCfg(ctx context.Context, channel int) (map[string]interface{}, error)

GetSysCfg exports system configuration

func (*SecurityAPI) GetUsers

func (s *SecurityAPI) GetUsers(ctx context.Context) ([]User, error)

GetUsers retrieves the list of users

func (*SecurityAPI) ModifyUser

func (s *SecurityAPI) ModifyUser(ctx context.Context, user User) error

ModifyUser modifies an existing user

func (*SecurityAPI) SetSysCfg

func (s *SecurityAPI) SetSysCfg(ctx context.Context, config map[string]interface{}) error

SetSysCfg imports system configuration

type StaticIP

type StaticIP struct {
	IP      string `json:"ip"`      // IP address
	Mask    string `json:"mask"`    // Subnet mask
	Gateway string `json:"gateway"` // Gateway address
}

StaticIP represents static IP configuration

type Stitch

type Stitch struct {
	Distance    float64 `json:"distance"`    // Distance between images (2.0-20.0)
	StitchXMove int     `json:"stitchXMove"` // Adjust pixels horizontally (-100 to 100)
	StitchYMove int     `json:"stitchYMove"` // Adjust pixels vertically (-100 to 100)
}

Stitch represents video stitching configuration for multi-lens cameras

type StitchValue

type StitchValue struct {
	Stitch Stitch `json:"stitch"`
}

StitchValue represents the response value for GetStitch

type Stream

type Stream struct {
	VType     string `json:"vType"`     // Video codec: "h264" or "h265"
	Size      string `json:"size"`      // Resolution: "2560*1440", "1920*1080", etc.
	FrameRate int    `json:"frameRate"` // Frames per second
	BitRate   int    `json:"bitRate"`   // Bitrate in kbps
	GOP       int    `json:"gop"`       // Group of pictures
	Height    int    `json:"height"`    // Video height in pixels
	Width     int    `json:"width"`     // Video width in pixels
	Profile   string `json:"profile"`   // H.264/H.265 profile (Base, Main, High)
}

Stream represents individual stream settings

type StreamConfig

type StreamConfig struct {
	Channel    int    `json:"channel"`
	MainStream Stream `json:"mainStream"`
	SubStream  Stream `json:"subStream"`
}

StreamConfig represents video stream configuration

type StreamType

type StreamType string

StreamType represents video stream type

const (
	StreamMain StreamType = "main" // Main stream (high quality)
	StreamSub  StreamType = "sub"  // Sub stream (low quality)
	StreamExt  StreamType = "ext"  // External stream
)

type StreamingAPI

type StreamingAPI struct {
	// contains filtered or unexported fields
}

StreamingAPI provides helpers for generating streaming URLs

func (*StreamingAPI) GetFLVURL

func (s *StreamingAPI) GetFLVURL(streamType StreamType, channelID int) string

GetFLVURL generates an FLV URL for the specified stream type and channel

Channel IDs start from 0 for FLV URLs (e.g., 0, 1, 2) Only H.264 encoding is supported for FLV

Example:

url := client.Streaming.GetFLVURL(reolink.StreamMain, 0)
// https://192.168.1.100/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=password

func (*StreamingAPI) GetRTMPURL

func (s *StreamingAPI) GetRTMPURL(streamType StreamType, channelID int) string

GetRTMPURL generates an RTMP URL for the specified stream type and channel

Channel IDs start from 0 for RTMP URLs (e.g., 0, 1, 2) Only H.264 encoding is supported for RTMP

Example:

url := client.Streaming.GetRTMPURL(reolink.StreamMain, 0)
// rtmp://192.168.1.100/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=password

func (*StreamingAPI) GetRTSPURL

func (s *StreamingAPI) GetRTSPURL(streamType StreamType, channel int) string

GetRTSPURL generates an RTSP URL for the specified stream type and channel

The channel parameter is 0-based (e.g., 0, 1, 2) and will be converted to the 1-based channel numbers used in RTSP URLs (e.g., 01, 02, 03).

Example:

url := client.Streaming.GetRTSPURL(reolink.StreamMain, 0)
// rtsp://admin:password@192.168.1.100:554/Preview_01_main

type SysCfg

type SysCfg struct {
	LockTime     int `json:"LockTime"`     // Login lock time in seconds (0-300)
	AllowedTimes int `json:"allowedTimes"` // Maximum login attempts (0-5)
	LoginLock    int `json:"loginLock"`    // 0=disabled, 1=enabled
}

SysCfg represents system configuration (login lock settings)

type SysCfgValue

type SysCfgValue struct {
	SysCfg SysCfg `json:"SysCfg"`
}

SysCfgValue wraps SysCfg for API response

type SystemAPI

type SystemAPI struct {
	// contains filtered or unexported fields
}

SystemAPI provides access to system-related API endpoints

func (*SystemAPI) CheckFirmware

func (s *SystemAPI) CheckFirmware(ctx context.Context) (*FirmwareCheck, error)

CheckFirmware checks for new firmware online

func (*SystemAPI) Format

func (s *SystemAPI) Format(ctx context.Context, hddID int) error

Format formats a storage device

func (*SystemAPI) GetAbility

func (s *SystemAPI) GetAbility(ctx context.Context) (*Ability, error)

GetAbility retrieves system capabilities

func (*SystemAPI) GetAutoMaint

func (s *SystemAPI) GetAutoMaint(ctx context.Context) (*AutoMaint, error)

GetAutoMaint gets automatic maintenance configuration

func (*SystemAPI) GetAutoUpgrade

func (s *SystemAPI) GetAutoUpgrade(ctx context.Context) (*AutoUpgrade, error)

GetAutoUpgrade gets automatic upgrade configuration

func (*SystemAPI) GetChannelStatus

func (s *SystemAPI) GetChannelStatus(ctx context.Context) (*ChannelStatusValue, error)

GetChannelStatus gets status of all channels (for NVR)

func (*SystemAPI) GetDeviceInfo

func (s *SystemAPI) GetDeviceInfo(ctx context.Context) (*DeviceInfo, error)

GetDeviceInfo retrieves device information including model, firmware version, hardware version, and capabilities.

This is typically one of the first calls made after authentication to determine what features the camera supports.

Example:

info, err := client.System.GetDeviceInfo(ctx)
if err != nil {
    return err
}
fmt.Printf("Model: %s, Firmware: %s\n", info.Model, info.FirmVer)

Returns an error if the request fails or if the camera returns an error code.

func (*SystemAPI) GetDeviceName

func (s *SystemAPI) GetDeviceName(ctx context.Context) (string, error)

GetDeviceName retrieves the device name

func (*SystemAPI) GetHddInfo

func (s *SystemAPI) GetHddInfo(ctx context.Context) ([]HddInfo, error)

GetHddInfo retrieves hard disk information

func (*SystemAPI) GetSysCfg

func (s *SystemAPI) GetSysCfg(ctx context.Context) (*SysCfg, error)

GetSysCfg gets system configuration (login lock settings)

func (*SystemAPI) GetTime

func (s *SystemAPI) GetTime(ctx context.Context) (*TimeConfig, error)

GetTime retrieves the current time configuration

func (*SystemAPI) Reboot

func (s *SystemAPI) Reboot(ctx context.Context) error

Reboot reboots the device

func (*SystemAPI) Restore

func (s *SystemAPI) Restore(ctx context.Context) error

Restore restores factory default settings

func (*SystemAPI) SetAutoMaint

func (s *SystemAPI) SetAutoMaint(ctx context.Context, config AutoMaint) error

SetAutoMaint sets automatic maintenance configuration

func (*SystemAPI) SetAutoUpgrade

func (s *SystemAPI) SetAutoUpgrade(ctx context.Context, enable bool) error

SetAutoUpgrade sets automatic upgrade configuration

func (*SystemAPI) SetDeviceName

func (s *SystemAPI) SetDeviceName(ctx context.Context, name string) error

SetDeviceName sets the device name

func (*SystemAPI) SetSysCfg

func (s *SystemAPI) SetSysCfg(ctx context.Context, cfg SysCfg) error

SetSysCfg sets system configuration (login lock settings)

func (*SystemAPI) SetTime

func (s *SystemAPI) SetTime(ctx context.Context, timeConfig *TimeConfig) error

SetTime sets the time configuration

func (*SystemAPI) Upgrade

func (s *SystemAPI) Upgrade(ctx context.Context, firmware []byte) error

Upgrade uploads and installs firmware upgrade Note: This command can only carry up to 40K packets at a time. It needs to be called several times to complete the device update for larger firmware files. The firmware parameter should be the raw firmware file bytes (.pak file)

func (*SystemAPI) UpgradeOnline

func (s *SystemAPI) UpgradeOnline(ctx context.Context) error

UpgradeOnline starts online firmware upgrade

func (*SystemAPI) UpgradePrepare

func (s *SystemAPI) UpgradePrepare(ctx context.Context, restoreCfg bool, fileName string) error

UpgradePrepare prepares device for firmware upgrade restoreCfg: whether to restore configuration (false=keep config, true=reset to defaults) fileName: firmware file name (e.g., "firmware.pak")

func (*SystemAPI) UpgradeStatus

func (s *SystemAPI) UpgradeStatus(ctx context.Context) (*UpgradeStatusInfo, error)

UpgradeStatus gets current firmware upgrade status

type TimeConfig

type TimeConfig struct {
	Year       int    `json:"year"`
	Mon        int    `json:"mon"`
	Day        int    `json:"day"`
	Hour       int    `json:"hour"`
	Min        int    `json:"min"`
	Sec        int    `json:"sec"`
	TimeZone   int    `json:"timeZone"`
	TimeFormat string `json:"timeFormat,omitempty"` // "DD/MM/YYYY" or "MM/DD/YYYY" or "YYYY/MM/DD"
}

TimeConfig represents time configuration

type TimeParam

type TimeParam struct {
	Time TimeConfig `json:"Time"`
}

TimeParam represents parameters for SetTime

type TimeValue

type TimeValue struct {
	Time TimeConfig `json:"Time"`
}

TimeValue wraps TimeConfig for API response

type TokenInfo

type TokenInfo struct {
	Name      string `json:"name"`      // Token value
	LeaseTime int    `json:"leaseTime"` // Token validity duration in seconds
}

TokenInfo represents authentication token information

type UpgradeStatusInfo

type UpgradeStatusInfo struct {
	Percent int `json:"Persent"` // Note: API uses "Persent" (typo in API)
	Code    int `json:"code"`    // Status code
}

UpgradeStatusInfo represents upgrade status information

type UpgradeStatusValue

type UpgradeStatusValue struct {
	Status UpgradeStatusInfo `json:"Status"`
}

UpgradeStatusValue wraps UpgradeStatusInfo for API response

type Upnp

type Upnp struct {
	Enable int `json:"enable"` // 0=disabled, 1=enabled
}

Upnp represents UPnP configuration

type UpnpValue

type UpnpValue struct {
	Upnp Upnp `json:"Upnp"`
}

UpnpValue represents the response value for GetUpnp

type User

type User struct {
	UserName string `json:"userName"`
	Password string `json:"password,omitempty"`
	Level    string `json:"level"` // "admin" or "guest"
}

User represents a user account

type UserValue

type UserValue struct {
	User []User `json:"User"`
}

UserValue wraps user array for API response

type VideoAPI

type VideoAPI struct {
	// contains filtered or unexported fields
}

VideoAPI provides access to video input and encoding API endpoints

func (*VideoAPI) GetCrop

func (v *VideoAPI) GetCrop(ctx context.Context, channel int) (*Crop, error)

GetCrop gets video crop/zoom configuration

func (*VideoAPI) GetImage

func (v *VideoAPI) GetImage(ctx context.Context, channel int) (*Image, error)

GetImage gets image quality settings

func (*VideoAPI) GetIsp

func (v *VideoAPI) GetIsp(ctx context.Context, channel int) (*Isp, error)

GetIsp gets Image Signal Processor settings

func (*VideoAPI) GetMask

func (v *VideoAPI) GetMask(ctx context.Context, channel int) (*Mask, error)

GetMask gets privacy mask configuration

func (*VideoAPI) GetOsd

func (v *VideoAPI) GetOsd(ctx context.Context, channel int) (*Osd, error)

GetOsd gets On-Screen Display configuration

func (*VideoAPI) GetStitch

func (v *VideoAPI) GetStitch(ctx context.Context) (*Stitch, error)

GetStitch gets video stitching configuration (for multi-lens cameras)

func (*VideoAPI) SetCrop

func (v *VideoAPI) SetCrop(ctx context.Context, crop Crop) error

SetCrop sets video crop/zoom configuration

func (*VideoAPI) SetImage

func (v *VideoAPI) SetImage(ctx context.Context, image Image) error

SetImage sets image quality settings

func (*VideoAPI) SetIsp

func (v *VideoAPI) SetIsp(ctx context.Context, isp Isp) error

SetIsp sets Image Signal Processor settings

func (*VideoAPI) SetMask

func (v *VideoAPI) SetMask(ctx context.Context, mask Mask) error

SetMask sets privacy mask configuration

func (*VideoAPI) SetOsd

func (v *VideoAPI) SetOsd(ctx context.Context, osd Osd) error

SetOsd sets On-Screen Display configuration

func (*VideoAPI) SetStitch

func (v *VideoAPI) SetStitch(ctx context.Context, stitch Stitch) error

SetStitch sets video stitching configuration (for multi-lens cameras)

type WhiteLed

type WhiteLed struct {
	Channel          int              `json:"channel"`          // Channel number
	State            int              `json:"state"`            // 0=off, 1=on
	Mode             int              `json:"mode"`             // 0=always on, 1=alarm trigger, 2=auto with AI
	Bright           int              `json:"bright"`           // Brightness (0-100)
	LightingSchedule WhiteLedSchedule `json:"LightingSchedule"` // Schedule for mode 2
	WlAiDetectType   WhiteLedAiDetect `json:"wlAiDetectType"`   // AI detection types
}

WhiteLed represents white LED configuration

type WhiteLedAiDetect

type WhiteLedAiDetect struct {
	People  int `json:"people"`  // 0=disabled, 1=enabled
	Vehicle int `json:"vehicle"` // 0=disabled, 1=enabled
	DogCat  int `json:"dog_cat"` // 0=disabled, 1=enabled
	Face    int `json:"face"`    // 0=disabled, 1=enabled
}

WhiteLedAiDetect represents AI detection types for white LED

type WhiteLedParam

type WhiteLedParam struct {
	WhiteLed WhiteLed `json:"WhiteLed"`
}

WhiteLedParam represents parameters for SetWhiteLed

type WhiteLedSchedule

type WhiteLedSchedule struct {
	StartHour int `json:"StartHour"` // Start hour (0-23)
	StartMin  int `json:"StartMin"`  // Start minute (0-59)
	EndHour   int `json:"EndHour"`   // End hour (0-23)
	EndMin    int `json:"EndMin"`    // End minute (0-59)
}

WhiteLedSchedule represents lighting schedule

type WhiteLedValue

type WhiteLedValue struct {
	WhiteLed WhiteLed `json:"WhiteLed"`
}

WhiteLedValue wraps WhiteLed for API response

type Wifi

type Wifi struct {
	SSID     string `json:"ssid"`     // WiFi network name
	Password string `json:"password"` // WiFi password
}

Wifi represents WiFi configuration

type WifiNetwork

type WifiNetwork struct {
	SSID    string `json:"ssid"`    // Network name
	Signal  int    `json:"signal"`  // Signal strength
	Encrypt int    `json:"encrypt"` // Encryption type
}

WifiNetwork represents a WiFi network from scan results

type WifiSignal

type WifiSignal struct {
	Signal int `json:"signal"` // Signal strength (0-100)
}

WifiSignal represents WiFi signal strength

type WifiValue

type WifiValue struct {
	Wifi Wifi `json:"Wifi"`
}

WifiValue represents the response value for GetWifi

type ZoomFocus

type ZoomFocus struct {
	Channel int `json:"channel"` // Channel number
	Zoom    struct {
		Pos int `json:"pos"` // Zoom position
	} `json:"zoom"`
	Focus struct {
		Pos int `json:"pos"` // Focus position
	} `json:"focus"`
}

ZoomFocus represents zoom and focus position

type ZoomFocusValue

type ZoomFocusValue struct {
	ZoomFocus ZoomFocus `json:"ZoomFocus"`
}

ZoomFocusValue wraps ZoomFocus for API response

Directories

Path Synopsis
api
examples
basic command
debug_test command
hardware_test command
pkg
sdk
go/reolink module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL