Comprehensive Ruby client for the Particle cloud API

Hello all,

I’ve written a Ruby client for the Particle cloud API. I wanted something that is comprehensive so it includes the device API, the login/token API, the publish API and the webhook API.

The only omission is the subscribe API since the default Ruby HTTP client doesn’t supports streaming responses. This didn’t seem too bad since I expect this Ruby gem to be used mostly in web applications like Rails and using webhooks to receive events makes more sense in a web application than using subscribe.

The interface is object oriented so you can do things like

Particle.device('lighting').function('changeColor', 'blue')
Particle.publish(name: "wakeup", private: true)
connected_devices = Particle.devices.select { |device| device.connected? }
connected_devices.each { |device| device.flash('blink_led.ino') }

Go check out the particlerb repository and star it!

I took a look at RubySpark repository by @nixpulvis and @efatsi but I wanted to take a different approach with wrapping the API and providing uniform error handling. Still I want to thank you both for your work.

Comments are of course welcome.

3 Likes

Awesome work! For a while I dreamed of building out RubySpark to include more of the API, never found the time or motivation. I’m glad Ruby has a comprehensive client now!

2 Likes

I’ll have to give this a try. We’ve been using RubySpark (which is super cool, too, btw, thanks for putting that out @efatsi ), but this seems to cover a lot more ground.

1 Like

Great. Let me know if you have any comments/suggestions.