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.
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.
To publish a message, issue a GET Request in the following format:
http://pubsub.pubnub.com /publish /pub-key /sub-key /signature /channel /callback /messageExample:
http://pubsub.pubnub.com /publish /demo /demo /0 /hello_world /0 /%22Hello%20World%22
To subscribe and receive messages, issue a GET request in the following format:
http://pubsub.pubnub.com /subscribe /sub-key /channel /callback /timetokenExample:
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
To load publish history, issue a GET request in the following format:
http://pubsub.pubnub.com /history /sub-key /channel /callback /limitExample:
http://pubsub.pubnub.com /history /demo /hello_world /0 /10
We recommend using our Client Push APIs. Find them on GitHub in your language.