ring-client-api
This is an unofficial TypeScript api for Ring Doorbells, Ring Cameras, the Ring Alarm System, Ring Smart Lighting, and third party devices that connect to the Ring Alarm System. Built to support the homebridge-ring Plugin
Installation
npm i ring-client-api
Setup and Config
const ringApi = // without 2fa email: 'some.one@website.com' password: 'abc123!#' // with 2fa or if you dont want to store your email/password in your config refreshToken: 'token generated with ring-auth-cli. See https://github.com/dgreif/ring/wiki/Two-Factor-Auth' // The following are all optional. See below for details cameraStatusPollingSeconds: 20 cameraDingsPollingSeconds: 2 locationIds: '488e4800-fcde-4493-969b-d1a06f683102' '4bbed7a7-06df-4f18-b3af-291c89854d60';
For accounts with 2fa enabled, see the Two Factor Auth Wiki
Optional Parameters
Option | Default | Explanation |
---|---|---|
refreshToken |
undefined |
An alternate authentication method for accounts with 2fa enabled, or if you don't want to store your email/password in a config file. See the Two Factor Auth Wiki. |
cameraStatusPollingSeconds |
undefined (No Polling) |
How frequently to poll for updates to your cameras (in seconds). Information like light/siren status do not update in real time and need to be requested periodically. |
cameraDingsPollingSeconds |
undefined (No Polling) |
How frequently to poll for new events from your cameras (in seconds). These include motion and doorbell presses. Without this option, cameras will not emit any information about motion and doorbell presses. |
locationIds |
All Locations | Allows you to limit the results to a specific set of locations. This is mainly useful for the homebridge-ring Plugin, but can also be used if you only care about listening for events at a subset of your locations and don't want to create websocket connections to all of your locations. This will also limit the results for ringApi.getCameras() to the configured locations. If this option is not included, all locations will be returned. |
debug |
false | Turns on additional logging. In particular, ffmpeg logging. |
Locations
location.hasHubs // does this location have an alarm and/or lighting bridgelocation.disarmlocation.armHomelocation.armAwaylocation.getAlarmMode // returns Promise<'all' | 'some' | 'none'>location.soundSirenlocation.silenceSirenlocation.cameras // array of cameras at this location
locations
is an array of your Ring locations. Each location can be armed or disarmed,
and used to interact with all devices in that location.
Devices
Once you have acquired the desired location, you can start to interact with associated devices. These devices include ring alarm, ring lighting, and third party devices connected to ring alarm
const devices = await locationconst baseStation = devicesbaseStation // base station and keypad support volume settings between 0 and 1console // object containing properties like zid, name, roomId, faulted, tamperStatus, etc.baseStationonData
Cameras
You can get all cameras using await ringApi.getCameras()
or cameras for a particular
location with location.cameras
camera.data // camera info including motion zones, light status, battery, etc.camera.onData.subscribecamera.setLighttrue // turn light on/offcamera.setSirentrue // turn siren on/offcamera.getHealth // fetch health info like wifi statuscamera.startVideoOnDemand // ask the camera to start a new video streamcamera.createSipSession // creates a new SipSession which allows you to control RTP flowcamera.getHistory50 // fetch ding history (like motion and doorbell presses)camera.getRecordingcamera.getSnapshot // returns a Promise<Buffer> of the latest snapshot from the camera
Camera also includes the following observables:
onNewDing
: this will include the sip info and ding information every time a new ding is createdonActiveDings
: dings created within the last 65 secondsonDoorbellPressed
: emits a ding every time the doorbell is pressedonMotionDetected
:true
orfalse
based ononActiveDings
containing a motion ding
Some other useful propeties
id
name
: same asdescription
fromdata
hasLight
: does this camera have a lighthasSiren
: does this camera have a sirenisDoorbot
: is this camera a doorbell
See the examples
directory for additional code examples.
Upgrading from v3 to v4
See https://github.com/dgreif/ring/wiki/Upgrading-from-v3-to-v4
homebridge-ring
The homebridge-ring
is also maintained in this repo. It's readme can be found in the homebridge
directory
Credits
I'd like to give a big thanks to a number developers who have put a lot of hard work into analyzing the Ring api and building similar libraries which were extremely valuable in my creation of this project. Thank you all for your hard work!
- @davglass - https://github.com/davglass/doorbot - The original node project that proved we can interact with Ring's api
- @jimhigson - https://github.com/jimhigson/ring-api - A promisified api for Ring's original line of products
- @tchellomello - https://github.com/tchellomello/python-ring-doorbell - A python api which is widely used for Ring integrations
- @mrose17 - https://github.com/homespun/homebridge-platform-ring-video-doorbell - The original Ring camera homebridge plugin
- @codahq - Thanks for all your help debugging the Ring api
- @joeyberkovitz - Great discovery work on the Ring Alarm websockets api