Activity Feeds V3 is in closed alpha — do not use it in production (just yet).

Querying Activities

Activity Search & Queries

You can query & search activities. Here’s an example of how to query activities:

let query = ActivitiesQuery(
    filter: .equal(.type, "post"),
    sort: [Sort(field: .createdAt, direction: .reverse)],
    limit: 10
)
let activities = try await feed.queryActivities(with: query)

The syntax emulates a MongoDB style query syntax. (It emulates it, we don’t use MongoDB, but the query syntax is nice here).

Querying activities by text

// search for activities where the text includes the word 'popularity'.
let query = ActivitiesQuery(
    filter: .query(.text, "popularity")
)
let activities = try await feed.queryActivities(with: query)

Querying activities by search data

Consider this example activity:

{
  "id": "activity-123",
  "type": "post",
  "text": "Check out our spring sale!",
  "search_data": {
    "campaign": {
      "id": "spring-sale-2025",
      "location": {
        "mall": "yorkdale",
        "city": "toronto",
        "country": "canada"
      }
    }
  }
  // ... other activity fields
}

You can search this activity using the search_data field in several ways:

// search for activities associated with the campaign ID 'spring-sale-2025'
let searchValue: [String: RawJSON] = ["campaign": .dictionary(["id": .string("spring-sale-2025")])]
let query = ActivitiesQuery(
    filter: .contains(.searchData, searchValue)
)
let activities = try await feed.queryActivities(with: query)

// search for activities where the campaign took place in a mall
let query2 = ActivitiesQuery(
    filter: .pathExists(.searchData, "campaign.location.mall")
)
let activities2 = try await feed.queryActivities(with: query2)

Activities Queryable Built-In Fields

nametypedescriptionsupported operationsexample
idstring or list of stringsThe ID of the activity$in, $eq{ id: { $in: [ 'abc', 'xyz' ] } }
activity_typestring or list of stringsThe type of the activity$in, $eq{ activity_type: { $in: [ 'abc', 'xyz' ] } }
user_idstring or list of stringsThe ID of the user who created the activity$in, $eq{ user_id: { $in: [ 'abc', 'xyz' ] } }
textstringThe text content of the activity$eq, $q, $autocomplete{ text: { $q: 'popularity' } }
search_dataobjectThe extra metadata for search indexing$contains, $path_exists{ search_data: { $contains: { 'category': 'sports', 'status': 'active' } } }
interest_tagslist of stringsTags for user interests$eq, $contains{ interest_tags: { $in: [ 'sports', 'music' ] } }
filter_tagslist of stringsTags for filtering$eq, $contains{ filter_tags: { $in: [ 'categoryA', 'categoryB' ] } }
created_atstring, must be formatted as an RFC3339 timestampThe time the activity was created$eq, $gt, $lt, $gte, $lte{ created_at: { $gte: '2023-12-04T09:30:20.45Z' } }
popularitynumberThe popularity score of the activity$eq, $ne, $gt, $lt, $gte, $lte{ popularity: { $gte: 70 } }
nearobjectIndicates the GEO point to search nearby activities$eq{ near: { $eq: { lat: 40.0, lng: -74.0, distance: 200 } } }
within_boundsobjectIndicates the GEO bounds to search for activities within$eq{ within_bounds: { $eq: { ne_lat: 40.0, ne_lng: -115.0, sw_lat: 32.0, sw_lng: -125.0 } } }
visible_to_userbooleanIndicate whether the activity is visible to the user$eq{ visible_to_user: { $eq: true } }

Be sure to reach out to support if you need additional query activity capabilities.

© Getstream.io, Inc. All Rights Reserved.