Utility Methods API for PubNub Python-Asyncio SDK

The methods on this page are utility methods that don't fit into other categories.

Time

This function will return a 17 digit precision Unix epoch.

Algorithm constructing the timetoken
timetoken = (Unix epoch time in seconds) * 10000000

Example of creating a timetoken for a specific time and date:

08/19/2013 @ 9:20pm in UTC = 1376961606
timetoken = 1376961606 * 10000000
timetoken = 13769616060000000

Method(s)

To fetch Time you can use the following method(s) in Python SDK:

pubnub.time()

Basic Usage

Get PubNub Timetoken

envelope = await pubnub.time().future()
print('current time: %d' % envelope.result)

Returns

The time() operation returns a PNTimeResponse which contains the following operations:

MethodTypeDescription
intIntReturns an int representation of current timetoken.
strStringReturns a str representation of current timetoken.
date_timeDateReturns a date representation of current timetoken.

Do not confuse with timestamp() method, which is a shortcut to int(time.time()).

Get Subscribed Channels

Returns all the subscribed channels in a list.

Method(s)

To Get Subscribed Channels you can use the following method(s) in the Python-asyncio SDK:

pubnub.get_subscribed_channels()

Basic Usage

Get Subscribed Channels

channels = pubnub.get_subscribed_channels()

Returns

List

["my_ch1", "my_ch2"]

Get Subscribed Channel Groups

Returns all the subscribed channel groups in a list.

Method(s)

To Get Subscribe Channel Groups you can use the following method(s) in the Python-asyncio SDK:

pubnub.get_subscribed_channel_groups()

Basic Usage

Get Subscribed Channel Groups

channels = pubnub.get_subscribed_channel_groups()

Returns

List

["my_group1", "my_group2"]
Last updated on