This document descibes how to use PubNub JSON/JSONP REST API with HTTP GET. PubNub APIs are available in many programming languages. Visit the following link to download your language. We are building many Client APIs which hook ito PubNub Publish/Subscribe. If one is not available in your language, contact us and we will add it.

Realtime Software Development Resources, Tutorials & SDKs

Grab your PubNub Realtime Network API Keys
Get Publish and Subscribe API Keys. You need the Publish and Subscribe Keys for now. Ignore the Secret Key unless you are interested in reading more about PubNub Security Access Manager.

PUBLISH

To publish a message, issue a GET Request in the following format:

http://pubsub.pubnub.com
/publish
/pub-key
/sub-key
/signature
/channel
/callback
/message
Example:
http://pubsub.pubnub.com
/publish
/demo
/demo
/0
/hello_world
/0
/%22Hello%20World%22

PUBLISH TEST:
http://pubsub.pubnub.com/publish/demo/demo/0/hello_world/0/%22Hello%20World%22

SUBSCRIBE

To subscribe and receive messages, issue a GET request in the following format:

http://pubsub.pubnub.com
/subscribe
/sub-key
/channel
/callback
/timetoken
Example:
http://pubsub.pubnub.com
/subscribe
/demo
/hello_world
/0
/0

You will receive a response as an array. The first element of the array will be an empty array (at first) and the second is a timetoken. You must use this timetoken response from the server at every following request. Each response will have a brand new timetoken. So you must replace the old timetoken each time.

// Initial Response
[[],"9718304464409"]

Take the "timetoken" value and place it in the following request like this:

http://pubsub.pubnub.com
/subscribe
/demo
/hello_world
/0
/9718304464409

SUBSCRIBE TEST:
http://pubsub.pubnub.com/subscribe/demo/hello_world/0/0

HISTORY

To load publish history, issue a GET request in the following format:

http://pubsub.pubnub.com
/history
/sub-key
/channel
/callback
/limit
Example:
http://pubsub.pubnub.com
/history
/demo
/hello_world
/0
/10

HISTORY TEST:
http://pubsub.pubnub.com/history/demo/hello_world/0/10

We recommend using our Client Push APIs. Find them on GitHub in your language.

Download PubNub Realtime Network Push SDKs

Loading...