RapidAPI logo

PubNub

FREE
By dimashirokov
Updated 6 months ago
Communication
-/10
Popularity Score
-
Latency
-
Success Rate

PubNub API Documentation

Apply real-time publish/subscribe messaging to your program.

View API Details
POSTgetUserState
POSThereNow
POSTpresence
POSTpublishMessage
POSTwhereNow
POSTgetUserState

The state API is used to get key/value pairs specific to a subscriber uuid.

Header Parameters
X-RapidAPI-HostSTRING
REQUIRED
X-RapidAPI-KeySTRING
REQUIRED
Required Parameters
channelsLIST
REQUIREDSpecifies the `channel` name to return occupancy results. If `channel` is not provided, `hereNow()` will return data for all `channels`. (`ch1`, `ch2`, `ch3`)
uuidSTRING
REQUIREDRequired: UUID to use, if not passed, a random will be generated.
subscribeKeyCREDENTIALS
REQUIREDRequired: The subscribe key obtained from PubNub.
Optional Parameters
channelGroupsLIST
OPTIONALThe channel group for which here now information should be received. (`ch1`, `ch2`, `ch3`)
cipherKeySTRING
OPTIONALIf passed, will encrypt the payloads.
authKeySTRING
OPTIONALIf PAM enabled, this key will be used on all requests.
Code Snippet
unirest.post("https://PubNubdimashirokovV1.p.rapidapi.com/getUserState")
.header("X-RapidAPI-Host", "PubNubdimashirokovV1.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.header("Content-Type", "application/x-www-form-urlencoded")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
Sample Response
General
Request URL: https://PubNubdimashirokovV1.p.rapidapi.com/getUserState
Request Method: POST
Response Headers
Response Body

Install SDK for NodeJS

Installing

To utilize unirest for node.js install the the npm module:

$ npm install unirest

After installing the npm package you can now start simplifying requests like so:

var unirest = require('unirest');

Creating Request

unirest.post("https://PubNubdimashirokovV1.p.rapidapi.com/getUserState")
.header("X-RapidAPI-Host", "PubNubdimashirokovV1.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.header("Content-Type", "application/x-www-form-urlencoded")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication