This directory contains example programs demonstrating how to use the Reolink Go SDK.
- Go 1.19 or later installed
- A Reolink camera on your network
- Camera credentials (username and password)
Purpose: Demonstrates basic SDK usage - login, get device info, logout.
What it does:
- Connects to a Reolink camera
- Authenticates and obtains a token
- Retrieves device information
- Gets device name and time configuration
- Properly logs out
Run it:
cd basic
export REOLINK_HOST=192.168.1.100
export REOLINK_USERNAME=admin
export REOLINK_PASSWORD=yourpassword
go run main.goExpected output:
Logging in...
Logged in successfully. Token: abc123...
Device Information:
Model: RLC-810A
Firmware: v3.0.0.136_20121100
Hardware: IPC_51516M5M
...
Purpose: Comprehensive integration testing against real Reolink hardware.
What it does:
- Tests all major API modules
- Validates System, Security, Network, Video, PTZ, Alarm, LED, AI APIs
- Reports success/failure for each endpoint
- Useful for validating SDK against your specific camera model
Run it:
cd hardware_test
export REOLINK_HOST=192.168.1.100
export REOLINK_USERNAME=admin
export REOLINK_PASSWORD=yourpassword
go run main.goUse cases:
- Validate SDK compatibility with your camera model
- Test which features your camera supports
- Debug API issues
- Verify firmware compatibility
Purpose: Low-level debugging tool for troubleshooting API issues.
What it does:
- Makes direct HTTP requests to the camera
- Compares SDK behavior with raw HTTP requests
- Useful for debugging authentication or API issues
Run it:
cd debug_test
# Edit main.go to set your camera IP and credentials
go run main.goWhen to use:
- Troubleshooting login issues
- Debugging API request/response format
- Comparing SDK behavior with direct HTTP calls
- Investigating camera-specific quirks
All examples support environment variables for configuration:
# Required
export REOLINK_HOST=192.168.1.100 # Camera IP address
export REOLINK_USERNAME=admin # Camera username
export REOLINK_PASSWORD=yourpassword # Camera password
# Optional
export REOLINK_HTTPS=true # Use HTTPS (default: false)
export REOLINK_SKIP_VERIFY=true # Skip TLS verification (default: false)Alternatively, you can hardcode values in the example files (not recommended for production).
Each example can be built into a standalone binary:
# Build basic example
cd basic
go build -o basic main.go
./basic
# Build hardware test
cd hardware_test
go build -o hardware_test main.go
./hardware_testSee basic/main.go for a complete example:
info, err := client.System.GetDeviceInfo(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Model: %s, Firmware: %s\n", info.Model, info.FirmVer)// Move camera right
err := client.PTZ.StartPTZ(ctx, 0, "Right", 32)
if err != nil {
log.Fatal(err)
}
// Stop movement after 2 seconds
time.Sleep(2 * time.Second)
err = client.PTZ.StopPTZ(ctx, 0)// Get RTSP URL for main stream
rtspURL := client.Streaming.GetRTSPURL(reolink.StreamMain, 0)
fmt.Printf("RTSP URL: %s\n", rtspURL)
// Output: rtsp://admin:password@192.168.1.100:554/Preview_01_main
// Get RTMP URL for sub stream
rtmpURL := client.Streaming.GetRTMPURL(reolink.StreamSub, 0)
fmt.Printf("RTMP URL: %s\n", rtmpURL)// Get current motion detection config
md, err := client.Alarm.GetMd(ctx, 0)
if err != nil {
log.Fatal(err)
}
// Enable motion detection
md.Enable = 1
md.Sensitivity = 50
// Update configuration
err = client.Alarm.SetMd(ctx, 0, md)
if err != nil {
log.Fatal(err)
}// Get all users
users, err := client.Security.GetUsers(ctx)
if err != nil {
log.Fatal(err)
}
// Add a new user
err = client.Security.AddUser(ctx, reolink.User{
UserName: "guest",
Password: "guestpass",
Level: "guest",
})Problem: connection refused or timeout
Solutions:
- Verify camera IP address is correct
- Ensure camera is on the same network
- Check firewall settings
- Try pinging the camera:
ping 192.168.1.100
Problem: login failed or invalid credentials
Solutions:
- Verify username and password are correct
- Check if camera account is locked (too many failed attempts)
- Try logging in via web interface first
- Use
debug_testexample to see raw API responses
Problem: x509: certificate signed by unknown authority
Solutions:
- Use
WithInsecureSkipVerify(true)for self-signed certificates - Or install the camera's certificate in your system trust store
- For production, use proper TLS certificates
client := reolink.NewClient(host,
reolink.WithCredentials(username, password),
reolink.WithHTTPS(true),
reolink.WithInsecureSkipVerify(true), // Only for testing!
)Problem: API returns error or unexpected response
Solutions:
- Check if your camera model supports the feature
- Verify firmware version compatibility
- Run
hardware_testto see which APIs your camera supports
To create a new example:
- Create a new directory:
mkdir my_example - Create
main.gowith your code - Add module dependency:
import "github.com/mosleyit/reolink_api_wrapper"
- Build and run:
cd my_example go mod init my_example go mod edit -replace github.com/mosleyit/reolink_api_wrapper=../.. go mod tidy go run main.go
- Main README - SDK overview and features
- pkg.go.dev - Complete API reference
- GitHub Pages Docs - Documentation hub
- OpenAPI Spec - Complete API specification
If you encounter issues:
- Check the Troubleshooting section above
- Run the
debug_testexample to see raw API behavior - Open an issue: https://github.com/mosleyit/reolink_api_wrapper/issues
These examples are provided as-is for demonstration purposes. Use at your own risk.