Coder Social home page Coder Social logo

doorbot's Introduction

Ring.com Doorbell API Build Status

I built this because of this tweet.

I have nothing to do with Ring.com, they just annoyed me with that tweet, so I figured out their api..

doorbot 2.x has an API change

usage

npm i doorbot --save

const RingAPI = require('doorbot');

const ring = RingAPI({
    email: '[email protected]',
    password: '12345',
    retries: 10, //authentication retries, optional, defaults to 0
    userAgent: 'My User Agent', //optional, defaults to @android:com.ringapp:2.0.67(423)
    api_version: 11, //optional in case you need to change it from the default of 9
    timeout: (10 * 60 * 1000) //Defaults to 5 minutes
});

ring.devices((e, devices) => {
    console.log(e, devices);
    ring.history((e, history) => {
        console.log(e, history);
        ring.recording(history[0].id, (e, recording) => {
            console.log(e, recording);
            const check = () => {
                console.log('Checking for ring activity..');
                ring.dings((e, json) => {
                    console.log(e, json);
                });
            };
            setInterval(check, 30 * 1000);
            check();
        });
    });

    //floodlights are under the stickups_cams prop
    if (devices.hasOwnProperty('stickup_cams') && 
        Array.isArray(devices.stickup_cams) &&
        devices.stickup_cams.length > 0) {
        
        ring.lightToggle(devices.stickup_cams[0], (e) => {
            //Light state has been toggled
        });
    }
});

api

Get a list of your devices:

ring.devices(callback) => (error, array)

Device Health: ring.health(device, callback) => (error, json)

Get your ring history:

ring.history(callback) => (error, array) ring.history(limit, callback) => (error, array) - limit - The Number of items to return from the history. ring.history(limit, older_than, callback) => (error, array) - limit - The Number of items to return from the history. older_than - The ID of the latest history item to start with when going backward.

Get a URL to a recording:

ring.recording(id, callback) => (error, url)

Get information for video on demand:

ring.vod(device, callback) => (error, json)

Turn on floodlights

ring.lightOn(device, callback) => (error)

Turn off floodlights

ring.lightOff(device, callback) => (error)

Toggle floodlights

ring.lightToggle(device, callback) => (error)

Set Chime Do Not Disturb

ring.set_chime_dnd(device, minutes, callback) => (error, json)

  • on: ring.set_chime_dnd(device, 15, callback) => (error, json)
  • off: ring.set_chime_dnd(device, 0, callback) => (error, json)

Get Chime Do Not Disturb

ring.get_chime_dnd(device, callback) => (error, json)

Set Doorbot Do Not Disturb (motion snooze)

ring.set_doorbot_dnd(device, minutes, callback) => (error, json)

  • on: ring.set_doorbot_dnd(device, 60, callback) => (error, json)
  • off: ring.set_doorbot_dnd(device, 0, callback) => (error, json)

The Get API call for the doorbot DND returned a 404, not sure how to get the current time

debugging

I've added the debug module, so you can run this with export DEBUG=doorbot and it will print some helpful logs.

doorbot's People

Contributors

davglass avatar lmoga avatar mrose17 avatar shadowbq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doorbot's Issues

Alarm Support

I just got the alarm and tried to connect to that API.

I discovered some info about the API, but had problems getting the connection to work
It looks like the alarm is associated with a location_id, available in the latest API version
Sending a POST request to https://app.ring.com/api/v1/rs/connections with accountId: LOCATION_ID and an authorization header using the same oauth token used during the initial login returns an object with a server to connect to along with an auth code.

The alarm communication then occurs over a websocket, seemingly using socket.io. The websocket URL is:
wss://SERVERNAME/socket.io/?authcode=AUTHCODE&ack=false&EIO=3&transport=websocket where SERVERNAME and AUTHCODE come from the connections request

I tried connecting to the socket using the socket.io client, but the connection is closed after the initial frame is received. Following is the code I used to initiate the socket:
io.connect("wss://" + alarmConnection.server + "/socket.io/?authcode=" + alarmConnection.authCode, { transports: ['websocket'], upgrade: false, nsp: '/' } );

Any help would be appreciated

I did some research and it looks like there is a difference when connecting with socket.io that the official ring client doesn't do. Screenshots below:
Official Client:
socket_official

Custom Client:
socket_custom

Question

Hello, how difficult would it be to write a program that simply downloads all of the recordings automatically to a folder for each camera?

FR: Add doorbot motion_snooze and chime do_not_disturb functions

Set a 3 hour chime 'do_not_disturb'..

POST https://api.ring.com/clients_api/chimes/123456/do_not_disturb HTTP/1.1
Host:	api.ring.com
Content-Type:	application/json
Accept:	*/*
Content-Length:	30
Connection:	keep-alive
X-API-LANG:	en
Hardware_Id:	<GUID>
User-Agent:	ring/4.1.16 (iPhone; iOS 11.3; Scale/2.00)
Accept-Language:	en-US;q=1, es-ES;q=0.9
Authorization:	Bearer <TOKEN>
Accept-Encoding:	identity


{"api_version":"9","time":180}

Disable the motion snooze..

POST https://api.ring.com/clients_api/chimes/123456/do_not_disturb HTTP/1.1
Host:	api.ring.com
Content-Type:	application/json
Accept:	*/*
Content-Length:	19
Connection:	keep-alive
X-API-LANG:	en
Hardware_Id:	<GUID>
User-Agent:	ring/4.1.16 (iPhone; iOS 11.3; Scale/2.00)
Accept-Language:	en-US;q=1, es-ES;q=0.9
Authorization:	Bearer <TOKEN>
Accept-Encoding:	identity
{
    "api_version": "9"
}

Set a 15 minute doorbell 'motion_snooze'..

POST https://api.ring.com/clients_api/doorbots/7654321/motion_snooze HTTP/1.1
Host:	api.ring.com
Content-Type:	application/json
Accept:	*/*
Content-Length:	29
Connection:	keep-alive
X-API-LANG:	en
Hardware_Id:	<GUID>
User-Agent:	ring/4.1.16 (iPhone; iOS 11.3; Scale/2.00)
Accept-Language:	en-US;q=1, es-ES;q=0.9
Authorization:	Bearer <TOKEN>
Accept-Encoding:	identity
{
    "api_version": "9",
    "time": 15
}

Clear doorbell 'motion_snooze'..

POST https://api.ring.com/clients_api/doorbots/7654321/motion_snooze/clear HTTP/1.1
Host:	api.ring.com
Content-Type:	application/json
Accept:	*/*
Content-Length:	19
Connection:	keep-alive
X-API-LANG:	en
Hardware_Id:	<GUID>
User-Agent:	ring/4.1.16 (iPhone; iOS 11.3; Scale/2.00)
Accept-Language:	en-US;q=1, es-ES;q=0.9
Authorization:	Bearer <TOKEN>
Accept-Encoding:	identity
{
    "api_version": "9"
}

throw new TypeError('Parameter "url" must be a string, not ' + typeof url);

I ran download-all.js and it ran for a while downloading 4,327 videos before getting the error below. I am about to look at this closer to see if I can figure it out. I know that there are more videos after this, but this might be about where there is a gap where several months ago a bunch of videos were deleted from the ring web portal.

url.js:103
throw new TypeError('Parameter "url" must be a string, not ' + typeof url);
^

TypeError: Parameter "url" must be a string, not undefined
at Url.parse (url.js:103:11)
at Object.urlParse [as parse] (url.js:97:13)
at ring.recording (...RingVids\download-all.js:64:46)
at simpleRequest (...RingVids\node_modules\doorbot\doorbot.js:357:13)
at fetch (...RingVids\node_modules\doorbot\doorbot.js:176:17)
at IncomingMessage.res.on (...RingVids\node_modules\doorbot\doorbot.js:125:17)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)

Installed; nothing happens. Newbie help needed please.

So I've installed node and I believe, this package. I go into the doorbot folder and edit downloads.js and links.js to have my username and password. I've turned off 2fa to keep things simple.

MacBook-Pro:downloads mac$ node /Users/mac/node_modules/doorbot/examples/download.js
done
MacBook-Pro:downloads mac$

This creates a 'Downloads' folder with nothing in it.

Similarly, links.js just opens and closes (if I run it as node /folder/links.js which I assume is the way to do these things)

I am new to node and scripts generally so don't know if I'm missing anything obvious. Please help?

Missing health information for device chime

I do not get health information for chime. I called the health information with the doorbot. I get an error 410 back. Enclosed the logfile and the doorbot I called the health function


Chimes (doorbot): {"id":5359415,"description":"Flur","device_id":"c8fd1906ac0f","time_zone":"Europe/Berlin","firmware_version":"Up to Date","kind":"chime","latitude":LAT026,"longitude":LON626,"address":"strasse Str. 1b, ort, nds PLZ, DE","settings":{"volume":5,"ding_audio_user_id":"ring","ding_audio_id":"xxxfa2-a83d-e5a4-5af2-5646cb2449be","motion_audio_user_id":"ring","motion_audio_id":"xxxe86-f43b-738f-7287-5693688ec52b"},"features":{"ringtones_enabled":true},"owned":true,"alerts":{"connection":"online"},"do_not_disturb":{"seconds_left":0},"stolen":false,"location_id":"xxx0k-4ishs-0","ring_id":null,"owner":{"id":4813372,"email":"[email protected]","first_name":"VORNAME","last_name":"NACHNAME"}}
 Health ID: {"id":5359415,"description":"Flur","device_id":"c8fd1906ac0f","time_zone":"Europe/Berlin","firmware_version":"Up to Date","kind":"chime","latitude":LAT026,"longitude":LON626,"address":"strasse Str. 1b, ort, nds PLZ, DE","settings":{"volume":5,"ding_audio_user_id":"ring","ding_audio_id":"xxxfa2-a83d-e5a4-5af2-5646cb2449be","motion_audio_user_id":"ring","motion_audio_id":"xxxe86-f43b-738f-7287-5693688ec52b"},"features":{"ringtones_enabled":true},"owned":true,"alerts":{"connection":"online"},"do_not_disturb":{"seconds_left":0},"stolen":false,"location_id":"xxx0k-4ishs-0","ring_id":null,"owner":{"id":4813372,"email":"[email protected]","first_name":"VORNAME","last_name":"NACHNAME"}}
Could not get Health for 5359415. Error: API returned Status Code 410

Question about health checks

Hello,

I see in one of the issues that you use this code to monitor battery status, and that's exactly what i wanted to do. As for your experience with this, do you know:

  • how often is the device is checked for health?
  • is there any way to force a read to update battery status?
  • i can't see the "last health check" date that is show on the app, in the api responses, do you know if that is available?

Thank you very much

Retrieve *all* videos?

Currently using this I only seem to be able to get 20 or so mp4s. I'd like to download the entire history. Is that possible?

Works fine otherwise - great work!

Recordings Not Working

Looks like maybe the API for recordings has changed. I get this for every ID:

Error: API returned Status Code 404
    at IncomingMessage.res.on (/Users/jason/Projects/RingRecap/node_modules/doorbot/doorbot.js:61:21)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1045:12)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)
    at process._tickCallback (internal/process/next_tick.js:161:9) undefined

If you don't have time to fix this, would you mind describing how you captured the original dumps? Maybe I can replicate it and fix it.

change needed for new naming convention used

I tried the download-all.js example, but it didn't quite work because I think ring has changed their URL path names since this code was developed. The new path names added "_stamp" to the timestamp portion of the path name. I changed the code to be this:


                if ((e == null) && (typeof recording != 'undefined')) {
		const datea = dateFormat(info['created_at'],"yyyy_mm_dd_HH.MM.ss_Z");
		const partFilePath = url.parse(recording).pathname.substring(0,url.parse(recording).pathname.length - 4);
		const parts = partFilePath.split('/');
		const filePath = '/' + parts[1] + '/' + datea + '_' + parts[2] + '.mp4';
		const file = path.join(base, '.', filePath);
				
		// Track the smallest ID, which is the oldest ID in this batch
		if (info['id'] < oldestFile) {
                        oldestFile = info['id'];
		} 

So I use the info['id'] to obtain the timestamp, rather than parts[2] which now has the "_stamp" suffix making the comparison not work.

Hope this helps someone. I have it working so that it pulls down every file from my ring account, skipping over existing files. Very convenient - thanks for writing this code.

Authorization Issue

It appears ring have made a few changes with their API causing authentication to fail (401s). They've blocked a number of user agents - this may affect this project and they also require the auth to be included in the header of each request.

This is the python project equivalent issue and fix: tchellomello/python-ring-doorbell#143.

Get device IDs for all the devices

Would it be possible to get the Device IDs for the devices in the account? I'm trying to setup the Smartthings to turn on the Siren based on the motion at late night.

I have a Ring pro and 2 floodlights. I was able to get the device ID using the postman but just got only one device ID. I don’t know if the device ID is for the floodlight or doorbell.

The siren and spotlight are not working for me. It could be the device id that was causing the problem.

Use case?

Hi,

Looking through this, it all looks great but what is the actual use case on this? Like how are people actually using this? Do you have a web page that kicks off these scripts, do they tie in with openHAB or SmartThings, etc. or are you just running these from a command line when you want to get info?

no events

Hi!
the situation is very strange to me.
this doorbot working 24/7 on my rpi (raspberry pi)
after some period (~week or mb 1.5w) all motion events are gone.

just start, for example, on my iPad the ring app - all motion events start to passing to doorbot again.
after a week / 2 weeks the situation is coming again.

more than. I have dev copy on my windows pc of this node. just for additional developments.
so, if I start this node (with old refresh token...) this also "fix" motion events on my rpi 24/7 application.

idk, what happens. :(

thank you!

PS: snapshots working like a charm... at this time

ring only allow 2fa

everything stops after 2fa regulations on ring, can you modify login to allow 2fa autentification?

Button to unlock door

I’ve seen many commercial door locks integrated into ring so you can directly open the door from the live video feed.

I have built my own door lock working on Blynk. My door lock works great, but it’s annoying to have to change apps (an loose video and audio contact with your visitor) when you want to open the door on Blynk, so I would like to integrate my own button / endpoint to the live view screen.

Any ideas on how to achieve this?

I’ve also looked into the idea of showing the video feed on my Blynk app (which is possible), but it seems like the SIP video feed is still not figured out well to have the video streamed just from a http source, is it?

How can I download all of my videos on ring.com

My video files is going to be deleted off ring.com as its 6 months old.
Would you be able to show me a script that can download all of my videos on ring.com ?
I am on a linux machine.

Thanks for your consideration

License

What's up with the license on this repo? Consider changing it to MIT?

JSON Parse issue @ Line 278, doorbot.js

Gets this error when trying to get the device info.. after logging.

Error: JSON parse error from ring, check logging..
at IncomingMessage.res.on (/Users/XXXX/node_modules/doorbot/doorbot.js:278:45)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1129:12)
at process._tickCallback (internal/process/next_tick.js:63:19) undefined

Is intercepting ring's https via mitmproxy in transparent mode still possible

Hi,

My setup for intercepting ring traffic has stopped working recently, even though it works for other https websites. It looks like the ring app might not be trusting the MITMproxy CA any more, even though the rest of the OS does trust it.

Do still you have a technique that works to intercept traffic, and if so, would it be possible to document the steps perhaps in the repo?

screenshot at aug 03 19-42-35

Worried 3rd party APIs are getting more and more difficult to make for these devices.

Need a little help from a friend...

Hi bud,

This is JUST what I need, but I get an issue with the ring.authentication call. Any ideas? (Sooorry - yes, I'm blindly following instructions as I don't normally use node...)

download all videos files from my account

Hi

I want to download all videos files automatically from my account, is this possible ?
I am on linux and I want to download all my videos, any ideas on to do this?

Thanks in advance

Unable to install via npm

C:\Users\Ketan.Parekh\Downloads\python-ring-doorbell-master\python-ring-doorbell-master\node_modules\doorbot>npm i doorbot
npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "i" "doorbot"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ENOSELF

npm ERR! Refusing to install doorbot as a dependency of itself
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Ketan.Parekh\Downloads\python-ring-doorbell-master\python-ring-doorbell-master\node_modules\doorbot\npm-debug.log
npm-debug.log

Can't auth

  doorbot fetch-raw-data {"error":"You need to sign in or sign up before continuing."} +594ms
  doorbot fetch-json { error: 'You need to sign in or sign up before continuing.' } +1ms
  doorbot authentication_token undefined +0ms

Not really an issue - just a noob keen to contribute.

Hello,

I would like to use and contribute to this project. My goal is to enable / disable DND automatically based on the Alarm System's mode (disarmed ,home, away).

Oddly enough, this was also born out of a similar complaint I have with Ring Support's response of "No you cannot do this, the security cameras and the security system are different systems" - i mean WTF??

I could use some advice to see how you are peeking at the API requests made by the app (I am assuming you're using a phone app as the web dashboard is pretty cut down).

At the moment I am just playing with DND for doorbot but despite it accepting the minutes for DND, the devices still send through alerts to our mobile phones.

As I said keen to contribute as much as I take, I just need a kick in the right direction to get started :)

Thanks!

Limit of 100?

I seem unable to get more than 100 entries returned from history, setting any number over 100 seems to just return 100 - the same applies using the example downloader. Is this a limitation of the ring api?

Thanks

health status

I don't think there is a health function.

This seems to work:

health(device, callback){
	validate_callback(callback);
	const url= `/doorbots/${device.id}/health?api_version=9&auth_token=${this.token}`;
	this.simpleRequest(url, 'GET' , callback);
}

Download All for one device?

I have been trying to modify the download-all example to just pick one device based on ID but I can seem to get it to work. Would it too hard to show an example of how to download all from just one device ?

How to install this ?

Hello,
I would like to be able to test this program.
I have no idea how to do it.
How to compile them?
I am very very beginner.

Ubuntu upgrade broke authentication access

How do I get the access token set up? Any help would be appreciated.

I still have a .ringAlarmCache file.
I also am able to get a new refreshToken and store it in the file.

I have an alias I run to download all my files.
alias ringtime='pushd /hbase/archive/ring/doorbot/examples ; node download-all.js ; popd'

I have:
export DEBUG=doorbot

Running the download-all script gives status code 412 and then sends the verification code to phone.

greg@salt:/hbase/archive/ring/doorbot/examples$ node download-all.js
doorbot authenticating with oAuth... +0ms
doorbot fetching access_token from oAuth token endpoint +2ms
doorbot access_token statusCode 412 +470ms
doorbot access_token headers {
date: 'Wed, 23 Jun 2021 02:40:03 GMT',
'content-type': 'application/json',
'content-length': '65',
connection: 'close',
'strict-transport-security': 'max-age=31536000; includeSubDomains',
'cf-cache-status': 'DYNAMIC',
'cf-request-id': '0ad8563bc2000042a5be251000000001',
'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
server: 'cloudflare',
'cf-ray': '663a5972cfc942a5-LAX'
} +1ms
doorbot access_token request failed, bailing.. +2ms
Done, Oldest File: 10000000000000000000
Getting more, older than: 10000000000000000000
doorbot authenticate in progress, queuing callback +1ms
greg@salt:/hbase/archive/ring/doorbot/examples$

Getting 401 when authenticating

Hey all,

Ive finally found some time to tinker with the ring api, and implement something to download all ring videos, and I noticed that the API has been upgraded.. Alas Ive tried using it and for some reason I simply get a 401 when authenticating..
Any ideas? anyone else getting this error?

Step by step instuctions please

I am trying to run doorbot to download all my videos. I am new to java and really do not know what I am doing. I was able to download and install some of the required modules but when I try to install the doorbot module I get an error, "Refusing to install doorbot as a dependency of itself". I get this after attempting to run npm i doorbot --save
I am running Linux on Windows.
Thanks

Screenshot from Camera Preview

Now that ring has added the Camera Previews option, is there a way for doorbot to pull down the most recent preview image? I'm looking to integrate this into ActionTiles.

API Version 11

It looks like the app is now using API version 11. I'm not sure if using the app causes Ring to force you onto the latest version, but the account that I used with the latest version of the app no longer works with this and an account that isn't used works normally.

No problem at all - Just saying this works great!

Thanks for your library.
This is working great !!

I now use it to query the battery status, sent it to my mqtt server, and from there node-red starts mailing me every 1% under 10% capacity.
(for some reason I don't receive the battery status messages from ring)

Regards,
Luc

homebridge plugin for ring video doorbell

hi. i'm the author of https://github.com/homespun/homebridge-platform-ring-video-doorbell ...

i wish i had started a month later on that plugin for homebridge (homekit for the impatient), cause then i wouldn't have had to transcode the PHP API from https://github.com/jeroenmoors -- https://github.com/jeroenmoors/php-ring-api -- there's nothing wrong with his API, of course, it just would have been faster to use yours.

anyone my gameplan is to move over to your API and see if i get better results...

many thanks!

Jome

ringApi.getCameras()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.