Questions about REST API


I have some internal applications that use Ruby on Rails where I’d like to integrate some data from our Opto controllers. Has anybody written a wrapper class for the REST API that they’re happy with (even if not in Ruby)? Or is there some other way I should be going about this?


So, you’re looking for some Ruby slippers? (Har! Just teasing, can’t resist the chance to toss in a Wizard of Oz…)

Anyway, should be a pretty thin wrapper, perhaps parsing the JSON would be the hardest part. Is this just a GET to read/monitor, or also a POST for write/control?

I find this Ruby on Rails HTTP cheat sheet:
that might be helpful, but a few more questions for you:

Which REST API do you mean? (I’m guessing SNAP PAC vs. groov since you mentioned controllers?) Also hoping you can use http vs. https since that will make things much easier, too?

Note that if you can put your data from the controller into table(s) that might be easier when you get to the parsing part, also a little less overhead on the wire, if that matters.



Mary… I’ll gladly take some Ruby slippers.

My plan was to keep the wrapper pretty slim. I need to be able to both read from and write to a PAC controller. Parsing JSON is a piece of cake in Ruby, so that’s not the hard part. I’m fine using non-secure HTTP.

I think what I’m most concerned about is overhead on the wire, as you put it. I don’t want to overload the controller by making too many requests, but I also don’t want to do a crazy amount of extra programming/formatting of variables on the controller. I’d like to keep both ends as natural as possible.


We use Swagger to specify our APIs. Ideally, you should be able to use Swagger’s code generator to quickly generate a Ruby API.

For controllers, you can find the documentation and Swagger spec here:

And for groov, here:


Thanks for the link, Jonathan. I’ve never looked at the code generator before, but I’ll definitely check it out.


If anybody is interested in this, I’ve created a wrapper class in Ruby and bundled it into a gem. The project is available on my Github. I’m pretty happy with how well it works.


Excellent! Thank you. Just curious, did you try the swagger-generated code at all? (When I first tried it a couple years ago it was still a bit buggy and required some “adjustments” but I’m guessing it’s better now.)


I very briefly looked at the Swagger-generated code, but not too much. Their code generator seemed complicated, and when I ran it, it generated a ton of source files. It just didn’t really seem like what I was looking for.


Yeah seemed a bit overkill if you just wanted to do a few POST/GET commands.
Thanks for sharing your nice wrapper!