⬢
1.
Getting Started
Before you start using the API you need to include the Pusher JavaScript library. We host this on a blazing-fast CDN so you can quickly get up and running.
- You can also use any of our other Client Libraries
<script src="//js.pusher.com/2.2/pusher.min.js"></script>
⬢
2.
Subscribe to the Realtime Product Hunt API
Subscribing to the Realtime Product Hunt API is a simple 2-step process — open a connection to Pusher using the free API key, then subscribe to the Realtime Product Hunt channel. Nothing more!
-
New posts are emitted using the
new-postsevent - Post data follows the standard Product Hunt JSON formatting
/// Open a Pusher connection to the Realtime Product Hunt API
var pusher = new Pusher("7c1db8905b12d9aa6a03");
var phChannel = pusher.subscribe("ph-posts");
⬢
3.
Listen for new posts
Once you've subscribed to the Realtime Product Hunt channel you can receive new posts in a simple JSON format using an event listener.
-
The Pusher application key is
7c1db8905b12d9aa6a03 -
The Product Hunt Pusher channel is
ph-posts
// Listen for new posts
phChannel.bind("new-post", function(post) {
// Output post to the browser console
console.log(post);
});
⬢
4.
You are done, it's that easy!
You're now receiving every single Product Hunt post as soon as they happen. What could you do with this data? The positibilities are endless!
- Track keywords and notify yourself or others when a new post contains them.
- Get detailed information about the author of each post.
- Display posts in new and exciting ways.