---
source_url: https://www.pubnub.com/docs/presence/get-subscribed-channels-for-user
title: Get subscribed channels for a user
updated_at: 2026-09-30T07:20:08.000Z
---

# Get subscribed channels for a user

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

This guide shows you how to call `Where Now` to list which channels a [User ID](https://www.pubnub.com/docs/architecture/core-concepts.md#user-id) is currently subscribed to. Presence must be enabled on the keyset, and new keysets have it enabled by default. Most applications already know which channels a client subscribes to, since they're the ones that subscribed it. Reach for this call mainly when testing and troubleshooting, not as part of your regular application logic.

`Where Now` requires no channel-level permission when [Access Manager](https://www.pubnub.com/docs/security/access-control/overview.md) is enabled because it looks up a User ID rather than a channel.

## Get channels for the current client

Call `Where Now` with no User ID, or with the client's own User ID, depending on your SDK.

### JavaScript

```javascript
try {
  const response = await pubnub.whereNow({
    uuid: 'uuid',
  });
  console.log('State set successfully:', response);
} catch (error) {
  console.error(`State set failed: ${error}`);
}
```

### Python

```python
envelope = pubnub.where_now().sync()

print(envelope.result.channels)
```

### Java

```java
pubNub.whereNow().async(result -> {
    result.onSuccess((PNWhereNowResult res) -> {
        System.out.println("User is currently subscribed to following channels: " + res.getChannels());
    }).onFailure((PubNubException exception) -> {
        // Handle errors if the request fails
        System.err.println("Error retrieving whereNow data: " + exception.getMessage());
        exception.getPubnubError();
        exception.getCause();
        exception.getStatusCode();
    });
});
```

### Kotlin

```kotlin
pubnub.whereNow()
    .async { result ->
        result.onFailure { exception ->
            // Handle error
        }.onSuccess { value ->
            // Handle successful method result
        }
    }
```

### C#

```csharp
using PubnubApi;

// Configuration
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize PubNub
Pubnub pubnub = new Pubnub(pnConfiguration);
        
PNResult<PNWhereNowResult> wherenowResponse = await pubnub.WhereNow()
    .ExecuteAsync();

PNWhereNowResult wherenowResult = wherenowResponse.Result;
PNStatus status = wherenowResponse.Status;
// returns a pojo with channels
// channel groups which I am part of.
```

### Go

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_whereNowCurrentUser demonstrates getting channels for current user
func Example_whereNowCurrentUser() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo"
	config.PublishKey = "demo"

	pn := pubnub.NewPubNub(config)

	// Get channels for current user (omit UUID parameter)
	_, status, err := pn.WhereNow().
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		fmt.Println("WhereNow for current user successful")
	}

	// Output:
	// WhereNow for current user successful
}
```

### Swift

```swift
// Get the channels that a specific UUID is present on
pubnub.whereNow(for: "my-unique-uuid") { result in
  switch result {
  case let .success(channelsByUUID):
    print("A `Dictionary` of UUIDs mapped to their respective `Array` of channels they have presence on \(channelsByUUID)")
    if let channels = channelsByUUID["my-unique-uuid"] {
      print("The list of channel identifiers for the UUID `my-unique-uuid`: \(channels)")
    }
  case let .failure(error):
    print("Failed WhereNow Response: \(error.localizedDescription)")
  }
}
```

Most PubNub SDKs default to the client's own User ID when you omit one, though some expect you to pass it explicitly. The JavaScript example above passes it explicitly. Check the parameter table in your platform's [API reference](https://www.pubnub.com/docs/sdks.md) before assuming which applies.

## Get channels for another User ID

Pass a specific User ID to look up a different client instead of the one making the call.

### Python

```python
envelope = pubnub.where_now() \
    .uuid('some-other-user-id') \
    .sync()
```

### Java

```java
pubNub.whereNow().uuid("some-other-uuid").async(result -> {
    result.onSuccess((PNWhereNowResult res) -> {
        System.out.println("some-other-uuid is currently subscribed to following channels: " + res.getChannels());
    }).onFailure((PubNubException exception) -> {
        // Handle errors if the request fails
        System.err.println("Error retrieving whereNow data: " + exception.getMessage());
        exception.getPubnubError();
        exception.getCause();
        exception.getStatusCode();
    });
});
```

### Kotlin

```kotlin
pubnub.whereNow(
    uuid = "someUuid"
).async { result ->
    result.onFailure { exception ->
        // Handle error
    }.onSuccess { value ->
        // Handle successful method result
    }
}
```

### C#

```csharp
using PubnubApi;

// Configuration
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
{
    SubscribeKey = "demo",
    PublishKey = "demo",
    Secure = true
};

// Initialize PubNub
Pubnub pubnub = new Pubnub(pnConfiguration);
        
PNResult<PNWhereNowResult> wherenowResponse = await pubnub.WhereNow()
    .Uuid("some-other-uuid") // uuid of the user we want to spy on.
    .ExecuteAsync();

PNWhereNowResult wherenowResult = wherenowResponse.Result;
PNStatus status = wherenowResponse.Status;
// returns a pojo with channels
// channel groups which "some-other-uuid" part of.ere_now_example_1
```

### Go

```go
// Replace with your package name (usually "main")
package pubnub_samples_test

import (
	"fmt"

	pubnub "github.com/pubnub/go/v10"
)

// Example_whereNow demonstrates getting channels a UUID is subscribed to
func Example_whereNow() {
	config := pubnub.NewConfigWithUserId(pubnub.UserId("demo-user"))
	config.SubscribeKey = "demo"
	config.PublishKey = "demo"

	pn := pubnub.NewPubNub(config)

	// Get list of channels a specific UUID is subscribed to
	response, status, err := pn.WhereNow().
		UUID("some-user-uuid").
		Execute()

	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}

	if status.StatusCode == 200 {
		fmt.Println("WhereNow request successful")
		fmt.Printf("Channels: %v\n", response.Channels)
	}

	// Output:
	// WhereNow request successful
	// Channels: []
}
```

A User ID that connects with multiple devices returns the union of channels across all of them, since presence tracks the User ID, not the individual connection. Refer to [Presence](https://www.pubnub.com/docs/presence/overview.md#how-presence-delivers-its-data) for what that means when the same User ID has more than one device connected at once.

## Related tasks

* [Get online users in a channel](https://www.pubnub.com/docs/presence/get-online-users-in-channel.md). Call `Here Now` to list current subscribers and their state.
* [Set and get presence state](https://www.pubnub.com/docs/presence/set-and-get-presence-state.md). Attach and read the custom state a client sets while subscribed.
* [Presence](https://www.pubnub.com/docs/presence/overview.md). How presence data is enabled and delivered.
* [Core concepts](https://www.pubnub.com/docs/architecture/core-concepts.md#user-id). What a User ID identifies and how billing counts it.

Last updated at: 2026-09-30T07:20:08.000Z
