Can non-Particle device subscribe to events?

Is there any way for a non-particle devices to subscribe to cloud events? I think it would be useful for third-party software (I’m thinking of a user-space Linux process) to subscribe to events from Particle devices (or vice versa). I could probably cook up something to meet my needs with Webhooks, but it seems like this would generally useful enough that something “official” may already exist.

Yes, you can do this using the Server-Sent-Events (SSE) data stream.

Here are some useful examples in node.js, but it works for anything that supports SSE. I also capture all of my events using a Java SSE client and store them in MySQL, for example.

2 Likes

Thanks - that’s very interesting and looks promising! How about the other direction? Is there a way to publish events that the Particle devices can subscribe to?

Yes, it’s super easy with node.js and the Particle API JS to send events from your server.

But you can do it from any language that can target the Particle REST API (Java, PHP, Python, whatever).

1 Like

Thanks again - A little more digging and I found the API docs for publishing events - should have been able to find that on my own!

1 Like