Announcing presence WebHooks and new APIs

We’ve always been interested in creating a platform that integrates seamlessly with your applications, and provides the best possible user experience as developers. To this end, we’ve been working hard on features that expose the interactions your users have with the system. We previously released WebHooks to notify your server when a channel is occupied (the first user joins), or when it is vacated (read more). Today we’re expanding WebHooks to cover presence channels, and releasing some new APIs which allow you to query the state of your channels.

Presence WebHooks

While our initial WebHooks were well-received we immediately started getting requests to broadcast when individual users joined or left our powerful “presence channels”. Because we allow unlimited channel subscriptions per connection, our suggestion was previously to subscribe to a private channel based on the user’s id, which would trigger the necessary WebHooks. Now presence events are available directly as a different class of WebHook.

Getting set up for presence WebHooks is easy as pie. Simply log in to your dashboard, navigate to the App you want to receive WebHooks for, and enable them on the “WebHooks” tab. You will need to specify a URL where you want them to go, but that’s it.

The WebHook docs contain more info about what the payload looks like, and how to verify the authenticity of WebHooks.

Some libraries, such as our ruby gem, already support validating and extracting info from received WebHooks. If you are a library developer please consider adding this this functionality and get in touch if you want any assistance.

Querying occupancy/presence via our REST API

While WebHooks afford a very neat mechanism for keeping your server up to date with the subscriptions of your users, sometimes you need to fetch the initial state of the system that needs to be updated. We’ve tried to make this easier with a new set of API methods for querying your channels.

The following API methods are now available:

These features won’t be needed by all applications, but when they are, they open up powerful possibilities.

Getting occupancy counts from channels

The REST APIs for getting information about channels also allow a number of other interesting attributes to be returned. For example you can now query how many people are subscribed to each of your channels. Browse the available options in our REST reference docs.

Interacting via our Ruby Gem

We’ve added support for the new API methods to our ruby gem via a generic interface for making API requests, for example

Pusher.get('/channels', {:filter_by_prefix => 'private-'})

We’ll be working with library developers to update our other libraries as soon as we can.

Let us know what you think.

Ready to begin?

Start building your realtime experience today.

From in-app chat to realtime graphs and location tracking, you can rely on Pusher to scale to million of users and trillions of messages