Rest Endpoint Setup

Setting up REST endpoints are about the worst development process I think i’ve ever come across on a developer platform. I’ve read just about every forum post I can at this point and it’s all shit and I just want to throw the whole thing in the trash because of it’s awfulness. Even when I get an access token and an installation URL’s I still can’t use them to get any response other than errors.Who knows if any of it’s right since nothing seems to be built in to smartthings and they want you to write your own ruby or curl requests just to access their API with a simple get request which is absolutely ridiculous.

If anybody has a FULL example that shows how this works I would be very appreciative. I don’t want help writing a ruby script, I don’t want to use curl, I want to know what the actual process smartthings has built into their system to access an end point from a simple web requests after you’ve built and published a smart app that has made one available.

I would be probably even more interested in how to bypass the whole rest endpoint bullshit and just hit a local URL and bypass all the bullshit of the cloud but i’m sure that’s a whole other headache in itself if it’s even allowed.

1 Like

First, can you explain what you are trying to accomplish with the endpoints? The ruby and curl snippets are just examples of how one might access an endpoint. The postman app in chrome is a very easy way to test rest endpoints without writing any code.

There are no local endpoints on the hub itself.

1 Like

Just trying to get the most basic setup described in the “Tutorial” to list some devices. Tutorial: Creating a REST SmartApp Endpoint

The fact that you need to use a third party tool just to get the URL to an end point helps illustrate my frustration of smartthings not making their development for their product self contained and incomplete. I get having the option to do it yourself but to not have the tools built in to complete their development concepts within their own environment is just a terrible design. Pair that with the inability to do local control to a URL you created on an IP device on YOUR network is just a awful architecture to force on a customer.

The link from the previous post is just one of the many spots I found information on how to accomplish this. There were plenty of other locations with other people trying to figure this out. Good thing there’s a good document somewhere that clearly explains everything in a good amount of detail to go off of…

I understand your frustration and we are working on making the getting started experience for new developers. One of the things we are doing is creating an API that does not require any knowledge of groovy or the SmartThings IDE to use.

The link you posted is a bit outdated and might be part of your problem.

Follow this guide:

http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/tutorial-part1.html

A complete overview can be found here

http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/index.html

The link you provided is really where I started this whole thing. It’s not the smartthings code I have a problem with, in that respect the documentation is decent. The app is published, it “works” in the simulator. Now what? I start using curl or ruby? That’s what the document suggests when after going back through this stuff again and ignoring any of the convoluted OAuth nonsense to get an access token, the documentation really just needs to say, here’s what a URL looks like, paste it into your browser. Why tell people to use another program when any browser can handle a URL and return the same JSON response you’re showing as a valid response? I’ll never agree with the inability to use local URL’s and always reliant on the cloud but I think I finally managed to suss out this convoluted end point URL structure.

This is why I asked you what you are trying to accomplish. oAuth is always going to be a factor and getting the token is part of that flow. The different examples are there to show how you would accomplish getting the token using different platforms. There is a PHP example in github.

We have a developer slack channel if you would like to get some realtime feedback as you work through this. Let me know if you would like an invite.

But it’s not a factor…At the end of the doc, all you do is take that end point from the simulator append the /switches (for GET) to it and it works. Why all the mess with OAuth if you don’t actually need it to work? And why not provide the auth token in the simulator to keep the development all within smartthings without requiring third party development? It just doesn’t make a whole lot of sense to tell people to develop on your platform but if you want to actually do the thing you’ve been developing, you have to go to third party development tools to finish it. I would appreciate an invite to the slack channel for future development.

I tend to agree with @SuperJonotron to a degree. As a long time developer I appreciate the level of flexibility that the SmartThings platform gives us, it’s great that the option is there. However I can’t help but feel that not having a reference implementation of a default Restful API severely limits the number and functionality of 3rd party integrations.

It would be really great if we could keep the current IDE’s flexibility but also had the option to extend a ST REST class that would come with a standardized set of endpoint all setup to return a standardized JSON schema. This would speed development immensely imho.

I do understand that doing things the way they are setup today mitigates, to a degree, some worries about having a single API key stolen ( Although you could just regenerate it ). But providing a reference ( Interface at the least, or an Abstract class we can override as needed ) would be fantastic. ( And doing it that way allows a per SmartApp API key still )

Honestly, for the few things I’ve done in SmartThings I’m more interested in what I’m coding locally then having to crawl the ST docs for device types and capabilities as well as dealing with Groovy since I had to learn that, and coming up with the json schema, error handling, boilerplate type logic, etc… +1 for hooking the reference into Swagger with proper documentation as well ;o)

If anyone knows of a project out there that is attempting this outside of Samsung I’m all ears!

/rant

1 Like

We are building this. The end goal is to have a smartapp that provides essential API functionality in a way that most developers are familiar with. We have the boilerplate smartapp and some example clients already built. We will probably release this SmartApp and client in the very near future.

Eventually we hope that this smartapp can be installed simply by filling out a form. After filling out the form you get your ID and Secret and you are ready to work with whatever external platform you want. No groovy knowledge required. That said, you might have noticed that we are currently experiencing a platform incident and won’t be able to get this released until we take care of that.

Message me with thoughts or concerns. Always happy for feedback.

That’s really great news, thanks @jody.albritton. I really enjoy working on a platform where we, the community, actually get replies :wink: I’m really interested to see how you’ve implemented the handling of devices Vs capabilities in the endpoints ( For instance, I want to get everything that can be switched on/off but in the reply I hope to get a full list of capabilities for each device returned along with all commands supported )

Also interested in seeing if / how you implemented a scenario where I want to send > 1 commands to > 1 capabilities. For example, I want to turn on switches 1,2,3 then set brightness to 50%.

Got more questions but I can be patient for a release :wink: Good luck with the platform issues, I’m sure ya’ll will get it sorted.

@jody.albritton Just wondering if there has been any update on a standardized REST API or otherwise extensible REST class for some OOTB web api setup? I’ve been out of the scene for a bit but just moved to a new place which always sparks my automation dev efforts. If nothing is in the works then I’ll just continue on with my homegrown smartapp. Thanks.

As far as I can tell from the documentation this still hasn’t changed? There’s no easy way to pull down data from the API without all the extra hassle of OAuth? (sorry for the old thread resurrect, first hit on google and looks like some good responses here from ST)

There is a new API and if you are just using it for personal use, you can manually generate the token you need pretty easily: