The queryActivities endpoint is designed for exploratory search and filtering across all activities. Example use-cases:
A search bar where users can search by text
A "My posts" page that shows a user their own posts across all feeds (useful for applications like Reddit, where users post across different communities instead of posting to a single feed like user:alice)
This endpoint is not a replacement for getOrCreateFeed - signs that you're using queryActivities instead of getOrCreateFeed:
You're using complicated filter expressions to tailor the search to the specific user
You're calling queryActivities automatically any time users open your application
getOrCreateFeed has all the performance optimizations and rate limit settings to support those patterns; it also supports activity filters. Check out the activity selectors guide for more information.
queryActivities endpoint searches for activities in public and visible feeds. It also respects activity visibility:
private activities are only returned for the activity author
if an activity has tag visibilty, and user doesn't have access to the full activity, only a preview is returned (for text based searches the search is performed across the whole activity text, not just the preview)
require 'getstream_ruby'client = GetStreamRuby.manual( api_key: 'api_key', api_secret: 'api_secret')# First page queryfirst_page = client.feeds.query_activities( GetStream::Generated::Models::QueryActivitiesRequest.new( limit: 10, filter: { activity_type: 'post' }, sort: [{ field: 'created_at', direction: -1 }] ))# Second page using next cursor from first pageif first_page.next second_page = client.feeds.query_activities( GetStream::Generated::Models::QueryActivitiesRequest.new( limit: 10, filter: { activity_type: 'post' }, sort: [{ field: 'created_at', direction: -1 }], next: first_page.next ) )end
When searching activities, the activity.current_feed field contains information about the feed the activity belongs to. However, if an activity is posted to multiple feeds, this field will be empty. In this case, you can use the activity.feeds array to read all feed IDs the activity was posted to and fetch feeds separately if needed.
Search filter syntax emulates a MongoDB style query syntax. (It emulates it, we don't use MongoDB, but the query syntax is nice here).
// search for activities where the text includes the word 'popularity'.let query = ActivitiesQuery( filter: .query(.text, "popularity"))let activityList = client.activityList(for: query)let activities = try await activityList.get()
// search for activities where the text includes the word 'popularity'.val query = ActivitiesQuery( filter = ActivitiesFilterField.text.query("popularity"))val activityList = client.activityList(query = query)val activities: Result<List<ActivityData>> = activityList.get()
// search for activities where the text includes the word 'popularity'.const query = ActivitiesQuery( filter: Filter.equal(ActivitiesFilterField.text, 'popularity'),);final activityList = client.activityList(query);final activities = await activityList.get();
// search for activities where the text includes the word 'popularity'.$response = $feedsClient->queryActivities( new GeneratedModels\QueryActivitiesRequest( filter: (object)[ 'text' => (object)[ '$q' => 'popularity' ] ] ));
var response = await _feedsV3Client.QueryActivitiesAsync( new QueryActivitiesRequest { Limit = 10, Filter = new Dictionary<string, object> { ["activity_type"] = "post" } });
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 activityList = client.activityList(for: query)let activities = try await activityList.get()// search for activities where the campaign took place in a malllet query2 = ActivitiesQuery( filter: .pathExists(.searchData, "campaign.location.mall"))let activityList2 = client.activityList(for: query2)let activities2 = try await activityList2.get()
// search for activities associated with the campaign ID 'spring-sale-2025'val searchValue = mapOf("campaign" to mapOf("id" to "spring-sale-2025"))val query = ActivitiesQuery( filter = ActivitiesFilterField.searchData.contains(searchValue))val activityList = client.activityList(query = query)val activities: Result<List<ActivityData>> = activityList.get()// search for activities where the campaign took place in a mallval query2 = ActivitiesQuery( filter = ActivitiesFilterField.searchData.pathExists("campaign.location.mall"))val activityList2 = client.activityList(query = query2)val activities2: Result<List<ActivityData>> = activityList2.get()
// search for activities associated with the campaign ID 'spring-sale-2025'final searchValue = { 'campaign': {'id': 'spring-sale-2025'},};final query = ActivitiesQuery( filter: Filter.contains(ActivitiesFilterField.searchData, searchValue),);final activityList = client.activityList(query);final activities = await activityList.get();// search for activities where the campaign took place in a mallconst query2 = ActivitiesQuery( filter: Filter.pathExists( ActivitiesFilterField.searchData, 'campaign.location.mall', ),);final activityList2 = client.activityList(query2);final activities2 = await activityList2.get();
// search for activities associated with the campaign ID 'spring-sale-2025'$response = $feedsClient->queryActivities( new GeneratedModels\QueryActivitiesRequest( filter: (object)[ 'search_data' => (object)[ '$contains' => (object)[ 'campaign' => (object)[ 'id' => 'spring-sale-2025' ] ] ] ] ));// search for activities where the campaign took place in a mall$response2 = $feedsClient->queryActivities( new GeneratedModels\QueryActivitiesRequest( filter: (object)[ 'search_data' => (object)[ '$path_exists' => 'campaign.location.mall' ] ] ));
var response = await _feedsV3Client.QueryActivitiesAsync( new QueryActivitiesRequest { Limit = 10, Filter = new Dictionary<string, object> { ["activity_type"] = "post" } });
For server-side requests, you can set include_private_activities to true to include private activities in the results (the default is false).
const response = await client.feeds.queryActivities({ include_private_activities: true, filter: { // your filter here },});
response, err := client.Feeds().QueryActivities(context.Background(), &getstream.QueryActivitiesRequest{ IncludePrivateActivities: boolPtr(true), Filter: map[string]any{ // your filter here },})
Map<String, Object> filter = new HashMap<>();// your filter hereQueryActivitiesRequest request = QueryActivitiesRequest.builder() .filter(filter) .includePrivateActivities(true) .build();QueryActivitiesResponse response = feeds.queryActivities(request).execute().getData();
$response = $feedsClient->queryActivities( new GeneratedModels\QueryActivitiesRequest( include_private_activities: true, filter: (object)[ // your filter here ] ));
var response = await _feedsV3Client.QueryActivitiesAsync( new QueryActivitiesRequest { IncludePrivateActivities = true, Filter = new Dictionary<string, object> { // your filter here } });
response = self.client.feeds.query_activities( include_private_activities=True, filter={ # your filter here })
For server-side requests, you can provide a user_id to perform the search as if it were made by that specific user. It turns the server-side request into a client-side request.
const response = await client.feeds.queryActivities({ user_id: "john", filter: { // your filter here },});
response, err := client.Feeds().QueryActivities(context.Background(), &getstream.QueryActivitiesRequest{ UserID: strPtr("john"), Filter: map[string]any{ // your filter here },})
Map<String, Object> filter = new HashMap<>();// your filter hereQueryActivitiesRequest request = QueryActivitiesRequest.builder() .filter(filter) .userId("john") .build();QueryActivitiesResponse response = feeds.queryActivities(request).execute().getData();
$response = $feedsClient->queryActivities( new GeneratedModels\QueryActivitiesRequest( user_id: 'john', filter: (object)[ // your filter here ] ));
var response = await _feedsV3Client.QueryActivitiesAsync( new QueryActivitiesRequest { UserId = "john", Filter = new Dictionary<string, object> { // your filter here } });
response = self.client.feeds.query_activities( user_id="john", filter={ # your filter here })
true if an activity was hidden by the user. Hidden activities are excluded unless specified with filter
$eq
{ hidden: { $eq: true }
The filter syntax also supports $or and $and:
// Get all the activities where filter tags contain both "green" and "orange"let filter = .and([ .in(.filterTags, ["green"]), .in(.filterTags, ["orange"])])
// Get all the activities where filter tags contain both "green" and "orange"val filter = Filters.and( ActivitiesFilterField.filterTags.`in`("green"), ActivitiesFilterField.filterTags.`in`("orange"),)
// Get all the activities where filter tags contain both "green" and "orange"const filter = { $and: [{ filter_tags: ["green"] }, { filter_tags: ["orange"] }],};
// Get all the activities where filter tags contain both "green" and "orange"const filter = { $and: [{ filter_tags: ["green"] }, { filter_tags: ["orange"] }],};
// Get all the activities where filter tags contain both "green" and "orange"const filter = { $and: [{ filter_tags: ["green"] }, { filter_tags: ["orange"] }],};
// Get all the activities where filter tags contain both "green" and "orange"const filter = Filter.and([ Filter.in_(ActivitiesFilterField.filterTags, ['green']), Filter.in_(ActivitiesFilterField.filterTags, ['orange']),])
// Get all the activities where filter tags contain both "green" and "orange"const filter = { $and: [ { filter_tags: ["green"] } { filter_tags: ["orange"] } ],}
// Get all the activities where filter tags contain both "green" and "orange"filter := map[string]any{ "$and": []map[string]any{ {"filter_tags": []string{"green"}}, {"filter_tags": []string{"orange"}}, },}
// Get all the activities where filter tags contain both "green" and "orange"Map<String, Object> filter = new HashMap<>();List<Map<String, Object>> andConditions = List.of( Map.of("filter_tags", List.of("green")), Map.of("filter_tags", List.of("orange")));filter.put("$and", andConditions);
// Get all the activities where filter tags contain both "green" and "orange"var filter = = new{ and = new[] { new { filter_tags = new[] { "green" } }, new { filter_tags = new[] { "orange" } } }}
# Get all the activities where filter tags contain both "green" and "orange"filter = { "$and": [ {"filter_tags": ["green"]}, {"filter_tags": ["orange"]} ]}
# Get all the activities where filter tags contain both "green" and "orange"filter = { "$and" => [ { "filter_tags" => ["green"] }, { "filter_tags" => ["orange"] } ]}
Be sure to reach out to support if you need additional query activity capabilities.