---
source_url: https://www.pubnub.com/docs/sdks/asyncio/api-reference/misc
title: Utility Methods API for Python-Asyncio SDK
updated_at: 2026-06-18T11:26:55.415Z
sdk_name: PubNub Python Asyncio SDK
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Utility Methods API for Python-Asyncio SDK

PubNub Python Asyncio SDK

Install:

```bash
pip install pubnub
```

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.

:::note Algorithm constructing the timetoken
```javascript
timetoken = (Unix epoch time in seconds) * 10000000
```
Example of creating a timetoken for a specific time and date:
```javascript
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:

```python
pubnub.time()
```

### Sample code

#### Get PubNub timetoken

:::tip Reference code
This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.
:::

```python
import asyncio
import os
from pubnub.pnconfiguration import PNConfiguration
from pubnub.pubnub_asyncio import PubNubAsyncio
from pubnub.exceptions import PubNubException

async def get_pubnub_time(pubnub: PubNubAsyncio):
    try:
        # Get PubNub Timetoken
        envelope = await pubnub.time().future()
        print(f"Current time: {envelope.result}")

    except PubNubException as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)

    # Configuration for PubNub instance
    pn_config = PNConfiguration()
    pn_config.subscribe_key = os.getenv('SUBSCRIBE_KEY', 'demo')
    pn_config.user_id = "my_custom_user_id"

    pubnub = PubNubAsyncio(pn_config)

    try:
        loop.run_until_complete(get_pubnub_time(pubnub))
    finally:
        loop.run_until_complete(pubnub.stop())
        loop.close()
```

### Returns

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

| Method | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| int | Int | Optional |  | Returns an `int` representation of current timetoken. |
| str | String | Optional |  | Returns a `str` representation of current timetoken. |
| date_time | Date | Optional |  | Returns 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:

```python
pubnub.get_subscribed_channels()
```

### Sample code

#### Get subscribed channels

```python
channels = pubnub.get_subscribed_channels()
```

### Returns

`List`

```python
["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:

```python
pubnub.get_subscribed_channel_groups()
```

### Sample code

#### Get subscribed channel groups

```python
channels = pubnub.get_subscribed_channel_groups()
```

### Returns

`List`

```python
["my_group1", "my_group2"]
```