A generated Onvif client in Go. Contains a simple command line utility to send Onvif commands/queries to an Onvif compatible device. This also serves as an example of how to use the generated client programatically.
Get the built gonvif
binary for your system and architecture from our
Release page.
Then run a command of your choice from one of the supported Onvif ports, e.g., listing all device
profiles using the media
port, providing the Onvif device URL and credentials:
gonvif -a http://IP[:PORT] -u USERNAME -p PASSWORD media get-profiles
Get the shell completion script by running the following, using one of bash
, zsh
, fish
,
powershell
:
gonvif completion bash
import (
"log"
"github.com/eyetowers/gonvif/pkg/gonvif"
)
func main() {
// Connect to the Onvif device.
client, err := gonvif.New("http://IP[:PORT]", "USERNAME", "PASSWORD")
if err != nil {
log.Fatal(err)
}
// Get the Media2 service client.
media, err := client.Media2()
if err != nil {
log.Fatal(err)
}
// Make a request.
resp, err := media.GetProfiles(&wsdl.GetProfiles{
Type: []string{"All"},
})
if err != nil {
log.Fatal(err)
}
// Process the response.
log.Printf("Got profiles: %v", resp)
}
Gonvif is used in the eyetowers/Ginvif JSON to Onvif HTTP server adapter.
Gonvif is open source, released under the MIT license.