Skip to content
portpoweredPublic

About

Golang library for Ring Doorbell devices:- auth, video streams, controls

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

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

To use Ring cameras and doorbells from ChatGPT, Claude or another AI assistant without writing code, see Ring MCP in Port OS Smart Home Cloud MCP.

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.

Register the hardware ID as a Ring client session once, when you link the account. go-ring never registers on its own, and Ring throttles registration (HTTP 406, returned as a rate limit error).

if err := client.RegisterSession(ctx, ring.RegisterSessionRequest{Auth: auth}); err != nil {
    return err
}

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.

About

Golang library for Ring Doorbell devices:- auth, video streams, controls

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages