Integration of JSON data from HTTP/S API


#1

Hi,

I recently received a Wio Link-Kit from Seeed which provides his data over an HTTP/S API in a JSON-format.

For example:
https://iot.seeed.cc/v1/node/GroveTempHumD0/temperature?access_token=secrettoken

Output:
{“celsius_degree”: 24.0}

Would it be possible to provide a method to implement this into Cayenne dashboards?

If yes I could imagine that this would not be limited to a Wio Link device, but also to generic data inputs.
One completely different scenario that comes into my mind is the output from a Nagios plugin over the NCPA-Agent from their Web-API.


Low bandwidth alternative?
#2

Hi @gerhard.bruckner ,

Welcome to the Cayenne community! Yep, that’s actually what we’re working on right now. We will open up an API for Cayenne, where you can GET and POST data to the dashboard from virtually any device or third party. Hope this helps.

-B


#3

Thanks for the reply!

I cant wait to get my hands on testing this :slight_smile:

Kind regards,
Gerhard


#4

Hi @gerhard.bruckner,

I wanted to follow up with you here. We just released the Cayenne Beta MQTT API. You should be able to bring your board into Cayenne using this API. Would love if you gave it a try and update everyone on your progress!
http://www.cayenne-mydevices.com/docs/#bring-your-own-thing-api

Thanks,

-Benny


#5

Hi:
I saw via this Jul16 post that you were developing an API were we would comunicate via HTTP POST or GET.
Do you know if this is ready, because I haven´t seen in the documentation yet? I have also the same problem with some devices that I can´t connect to Cayenne because the only communication they have is via HTTP (and no MQTT).
Many thanks.


#6

@gerhard.bruckner @loslelazlo It is almost ready :slight_smile: Can you reply to this post so we can keep track of your requirements and also for Beta testing?

-Benny


#7

Hi, I try to use http api to connect to the server:
http://auth.mydevices.com?response_type=token&client_id=8e1d5af7-4850-4b52-999a-f27bbb396229&redirect_uri=http://localhost:8080&state=active

It shows an error:
Can’t read swagger JSON from http://auth.mydevices.com/swagger.json

Do you know how I can get this work?

Thanks


Now Live! Cayenne REST API for application developers
#8

Hi @xiaozhiyong1988,

Give us some time to look into this. We’ll get back to you!

Cheers,

~Benny


#9

Hi @xiaozhiyong1988, and welcome to the Cayenne Community.

This is a typo in our documentation which will be resolved soon, the URL should look like this instead:

https://auth.mydevices.com/oauth/authorization?response_type=token&client_id=YOUR APP ID&redirect_uri=APP REDIRECT&state=12345


#10

That’s fantastic! Now I get the correct address for getting authorization, but I am still receiving error message:

Invalid uri. What kind of uri I should use? I want to build local application to connect with mydevices. Thanks.


#11

You need to add a Redirect URI to your app as described in this part of the documentation.

You can add this redirect to your app by making a POST to https://auth.mydevices.com/applications/{id}/redirects

Example payload, you can use example.com to test it out first:

Make a POST call to

{
"redirect_uri":"http://example.com"
}

You can also make a GET call to /applications/{app id}/redirects to view your valid redirects.

edit: corrected a typo in the example payload provided above


#12

Thanks a lot! Enjoying develop with cayenne. I just have another question. Now I got the token and can do communication with auth server. However, I can not connect with the general api server: platform.mydevices.com.

I wonder is that another typo?

Get: http://platform.mydevices.com/v1.1/things shows connect error

Thank you very much!


#13

Hi @xiaozhiyong1988, thank you for your patience. I’ve asked one of our API developers to have a look at this latest post as I’m not familiar with it enough yet to know if that could be a typo (I don’t think so).


#14

Hi @xiaozhiyong1988, thanks for raising this issue. Looks like it’s another typo as it should be https and not http. Platform and Auth should both have calls being made over https.


#15

cool thanks.


#16

I have another question then. I use the authorization code that returns by the auth server to connect with the general api server and received an unauthorization message.
https://auth.mydevices.com/applications —this one work with the returned JWT Token
https://platform.mydevices.com/v1.1/things —this one does not work with the same JWT Token it says: unauthorization
thank you!


#17

Did you use a response_type=code when logging into oauth/authorization?

If so, you should receive a code value as code={CODE VALUE}
You can then use that value to make POST call to `https://auth.mydevices.com/oauth/token’ with the following payload:

{
   "client_id": "{your app key}",
   "client_secret": "{your app secret}",
   "code": "{your code value}",
   "grant_type": "authorization_code",
   "redirect_uri": "{redirect uri used when retrieving code}"
}

If successful, you’ll get an access_token in the response which will be authorized for https://platform.mydevices.com/

Another method is to use response_type=token which will then return an access_token value on a successful login to oauth/authorization


#19

Thanks for your response. I did follow your instruction and get the access_token but it still return an unauthorized message when I am trying to connect platform. I was wondering I did not finish the initialization in auth. I am trying to run all the code listed in the manual with connect to auth server. When I start with post an user:
https://auth.mydevices.com/users?first_name=&last_name=&email=&password=&application_id=*

it returns a message:
{
“statusCode”: 400,
“error”: “Bad Request”,
“message”: ““value” must be an object”,
“validation”: {
“source”: “payload”,
“keys”: [
“value”
]
}
}

Do you have an idea why it returns that?


#20

I am changing the parameters to a json playroad it works with only return the token. Then I use:
https://auth.mydevices.com/users to get the user I just posted and returns:
{
“statusCode”: 404,
“error”: “Not Found”
}


#22

Hi @xiaozhiyong1988,

To use the token, use the following format when adding authorization: Bearer ACCESS_TOKEN. We’ll update the docs to reflect this.

As for creating users, the correct endpoint will be https://auth.mydevices.com/applications/{APP KEY}/users. For this, you will need the following json payload:

{
   "email": "EMAIL",
   "message": "message"
}

You should now view your created user when issuing a GET to /applications/{APP KEY}/users.

Although you can add a user to your application, you (or the user) will not be able to access the account yet as the API is still in Beta phase.