KoenZomers / RingApi

Api in .NET 6 to communicate with the Ring Doorbell services
38 stars 19 forks source link
csharp dotnet6 ring ring-api ring-devices ring-doorbells ring-service

Ring API

licence badge stars badge forks badge issues badge Continuous Integration Build

This library for C# compiled against .NET 6 will allow you to easily communicate with the Ring API and retrieve details about your Ring doorbells and Ring chimes.

If you're just looking for a tool to download your Ring recordings, go here instead.
If you're looking for a tool to download snapshots from your Ring cameras, go here.

Version History

0.5.4.0 - released April 5, 2024

0.5.3.0 - released September 2, 2023

0.5.2.0 - released July 4, 2023

0.5.1.0 - released July 3, 2023

0.5.0.1 - released September 14, 2022

0.5.0.0 - released September 14, 2022

0.4.4.0 - released September 14, 2022

0.4.3.2 - released April 29, 2020

0.4.3.1 - released March 18, 2020

0.4.3.0 - released March 18, 2020

0.4.2.2 - released March 16, 2020

0.4.2.1 - released January 22, 2020

0.4.2.0 - released January 2, 2020

0.4.1.0 - released December 24, 2019

0.4.0.3 - released December 24, 2019

0.4.0.2 - released December 24, 2019

0.4.0.1 - released December 24, 2019

0.4.0.0 - released December 23, 2019

0.3.5.0 - released October 27, 2019

0.3.4.0 - released October 4, 2019

0.3.3.0 - released October 4, 2019

0.3.2.0 - released August 9, 2019

0.3.1.0 - released August 9, 2019

0.3.0.1 - released March 2, 2019

0.3.0.0 - released March 2, 2019

0.2.2.1 - released September 13, 2018

0.2.2 - released July 2, 2018

0.2.1 - released June 28, 2018

0.2 - released August 18, 2017

0.1 - released August 13, 2017

System Requirements

This API is built using Microsoft .NET Standard 2.0 and is fully asynchronous

Usage Instructions

To communicate with the Ring API, add the NuGet package to your solution and add a using reference in your code:

using KoenZomers.Ring.Api;

Then create a new session instance using:

var session = new Session("your@email.com", "yourpassword");

Note that this line does not perform any communications with the Ring API yet. You need to manually trigger authenticate before you can start using the session:

await session.Authenticate();

If the Ring account you're connecting with has been set up with a two factor authentication requirement, wait for the text message or e-mail from Ring with the code to arrive and run Authenticate again providing this code:

await session.Authenticate(twoFactorAuthCode: "12345");

If the account does not require two factor authentication, you can skip this step.

Once this succeeds, you can call one of the methods on the session instance to retrieve data, i.e.:

To retrieve all Ring devices connected to your account to i.e. retrieve the device Id needed for some methods:

var devices = await session.GetRingDevices();

To retrieve all recorded doorbell events including the recording Ids which you will need for the next two samples:

var doorbotHistory = await session.GetDoorbotsHistory();

To save a recording directly to your disk (use GetDoorbotsHistory to get the Id):

await session.GetDoorbotHistoryRecording("6000000004618901011", "c:\\temp\\recording.mp4");

To share a recording (use GetDoorbotsHistory to get the Id):

await session.ShareRecording("6000000004618901011");

To retrieve the latest available snapshot from a doorbot and save it to disk (use GetRingDevices to get the Id):

await session.GetLatestSnapshot(1111111, "c:\\temp\\snapshot.jpg");

To force a new snapshot to be taken from a doorbot (use GetRingDevices to get the Id):

await session.UpdateSnapshot(1111111);

To retrieve the date and time at which the last snapshot was taken from a doorbot (use GetRingDevices to get the Id):

var timestamps = await session.GetDoorbotSnapshotTimestamp(1111111);

Unit Tests

Check out the UnitTest project in this solution for full insight in the possibilities and working code samples. If you want to run the Unit Tests, just copy the App.sample.config file in the UnitTest project to App.config and fill in your Ring username and password and you're good to go to run all tests. They will not make any changes to your Ring devices or Ring profile, just retrieve information, so you can run it without any risk. If you're using text message or e-mail message two factor authentication on the Ring account you want to perform the unit tests with, just leave TwoFactorAuthenticationToken empty in the config file, run the unit tests, wait for the text or e-mail message to arrive, enter the code from the text or e-mail message in the TwoFactorAuthenticationToken appSetting in the config file and run the unit tests again. It should now succeed and update the RingRefreshToken appSetting with a valid refresh token it can use on subsequent runs so it no longer needs credentials or two factor authentication to run the unit tests.

Available via NuGet

You can also pull this API in as a NuGet package by adding "KoenZomers.Ring.Api" or running:

Install-Package KoenZomers.Ring.Api

Package statistics: https://www.nuget.org/packages/KoenZomers.Ring.Api

Current functionality

With this API at its current state you can:

Feedback

Any kind of feedback is welcome! Feel free to drop me an e-mail at koen@zomers.eu or create an issue