PubNub
APIManaged realtime pub/sub with presence, history, chat SDKs and mobile push
- Access
- Publish and subscribe keys
About
Managed realtime network: apps publish and subscribe to channels through SDKs or a REST API, with presence, message history, user and channel metadata, access tokens and Functions. Chat SDKs and APNs and FCM push build on it. Billing is by monthly active users; the free plan covers 200.
What you can do with it
- Stream live updates, game state or device events to apps over channels
- Add chat with threads, reactions, typing indicators and read receipts
- Forward channel messages to phones as APNs and FCM push notifications
Get started
- Sign up in the Admin Portal and copy the publish and subscribe keys
- Install an SDK, for example npm install pubnub
- Subscribe to a channel, then publish messages to it
Example
// npm install pubnub
const PubNub = require('pubnub');
const pubnub = new PubNub({
publishKey: 'YOUR_PUBLISH_KEY',
subscribeKey: 'YOUR_SUBSCRIBE_KEY',
userId: 'quickstart-user',
});
const channel = pubnub.channel('quickstart-channel');
const subscription = channel.subscription();
subscription.onMessage = (event) => {
console.log('Message received:', event.message.text);
};
// Publish only once the subscription is connected
pubnub.addListener({
status: (event) => {
if (event.category === 'PNConnectedCategory') {
pubnub
.publish({ channel: 'quickstart-channel', message: { text: 'Hello, PubNub!' } })
.catch((error) => console.error('Publish failed:', error));
}
},
});
subscription.subscribe();Details
- Hosting
- Hosted service
- Available in
- Worldwide
- Official SDKs
- JavaScript/TypeScript, Python, Java, Kotlin, Swift, C#, Go, PHP, Ruby, Rust, Dart
- MCP server
- Remote
- Works with
- Unity, Unreal