Long scale Nest time lapse videos (part 1)

We have a few Nest (formerly Dropcam) cameras that we’ve had pointed at the construction site of our new building. We’re paying for the lowest of the subscription services, the one that gets you 10 days of video storage but not the full “Nest Aware” package. The time lapse videos we were getting from the service were ok, but the cameras are capable of higher resolution than the videos we were getting. (1080 vs 720, I believe.) And there were some pretty unpleasant compression artefacts showing up, mainly in the sky and clouds, which make up a large portion of the frame with some of the cameras. Also, we want to be able to make time lapse videos covering months, maybe a year. I think you can do some of that with the higher priced subscriptions, but you definitely can’t with the cheap one, at least not easily. (The previous idea was to have someone download a daily time lapse every day and then assemble them in Final Cut as needed. That’s a lot of manual work for something which ought to be eminently automatable.)

Here’s what I did to get us the ability to make full resolution time lapse videos of arbitrary duration, over any period of time the cameras were running. I’m using an iMac running OS X, but this should work from a linux system or a Windows system with the right tools installed.

Step 1: Sign up for a Nest Developers account at https://developers.nest.com/

Step 2: Create a new “product” using your developer account. It’s only ever going to have one user — you — so you don’t need to worry about complying with the requirements of the product review phase. I called my product “Still grabber” and put it in the “Education and hobbyist” category. For the support URL, I entered our public web site. For permissions, I enabled “Camera + Images Read”, since it doesn’t need to write to the service. (When I wrote this, it was v3; I’ve done it again with v4 and it still works for me.)

Step 3: Get an authorization code

In your product details page, at the right, there are three pieces of information: Client ID, Client Secret, and Authorization URL. (“Client” used to be “Product”.) Copy the Authorization URL and load it in a browser. That should get you a page asking you to accept your product’s request to read still images from your camera. Click “Accept”, and you’ll get a PIN code to use later. Copy that down somewhere.

Step 4: Use curl to get a security token for your product

From a command line on a system where the utility “curl” is installed, run this command:

curl -o auth.txt -X POST -d 'code=AUTH_CODE&client_id=PRODUCT_ID&client_secret=PRODUCT_SECRET&grant_type=authorization_code' "https://api.home.nest.com/oauth2/access_token"

Where AUTH_CODE is the PIN you got in step 3, and PRODUCT_ID and PRODUCT_SECRET are the values from your product details page.

Once the command has run, you should have a file named auth.txt which contains a JSON string like this:

{"access_token":"c.ZEX[...]F3a","expires_in":315360000,"user_id":"1[...]9"}

Keep that access_token value (the bit highlighted in yellow) safe; you’re going to be using it to authorize API requests next, and you don’t want other people to be able to do that for your account. Incidentally, that “315360000” means that this token is good for ten years. If you’re going to be doing this for longer, you’ll want to come back and generate a new token somewhere in year nine.

Step 5: Get the snapshot URL(s) for your camera(s)

From the command line again, run this command:

curl -o info.json --location-trusted -v -L -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -X GET "https://developer-api.nest.com/"

Use the access_token you got in step 4 in place of “YOUR_ACCESS_TOKEN”. That should get you a file named info.json with a whole lot of information about your devices. It’s hard to read, so you can make it prettier with the following command:

python -m json.tool < info.json > info.txt

Now open that info.txt in your text editor of choice and look for the string “snapshot_url”. If you have multiple cameras, there should be “name” and “name_long” values right above the snapshot_url value telling you which camera it means. “snapshot_url” is the URL you can use to get a full resolution still image from your camera at the time you make the request. Keep this URL safe, because you don’t want anyone else using it. Don’t, for example, use it directly to provide a live image on your public web site. There are rate limits on these kinds of requests, but I don’t know what the limits are. I’m requesting a snapshot from each camera once per minute, and that seems to be fine.

Step 6: Save a snapshot once per minute and assemble them into videos.

I’ll write this up in Part Two.

Update, 2018.07.31

I’m adding some screenshots here, so people can double check what they’re doing against what I’m doing:

Update, 2019.03.07

I’ve added the --location-trusted argument to the curl command to get the info.json file, as suggested in the comments; newer versions of curl require that.

12 thoughts on “Long scale Nest time lapse videos (part 1)”

  1. I’m getting stuck at step 5. I put in the command replacing YOUR_ACCESS_TOKEN with ~/auth.txt since that is where my token was saved. I’m getting a 401 unauthorized response. Also the version of the permission is now revved to 4, I wonder if that is part of the issue.

  2. Oh, wait, I just read your comment more closely. If you’re replacing the string YOUR_ACCESS_TOKEN with the string “~/auth.txt”, that’s not going to work. You need to use the actual access_token value from inside ~/auth.txt, the bit that looks like “c.ZEX[…]F3a”.

      1. I’ve just highlighted the bit you need to copy from step 4 and past in step 5. Make sure that you’ve got the actual access token — the bit that looks like “c.ZEX[…]F3a” — pasted in where the instructions say “YOUR_ACCESS_TOKEN”. If you paste anything more or less than that, it’s not going to work. You want just the bit between quotation marks after "access_token": in the auth.txt file.

        1. no luck, I’m using:
          curl -o info.json -v -L -H “Content-Type: application/json” -H “Authorization: Bearer c.QX04PHV…” -X GET “https://developer-api.nest.com/”

          1. What happens when you do that? Because I just ran through it again, and it works for me. I added some screenshots; maybe see if there’s anything at all different going on?

  3. Please tell me I’m missing something, and this still works.

    This no longer appears to work, unless you already have a nest developer account. And even then I don’t know. as of 2019/07/07.
    Nest says they are not accepting any new WWN connections after Aug 31, 2019, but the developer.console already redirects to Nest FAQ about shuttering WWN.
    Eventually this will be changed to WWG, Has anyone gotten it to work with Google yet ?

    1. Oh no! The ones I set up are still working, but I haven’t tried setting up anything new recently. I have no idea if there’ll be a way to get frame grabs out of these things once they’re fully absorbed into the Google ecosystem. I’m betting not. *sigh* Once I know either way for sure, I’ll update the post.

Leave a Reply

Your email address will not be published. Required fields are marked *