go-ring

module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0

README

go-ring

Go version CI Replay coverage Release Go Reference License Documentation

A Go client for Ring authentication, device discovery and controls, recordings, notifications, and live sessions. Ring behavior can vary by account, device, and region.

Requires Go 1.24 or later.

go get github.com/portpowered/go-ring@latest

Authenticate

Create a login session, request a verification code, and complete the exchange. The caller supplies the current access token with each account request.

client, err := ring.NewClient()
if err != nil {
    return err
}
login, err := client.NewLoginSession(ring.LoginSessionRequest{
    Username: username,
    Password: password,
})
if err != nil {
    return err
}
defer login.Close()

if err := login.Request2FACode(ctx); err != nil {
    return err
}
tokens, err := login.Authenticate(ctx, ring.CompleteLoginRequest{
    OTPCode: os.Getenv("RING_OTP_CODE"),
})
if err != nil {
    return err
}
auth := ring.AuthContext{
    AccessToken: tokens.AccessToken,
    HardwareID:  login.HardwareID(),
}

See the authentication guide for token refresh and secure token storage.

List devices

Use the same authentication context for device requests.

devices, err := client.ListDevices(ctx, ring.ListDevicesRequest{Auth: auth})
if err != nil {
    return err
}
for _, device := range devices.Devices {
    fmt.Printf("%s: %s (%s)\n", device.ID, device.Name, device.Kind)
}

The device operations guide covers controls, capabilities, and device-specific behavior.

Open a live session

Create a WebRTC offer with your peer connection, then pass it to the client. The returned answer belongs to that same peer. Close the session and signaling connection when finished.

conn, err := client.OpenSignaling(ctx, ring.OpenSignalingRequest{Auth: auth})
if err != nil {
    return err
}
defer conn.Close()

session, err := conn.StartDeviceSession(ctx, ring.StartDeviceSessionRequest{
    DeviceID:     deviceID,
    Offer:        ring.SessionDescription{Type: ring.SDPTypeOffer, SDP: offer.SDP},
    VideoEnabled: true,
    ICEMode:      ring.ICENonTrickle,
})
if err != nil {
    return err
}
defer session.Close()

answer := session.Answer()
if err := peer.SetRemoteDescription(webrtc.SessionDescription{
    Type: webrtc.SDPTypeAnswer,
    SDP:  answer.SDP,
}); err != nil {
    return err
}

See the live sessions guide for complete WebRTC and ICE setup, and the PTZ example for camera movement and stop commands.

More examples

Workflow Runnable example
Authenticate and save tokens token-exchange
List devices enumerate-devices
Reboot a device reboot-device
Play a chime test sound chime-sound
Stream live video rtc_stream
Control PTZ rtc_ptz
Receive push events session_push_events
Download recordings download-recordings

Documentation

Issues and license

Please open an issue for a reproducible bug or unsupported device behavior. go-ring is licensed under Apache-2.0; see LICENSE.

Directories

Path Synopsis
cmd
go-ring module
examples
chime-sound command
Example chime-sound plays the ding test sound on an explicitly selected chime.
Example chime-sound plays the ding test sound on an explicitly selected chime.
internal/exampleerrors
Package exampleerrors adds operation context to example command errors.
Package exampleerrors adds operation context to example command errors.
quickstart command
reboot-device command
Example reboot-device sends the recorded reboot command to one device.
Example reboot-device sends the recorded reboot command to one device.
rtc_ptz command
Example rtc_ptz opens a live camera session, pans right briefly, and stops.
Example rtc_ptz opens a live camera session, pans right briefly, and stops.
rtc_stream command
Example rtc_stream generates a local Pion SDP offer and keeps Ring's signaling session alive.
Example rtc_stream generates a local Pion SDP offer and keeps Ring's signaling session alive.
session_push_events command
Example session_push_events subscribes to device push notifications.
Example session_push_events subscribes to device push notifications.
token-exchange command
internal
generatedfcm
Package generatedfcm provides primitives to interact with the openapi HTTP API.
Package generatedfcm provides primitives to interact with the openapi HTTP API.
generatedhttp
Package generatedhttp provides primitives to interact with the openapi HTTP API.
Package generatedhttp provides primitives to interact with the openapi HTTP API.
testkit/replay
Package replay provides strict, local-only transports for deterministic tests.
Package replay provides strict, local-only transports for deterministic tests.
pkg
dependencies/push
Package push adapts the long-lived FCM connection to Ring's account-scoped API.
Package push adapts the long-lived FCM connection to Ring's account-scoped API.
dependencies/rest
Package rest provides a REST API client for interacting with Ring services.
Package rest provides a REST API client for interacting with Ring services.
dependencies/webrtc
Package webrtc validates captured SDP and ICE media identities.
Package webrtc validates captured SDP and ICE media identities.
dependencymodels/fcm
Package fcm provides primitives to interact with the openapi HTTP API.
Package fcm provides primitives to interact with the openapi HTTP API.
generatedhttp
Package generatedhttp provides primitives to interact with the openapi HTTP API.
Package generatedhttp provides primitives to interact with the openapi HTTP API.
ring
Package ring provides the main client for interacting with Ring services.
Package ring provides the main client for interacting with Ring services.
ringapimodels
Package ringapimodels provides primitives to interact with the openapi HTTP API.
Package ringapimodels provides primitives to interact with the openapi HTTP API.
ringtypes
Package ringtypes contains schema-backed scalar types shared by the public API projections and generated provider models.
Package ringtypes contains schema-backed scalar types shared by the public API projections and generated provider models.
third_party
go-push-receiver
Package pushreceiver is Push Message Receiver library from FCM.
Package pushreceiver is Push Message Receiver library from FCM.
tools
capture command
compatibility command
Command compatibility checks the supported Go API against a Git baseline.
Command compatibility checks the supported Go API against a Git baseline.
coverage command
Command coverage measures maintained library code by the test suite that exercises it.
Command coverage measures maintained library code by the test suite that exercises it.
restmodelsplit command
routegate/cmd command
schemaexamples command
Package main validates examples against the schema declarations in a repository.
Package main validates examples against the schema declarations in a repository.
schemalinks command
Package main checks schema links against a rendered documentation site.
Package main checks schema links against a rendered documentation site.

Jump to

Keyboard shortcuts

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