How to show if a camera is online with the nest api - nest-api

I'm working on a website that contains multiple Nest cameras and I wonder if it is possible to display if a camera is online before a user clicks on the link to view this cam.
I would do it with a XMLRequest in javascript but I cant find how to do it.

You would make a REST call for it, HTTP GET specifically. The request url would look like this:
https://developer-api.nest.com/devices/cameras/<device_id>/is_online?auth=<auth_token>
Using cURL it would look like this:
curl -v -L -H
"Authorization: Bearer <auth_token>"
-X GET "https://developer-api.nest.com/devices/cameras/<device_id>/is_online"
Reference: https://developer.nest.com/documentation/api-reference/overview#cameras

Related

How can I make this API call from my Nodejs program?

A member of my team developed this API where you send some numeric values and it gives you back a probability. He deployed it in Heroku and sent me the task of connecting it with our backend, you can make the call from cmd like this:
curl -d "{\"Values\":[[value1,value 2,value 3,value 4,value 5]]}" -H "Content-Type: application/json" -X POST https://apibc1.herokuapp.com/predict
And it will work just like intended, but to be honest I don't know how to make this call in my server file, I'm trying to use the request package in Node but I keep getting the invalid URI error on my logs. An example of the API working from cmd:
And this is what happens when I make the same call in my server.js file:
If you have a working curl you can import it into postman and generate a working code sample for a lot of languages.
Import the curl request
Then click the code button on the right
and select a language/framework option from the dropdown

Get list of files name and path in whole google cloud with a particular file extension using NodeJS

I have a google cloud bucket which is having the files with the extension .jtl, I need to get these file names and paths irrespective of the nesting of folders they are in using NodeJS.
How can we do that!
I think this link might help you
https://cloud.devsite.corp.google.com/storage/docs/json_api/v1/objects/list
You can try this API, and give the preferred parameters present in that,
for example: in your case you can give delimiter as jtl, and then you can copy the curl command or http or node JS as you prefer and execute this in your google cloud platform
The command will look something like this:
curl
'https://storage.googleapis.com/storage/v1/b/xyz12345/o?delimiter=jpg&includeTrailingDelimiter=true&key=[YOUR_API_KEY]'
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]'
--header 'Accept: application/json'
--compressed
Provide your API key and Access token to be able to run this in your google cloud platform.

Activating Google Speech API in Firebase CLI?

I get this error when I try to use Google Speech from either the cmd command line (Windows 10) using curl or from a local Firebase server.
"Cloud Speech API has not been used in project firebase-cli before or
it is disabled. Enable it by visiting
https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=firebase-cli
then retry"
Going to the suggested URL just gives the message:
The API "speech.googleapis.com" doesn't exist or you don't have permission to access it
The curl command has worked before. Login seems to work (using Bearer header). I have no idea why it does not work now. Did I do something before that made it work? Or is there some change to Firebase CLI/Google Speech?
EDIT: Here is the curl command that worked before. I do not think it matters here, but someone might be interested still:
#for /f %%i in ('gcloud auth application-default print-access-token') do #set bearer=%%i
curl -X POST ^
-H "Authorization: Bearer %bearer%" ^
-H "Content-Type: application/json; charset=utf-8" ^
--data #request-flac.json ^
"https://speech.googleapis.com/v1/speech:longrunningrecognize"
Follow the Cloud Speech API quickstart. There is a button that will help you enable the API in your project. If you don't want to do it that way:
Go to the GCP console
Select the APIs and Services option in the left menu
Select dashboard
Click Enable APIs and Services
Type "speech" in the search box
Click the "Speech API" card
Click Enable
This is the generalized way to enable APIs in your project.

401 Unauthorized when trying to grab playlists using Spotify API

I've pulled a client_credentials token and while I can access other parts of the API, I can't seem to pull playlist information. It's definitely a public playlist, yet I'm getting 401 Unauthorized. Am I just misunderstanding something?
Edit
For example, this works:
puts curl -I -s -X GET "https://api.spotify.com/v1/users/#{testUser}" -H "Authorization: Bearer {#{#accessToken}}"
This does not:
puts curl -I -s -X GET "https://api.spotify.com/v1/users/#{testUser}/playlists/#{testPlaylist}?fields=href,name,owner(!href,external_urls),tracks.items(added_by.id,track(name,href,album(name,href)))" -H "Authorization: Bearer {#{#accessToken}}"
Are you sure you are sending the credentials cookie as part of your request? If you're not sure, you can use Wireshark or a similar tool to see the details of your request.
Edit: Relevant doc, but you've probably already seen this:
https://developer.spotify.com/web-api/get-playlist/

csrf token in bluemix deployed node instance

Hi I used the deploy to bluemix button at the top right of this page
https://alchemy-language-demo.mybluemix.net/?cm_mc_uid=69990450306114782046823&cm_mc_sid_50200000=1478206651
to create an Alchemy language node server. It runs ok -
https://alchemylanguage-nodejs-encekxdev-216.mybluemix.net/
but when I try to post to it using postman I get the response 'internal server error'.
Checking the server logs, it seems to respond to the request with
code: 'EBADCSRFTOKEN', error: 'invalid csrf token'
Even if I try to send the csrf from the webpage version of the site, it still doesn't work.
I feel like I have missed something in the configuration of the server but don't know what. I'm not great with servers etc so sorry if this is super basic.
EDIT - I should mention I have also tried sending an apikey in the request which I got from the service credentials section in the alchemy service bit off the dashboard but the same error occurs.
EDIt - The call to the API I am making looks like this:
POST https://alchemylanguage-nodejs-encekxdev-216.mybluemix.net/api/keywords
with headers:
text: 'this is some dummy text I have made'
I have also tried adding apikey to the headers.
Thanks.
You do not POST your application, you have to POST to the API.
Here is the link with API URL and various samples:
http://www.ibm.com/watson/developercloud/alchemy-language/api/v1
For example, here is a curl request for keywords:
curl -X POST \
-d "outputMode=json" \
-d "url=http://www.twitter.com/ibmwatson" \
"https://gateway-a.watsonplatform.net/calls/url/URLGetRankedKeywords?apikey=$API_KEY"
Make sure you export $API_KEYto your environment before running the command above. You can find the $API_KEY in the AlchemyAPI instance you created in Bluemix.

Resources