Use Pusher's Realtime Reddit API to build engaging Reddit app on Mobile or the Web. Completely free and unlimited.
Pusher is the perfect platform for turning a static, REST-based API like Reddit’s into a smooth, realtime API utilising the power of WebSockets. The best bit? You don’t need to change anything with an existing REST API to do this!
We love Reddit at Pusher. You don’t have to take our word for it though, with over 731 million unique visitors last year, and over 40 million story submissions, it’s a pretty big deal however you look at it. It’s a weird and wonderful place, whether you want to keep up to speed with programming and JavaScript, or simply just want to see beautiful photos of planet Earth, Reddit has it all (and then some).
While Reddit is great, it’s a static experience in which you have to refresh the website to see new stories — you can’t sit back and let them come to you as they happen.
The solution? Building a realtime Reddit API that allows you to subscribe to a subreddit (content on a particular topic, like JavaScript) and receive every single public story posted within it. This is what we’ve built, open and free for everyone.
While a realtime Reddit API sounds amazing, what can you actually make with one and why is it useful?
The simplest and most obvious thing to do is to provide a realtime feed of stories in some sort of Web app, allowing you to sit back and consume Reddit as it happens. Sort of like Twitter for Reddit.
For a little more productivity, you could automatically monitor the realtime feed of story submissions and monitor it for particular keywords (eg. your business or product). By then using something like SendGrid to send an email alert you can have an immediate awareness and response on Reddit as events occur of interest you.
Like the email alert example, you could also use the realtime feed to monitor keywords and have stories automatically published to wherever you and your team would prefer the information to be displayed (like a Hipchat or Slack chatroom).
There are plenty of other uses for an API like this that haven’t even been dreamed up yet. With such a wealth of data at your fingertips it’s nearly impossible not to find some way to use it productively.
The Pusher Realtime API follows a basic structure. Here is an overview:
50ed18dd967b455393ed
(you’ll need this to connect to it)new-listing
event (how to subscribe)That’s it. We’ve tried to keep things as close to the Reddit REST API as possible.
The Pusher Realtime Reddit API has been built with simplicity in mind. All you need to do is subscribe to any subreddit using one of Pusher’s free platform libraries and decide what you want to do with each story.
Here’s an example that subscribes to the “/r/AskReddit” subreddit using JavaScript and outputs each new story to the browser console:
1<!-- Include the Pusher JavaScript library --> 2<script src="http://js.pusher.com/2.2/pusher.min.js"></script> 3 4<script> 5 // Open a Pusher connection to the Realtime Reddit API 6 var pusher = new Pusher("50ed18dd967b455393ed"); 7 8 // Subscribe to the /r/AskReddit subreddit (lowercase) 9 var subredditChannel = pusher.subscribe("askreddit"); 10 11 // Listen for new stories 12 subredditChannel.bind("new-listing", function(listing) { 13 // Output listing to the browser console 14 console.log(listing); 15 }); 16</script>
You can see a working, interactive code example of this on JSBin. It’s not a huge step to take things from here and start visualising new stories in some way.
We’ve built a simple demo that lets you subscribe to realtime updates from any public subreddit (viewer discretion is strongly advised).
Give it a go and see how it inspires you to create your own application using the Pusher Realtime Reddit API. If you’re looking to dive into the good stuff, you can find the Github repo here.
Thinking of making something with this free, no-limits API? Let us know when you have, we’d love to see it!