# Activity selectors

Activity selectors give you control over which data is shown in a feed. For example you can decide to show only popular activities, or activities that fit the current user's interests.

This page details what kind of activity selectors are supported by the Stream API, and how can you configure them.

## Selector types

### Current Feed Selector

Shows activities from the current feed. This is the selector used when reading a `user` feed.

#### Parameters

| Name          | Type                                              | Description                                       | Default     | Required |
| ------------- | ------------------------------------------------- | ------------------------------------------------- | ----------- | -------- |
| `cutoff_time` | string, must be formatted as an RFC3339 timestamp | Activities older than this date won't be selected | Last 7 days | No       |

#### Scope

The feed we're currently reading

#### Example

<codetabs>

<codetabs-item value="nodejs" label="Node">

```js
const last10Days = new Date(Date.now() - 10 * 24 * 60 * 60 * 1000);

const view = await client.feeds.createFeedView({
  view_id: "current_feed_view",
  activity_selectors: [
    {
      type: "current_feed",
      // Optionally provide cutoff time
      cutoff_time: last10Days.toISOString(),
    },
  ],
});

const response = await client.feeds.createFeedGroup({
  feed_group_id: "myid",
  default_view_id: view.feed_view.view_id,
});
```

</codetabs-item>

<codetabs-item value="go-golang" label="Go">

```go
package main

import (
    "context"
    "log"
    "time"

    "github.com/GetStream/getstream-go/v3"
)

func main() {
    client, err := getstream.NewClient("<your_api_key>", "<your_api_secret>")
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    feedsClient := client.Feeds()

    // Calculate cutoff time (10 days ago)
    last10Days := time.Now().Add(-10 * 24 * time.Hour)

    // Create view with current feed selector
    view, err := feedsClient.CreateFeedView(ctx, &getstream.CreateFeedViewRequest{
        ViewId: getstream.PtrTo("current_feed_view"),
        ActivitySelectors: []getstream.ActivitySelector{
            {
                Type: getstream.PtrTo("current_feed"),
                // Optionally provide cutoff time
                CutoffTime: getstream.PtrTo(last10Days.Format(time.RFC3339)),
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("Current feed view created: %s", *view.Data.ViewId)

    // Create feed group with the view
    response, err := feedsClient.CreateFeedGroup(ctx, &getstream.CreateFeedGroupRequest{
        FeedGroupId:   getstream.PtrTo("myid"),
        DefaultViewId: view.Data.ViewId,
        Custom: map[string]interface{}{
            "description": "Feed group with current feed selector",
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("Feed group created: %+v", response.Data)
}
```

</codetabs-item>

</codetabs>

### Following Feed Selector

Shows activities from feeds the current feed follows. This is the selector used when reading a `timeline` feed.

#### Parameters

| Name          | Type                                              | Description                                       | Default     | Required |
| ------------- | ------------------------------------------------- | ------------------------------------------------- | ----------- | -------- |
| `cutoff_time` | string, must be formatted as an RFC3339 timestamp | Activities older than this date won't be selected | Last 7 days | No       |

#### Scope

Feeds followed by the feed we're currently reading

#### Example

<codetabs>

<codetabs-item value="nodejs" label="Node">

```js
const last10Days = new Date(Date.now() - 10 * 24 * 60 * 60 * 1000);

const view = await client.feeds.createFeedView({
  view_id: "following_feed_view",
  activity_selectors: [
    {
      type: "following",
      // Optionally provide cutoff time
      cutoff_time: last10Days.toISOString(),
    },
  ],
});

const response = await client.feeds.createFeedGroup({
  feed_group_id: "myid",
  default_view_id: "following_feed_view",
});
```

</codetabs-item>

</codetabs>

### Popular Activity Selector

Selects popular activities from public and visible feeds.

Popularity is computed by the following formula:

```js
activity.popularity = reactions + comments * 2 + bookmarks * 3 + shares * 3;
```

#### Parameters

| Name             | Type                                              | Description                                               | Default | Required |
| ---------------- | ------------------------------------------------- | --------------------------------------------------------- | ------- | -------- |
| `min_popularity` | number (only positive numbers are accepted)       | Minimum popularity an activity should have to be selected | `0`     | No       |
| `cutoff_time`    | string, must be formatted as an RFC3339 timestamp | Activities older than this date won't be selected         | -       | No       |

#### Scope

Any feed with `public` or `visible` visibility level.

<codetabs>

<codetabs-item value="nodejs" label="Node">

```js
const last10Days = new Date(Date.now() - 10 * 24 * 60 * 60 * 1000);

const view = await serverClient.feeds.createFeedView({
  view_id: "popular_feed_view",
  activity_selectors: [
    {
      type: "popular",
      // Optional parameters
      min_popularity: 70,
      cutoff_time: last10Days.toISOString(),
    },
  ],
});

const response = await client.feeds.createFeedGroup({
  feed_group_id: "myid",
  default_view_id: "popular_feed_view",
});
```

</codetabs-item>

</codetabs>

### Proximity Activity Selector

Shows activities based on geographic proximity

#### Parameters

| Name             | Type                                              | Description                                                                | Default     | Required                                                                        |
| ---------------- | ------------------------------------------------- | -------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------- |
| `filter`         | object, see [Filter](#filter)                     | You must provide either `near` or `within_bounds` keys when using `filter` | -           | No (if not provided, you need to set location data for user, see example below) |
| `cutoff_time`    | string, must be formatted as an RFC3339 timestamp | Activities older than this date won't be selected                          | Last 7 days | No                                                                              |
| `min_popularity` | number (only positive numbers are accepted)       | Minimum popularity an activity should have to be selected                  | `0`         | No                                                                              |

#### Scope

The feed we're currently reading

#### Example

<codetabs>

<codetabs-item value="swift" label="Swift">

```swift

```

</codetabs-item>

<codetabs-item value="javascript" label="JavaScript">

```js
// Provide filter when reading the feed
await feed.getOrCreate({
  // View id is only required if you want to override the feed group's defaults
  view: "proximity_feed_view",
  filter: {
    within_bounds: {
      $eq: {
        ne_lat: 52.43017,
        ne_lng: 4.924821,
        sw_lat: 52.334272,
        sw_lng: 4.822116,
      },
    },
    // Optionally provide other filter properties, just like when querying activities
    activity_type: "hike",
  },
});

// Use either within_bounds or near filter
await feed.getOrCreate({
  // View id is only required if you want to override the feed group's defaults
  view: "proximity_feed_view",
  filter: {
    near: { $eq: { lat: 52.373558, lng: 4.885261, distance: 10 } },
  },
});

// You can omit filter if location is set for user
const me = client.state.getLatestValue().connected_user;
await client.updateUsersPartial({
  users: [
    {
      id: me.id,
      set: {
        lat: 52.373558,
        lng: 4.885261,
      },
    },
  ],
});

await feed.getOrCreate({
  // View id is only required if you want to override the feed group's defaults
  view: "proximity_feed_view",
  // If filter is not provided, API searches based on user's location
});
```

</codetabs-item>

<codetabs-item value="nodejs" label="Node">

```js
const last1Day = new Date(Date.now() - 1 * 24 * 60 * 60 * 1000);

const view = await serverClient.feeds.createFeedView({
  view_id: "proximity_feed_view",
  activity_selectors: [
    {
      type: "proximity",
      // Optional parameters
      min_popularity: 40,
      cutoff_time: last1Day.toISOString(),
    },
  ],
});

const response = await client.feeds.createFeedGroup({
  feed_group_id: "myid",
  default_view_id: "proximity_feed_view",
});

// Provide filter when reading the feed
await feed.getOrCreate({
  view: "proximity_feed_view",
  filter: {
    within_bounds: {
      $eq: {
        ne_lat: 52.43017,
        ne_lng: 4.924821,
        sw_lat: 52.334272,
        sw_lng: 4.822116,
      },
    },
  },
  user_id: "<user id>",
});

// Use either within_bounds or near filter
await feed.getOrCreate({
  view: "proximity_feed_view",
  filter: {
    near: { $eq: { lat: 52.373558, lng: 4.885261, distance: 10 } },
  },
  user_id: "<user id>",
});
```

</codetabs-item>

</codetabs>

### Interest Activity Selector

Selects activities that match the logged-in user's interests. Interest is automatically calculated by Stream API based on which activities the user interacts with.

#### Parameters

| Name             | Type                                        | Description                                               | Default      | Required |
| ---------------- | ------------------------------------------- | --------------------------------------------------------- | ------------ | -------- |
| `sort`           | array, see [Sort](#sort)                    | Sort options                                              | Newest first | No       |
| `filter`         | object, see [Filter](#filter)               | Additional filter conditions                              | -            | No       |
| `min_popularity` | number (only positive numbers are accepted) | Minimum popularity an activity should have to be selected | `0`          | No       |

#### Scope

Feeds that are visible to the logged-in user.

#### Examples

<codetabs>

<codetabs-item value="nodejs" label="Node">

```js
const view = await client.feeds.createFeedView({
  view_id: "interest_feed_view",
  activity_selectors: [
    {
      type: "interest",
      // Optional parameters
      sort: [{ field: "popularity", direction: -1 }],
      filter: {
        activity_type: "post",
      },
    },
  ],
});

const response = await client.feeds.createFeedGroup({
  feed_group_id: "myid",
  default_view_id: "interest_feed_view",
});
```

</codetabs-item>

</codetabs>

### Query Activity Selector

Selects activities using the provided filter query.

#### Parameters

| Name     | Type                          | Description       | Default      | Required |
| -------- | ----------------------------- | ----------------- | ------------ | -------- |
| `filter` | object, see [Filter](#filter) | Filter conditions | -            | Yes      |
| `sort`   | array, see [Sort](#sort)      | Sort options      | Newest first | No       |

#### Scope

Feeds that are visible to the logged-in user.

#### Example

<codetabs>

<codetabs-item value="nodejs" label="Node">

```js
const view = await client.feeds.createFeedView({
  view_id: "query_feed_view",
  activity_selectors: [
    {
      type: "interest",
      filter: { search_data: { $contains: { workout_type: "hike" } } },
      // Optional parameters
      sort: [{ field: "created_at", direction: -1 }],
    },
  ],
});

const response = await client.feeds.createFeedGroup({
  feed_group_id: "myid",
  default_view_id: "query_feed_view",
});
```

</codetabs-item>

</codetabs>

## Selector parameters

Supported values for `sort` and `filter` objects.

### Sort

The following `sort` options are available:

<partial id="activity-feeds/v3-latest/_default/_partials/activities-sort-fields"></partial>

### Filter

The following `filter` options are available:

<partial id="activity-feeds/v3-latest/_default/_partials/activities-queryable-fields"></partial>

## Combining selectors

You can combine multiple selectors. The example below will include:

- popular activities from public and visible feeds
- activities from feeds the user follows
- activities from feeds the user has access to, and matches the user's interest

You can set up ranking to decide how these activities are ordered in the resulting feed.

<codetabs>

<codetabs-item value="nodejs" label="Node">

```js
const view = await client.feeds.createFeedView({
  view_id: "foryou_feed_view",
  activity_selectors: [
    { type: "popular" },
    { type: "following" },
    { type: "interest" },
  ],
  // Define the order with ranking
  ranking: { type: "expression", score: "decay_linear(time) * popularity" },
});

const response = await client.feeds.createFeedGroup({
  feed_group_id: "myid",
  default_view_id: "foryou_feed_view",
});
```

</codetabs-item>

</codetabs>

---

This page was last updated at 2025-08-15T14:14:10.358Z.

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/react-native/activity_selectors/](https://getstream.io/activity-feeds/docs/react-native/activity_selectors/).