Capture image from camera via URL


#1

Hi,

I’m a total noob to this so apologies if I am missing something obvious. I just want to capture a snapshot from a camera that belongs to a client. I have the camera ID and the client ran my Authorization URL and gave me their pin. I put that through postman and got the authorization code (the long text that begins with “c…”).

The API instructions for snapshot are:

https://developer-api.nest.com/devices/cameras/device_id/snapshot_url
Example: “string1/device_id/string2?auth=camera_token”

I assume I replace “device_id” with the camera ID, but I’m not clear on where I put the “auth code” or how the “example” text is supposed to be integrated into the provided URL. I’m not a web developer so this is all greek to me. Can someone please humor me and provide an actual URL example that indicates where the “auth=c.” code goes, etc

Thanks!


#2

Hi,
Thanks for the question.

You’re right that you replace device_id with the camera ID.

Here’s a more realistic example of a GET call with a real camera ID:

GET https://developer-api.nest.com/devices/cameras/OPhwi9_fLyqQ4VQ23siK26c93gS8DYVH5_Os75k0srHmiW5g9RCniw/snapshot_url

The auth code goes in the header as shown here:
https://codelabs.developers.google.com/codelabs/wwn-api-quickstart/#5

The example "string1/device_id/string2?auth=camera_token” is what is returned from the GET call. This is explained here:
https://developers.nest.com/documentation/cloud/camera-guide#image_or_gif_files

You can then load this returned URL to view the image in a browser.

We will make some clarifications in our documentation. Specifically, we’ll clarify that the examples in the API reference are showing what is returned after the call is made.

Thanks again,
-Betsy


#3

Just an update to let you know that we’ve updated our reference tables to say “Returns” so that it’s clear what the example is actually showing.

Cheers,
Betsy


#4

Hi,

Thanks for the helpful response.

I’m actually trying to capture an image directly from the nestcam to do automated capture of still images for timelapse. Most regular IP or webcams support this. i.e. for example from a random AXIS brand public camera: http://67.141.206.85/axis-cgi/jpg/image.cgi and this returns an image. Is there a way to use a single URL to return an image with the nest cameras?

Tim


#5

@betsyl Any idea if there it is possible to capture directly via a url (i.e. not with a webpage)?

Thanks


#6

Hi @TimeCam,

Did your authorization question get resolved so that you get data back?
It sounds like it did, but you are expecting a different URL back.

I’ve included the URL for the Nest API, and the camera fields that you can ask for. You may want to try last_event/app_url, which would send you a link such as: nestmobile://cameras/device_id/cuepoints/STRING?auth=access_token

https://developers.nest.com/documentation/api-reference

Thanks,
Betsy


#7

On second thought, maybe what you need is “public_share_url”: “https://video.nest.com/live/STRING1?STRING2”,

FYI, you can see descriptions of the URLs by clicking on the blue circle.


#8

Hi @betsyl

I am looking for the actual single line URL I would use to return an actual image.
For example, as I said earlier, if I use this command with an axis camera it returns an image directly
http://67.141.206.85/axis-cgi/jpg/image.cgi
Not a web page or some json returned file, an image.

Does anything like that exist for the nest cam? If so, can you provide me with an actual example in text rather than as a pasted image so I can copy the URL and just replace it with my camera device_id and auth access token to test it. The above examples are not clear for people who are not developers (like is the access_token the “c.kljhlkjhwrjth” code that postman return or is it just the text after the “c.” or something else)?

Also, we need to to get the current image (i.e. snapshot), not the last event as we want to capture live images at fixed intervals. So can you tell me the URL for a the snapshot?

Finally, now I am getting the error code below when I try to run [step 4] in the tutorial (https://codelabs.developers.google.com/codelabs/wwn-api-quickstart/#4). Is this because I already ran it once and have an auth code already or is there another problem I’ll need to sort out before I can get this to work.

A quick answer would be appreciated, I’m on a bit of a deadline. Thanks

"error": "input_error",
"error_description": "code must exist, client_id must exist, client_secret must exist, grant_type is not in list of valid values: authorization_code",
"instance_id": "_[instance ID ommited]_",
"errors": [
    {
        "label": "code",
        "format": "%s must exist",
        "params": [
            "code"
        ]
    },
    {
        "label": "client_id",
        "format": "%s must exist",
        "params": [
            "client_id"
        ]
    },
    {
        "label": "client_secret",
        "format": "%s must exist",
        "params": [
            "client_secret"
        ]
    },
    {
        "label": "grant_type",
        "format": "%s is not in list of valid values: %s",
        "params": [
            "grant_type",
            "authorization_code"
        ]
    }
]

}


#9

Hi,

I sent you a private message.

-Betsy


#10

Answer from Andrew Urman on Stack Overflow:

"web_url simply gives the URL to the page on home.nest.com. The user has to be logged in. Nest Cam is not an IP camera and streams are not currently available via the API. You would need to write something to scrape the web page at home.nest.com that would be able to stay logged in.”


#11

Would love to hear the actual response to: Capture image from camera via URL

I’m getting this exact same error message, albeit a different use case: setting temp on thermostat --where am I missing the passing of the vars? I am able to generate an Oauth2 token, but missing how/where I resolve this. Sidenote: have it working like a charm in Postman… Thoughts? Thanks all! Andy


#12

The upshot from my discussion with tech support (such as I remember it now) was that you can only capture from a nest camera via URL from a computer that is logged into your nest account on the same local network as the camera. So if you want to run timelapse on your own camera on the same network, it is possible, but if you want to capture from a camera that is not within your network (i.e. via a web url, etc), it would not be possible. The documentation doesn’t make this clear, since the capture calls do exit, but only under the constraint of being on the same network and (I think) the capture computer having login access and being logged in to the user’s NEST camera account


#13

I am VERY interested in grabbing an image from my Nest camera and sending it into my corporate slack channel. I am not seeing a simple way to make this happen. @betsyl is there somewhere you could point me?


#14

@vajramatt You can use https://developers.nest.com/documentation/cloud/api-camera#snapshot_url to grab the image. I don’t know how to send it to a Slack channel.


#15

Thank you, @jbumgardner. But where do I make a token? I am getting my device-id from the sharing page, I assume?


#16

@vajramatt You’ll have to create a client and go through the OAuth process with your user account first. After that you can use the API to get info from your camera.

Easiest way is to do our Quickstart Codelab, it goes through all the basics using Postman: https://codelabs.developers.google.com/codelabs/wwn-api-quickstart/index.html?index=..%2F..%2Findex#0

The comprehensive reference for authorization is here: https://developers.nest.com/documentation/cloud/how-to-auth

Other API read examples are here:
https://developers.nest.com/documentation/cloud/how-to-read-data