Search for Feeds

The query feeds endpoint lets you search for feeds.

Examples

Querying My Feeds

ctx := context.Background()

// First page query
firstPage, err := client.Feeds().QueryFeeds(ctx, &getstream.QueryFeedsRequest{
  Filter: getstream.PtrTo(map[string]any{
    "created_by_id": "john",
  }),
  Limit: getstream.PtrTo(10),
  Sort: getstream.PtrTo([]getstream.SortParamRequest{
    {
      Field:     getstream.PtrTo("created_at"),
      Direction: getstream.PtrTo(-1),
    },
  }),
})
if err != nil {
  log.Fatal("Error querying first page:", err)
}

// Second page query using next cursor from first page
secondPage, err := client.Feeds().QueryFeeds(ctx, &getstream.QueryFeedsRequest{
  Filter: getstream.PtrTo(map[string]any{
    "created_by_id": "john",
  }),
  Limit: getstream.PtrTo(10),
  Sort: getstream.PtrTo([]getstream.SortParamRequest{
    {
      Field:     getstream.PtrTo("created_at"),
      Direction: getstream.PtrTo(-1),
    },
  }),
  Next: firstPage.Data.Next,
})
if err != nil {
  log.Fatal("Error querying second page:", err)
}

log.Printf("First page: %d feeds, next: %v", len(firstPage.Data.Feeds), firstPage.Data.Next)
log.Printf("Second page: %d feeds, next: %v", len(secondPage.Data.Feeds), secondPage.Data.Next)

Querying Feeds Where I Am a Member

ctx := context.Background()

filter := map[string]any{
  "members": map[string]any{
    "$in": []string{"john"},
  },
}

response, err := client.Feeds().QueryFeeds(ctx, &getstream.QueryFeedsRequest{
  Filter: getstream.PtrTo(filter),
})
if err != nil {
  log.Fatal("Error querying feeds:", err)
}

log.Printf("Query feeds response: %+v", response)

Querying feeds by name or description

// Create context
ctx := context.Background()

response1, err := client.Feeds().QueryFeeds(ctx, &getstream.QueryFeedsRequest{
  Filter: getstream.PtrTo(map[string]any{
    "visibility": map[string]any{
      "$eq": "public",
    },
    "name": map[string]any{
      "$q": "Sports",
    },
  }),
})
if err != nil {
  log.Fatal("Error querying feeds:", err)
}
log.Printf("Query feeds response 1: %+v", response1)

response2, err := client.Feeds().QueryFeeds(ctx, &getstream.QueryFeedsRequest{
  Filter: getstream.PtrTo(map[string]any{
    "visibility": getstream.PtrTo("public"),
    "description": map[string]any{
      "$q": "tech",
    },
  }),
})

Querying feeds by creator name

// Create context
ctx := context.Background()

// Search public feeds created by users with 'Thompson' in their name
if response, err := client.Feeds().QueryFeeds(ctx, &getstream.QueryFeedsRequest{
  Filter: getstream.PtrTo(map[string]any{
    "visibility": "public",
    "created_by.name": map[string]any{
      "$q": "Thompson",
    },
  }),
});

err != nil {
  log.Fatal("Error querying feeds:", err)
} else {
  log.Printf("Found %d feeds", len(response.Data.Feeds))
}

A complex example

Search for user feeds where text matches the feed's name, description or creator's name:

// Create context
ctx := context.Background()

response, err := client.Feeds().QueryFeeds(ctx, &getstream.QueryFeedsRequest{
  Filter: getstream.PtrTo(map[string]any{
    "group_id": "user",
    "$or": []map[string]any{
      {"name": map[string]any{"$q": searchQuery}},
      {"description": map[string]any{"$q": searchQuery}},
      {"created_by.name": map[string]any{"$q": searchQuery}},
    },
  }),
})
if err != nil {
  log.Fatal("Error querying feeds:", err)
}
log.Printf("Query feeds response: %+v", response)

Feeds Queryable Built-in Fields

name type description supported operations example
id string or list of strings The ID of the feed $in, $eq { id: { $in: [ 'abc', 'xyz' ] } }
group_id string or list of strings The ID of the group this feed belongs to $in, $eq { group_id: { $in: [ 'abc', 'xyz' ] } }
feed string or list of strings The fully qualified feed ID (group_id:id) $in, $eq { fid: { $in: [ 'abc', 'xyz' ] } }
visibility string or list of strings The visibility setting of the feed $in, $eq { visibility: { $eq: 'public' } }
created_by_id string or list of strings The ID of the user who created the feed $in, $eq { created_by_id: { $in: [ 'abc', 'xyz' ] } }
created_by.name string The name of the user who created the feed $eq, $q, $autocomplete { 'created_by.name': { $autocomplete: 'Frank' } }
name string The name of the feed $eq, $q, $autocomplete { name: { $q: 'Sports' } }
description string The description of the feed $eq, $q, $autocomplete { description: { $autocomplete: 'tech' } }
member_count number The number of accepted members in this feed (pending and declined invitations are not counted) $eq, $ne, $gt, $lt, $gte, $lte { member_count: { $gt: 100 } }
members list of strings The list of members in this feed $in { members: { $in: [ 'bob', 'alice' ] } }
following_count number The number of feeds this feed follows $eq, $ne, $gt, $lt, $gte, $lte { following_count: { $gt: 100 } }
following_feeds list of strings The list of feeds this feed follows $in { following_feeds: { $in: [ 'feed1', 'feed2' ] } }
follower_count number The number of followers of this feed $eq, $ne, $gt, $lt, $gte, $lte { follower_count: { $gt: 100 } }
created_at string, RFC3339 timestamp The time the feed was created $eq, $gt, $lt, $gte, $lte { created_at: { $gte: '2023-12-04T09:30:20.45Z' } }
updated_at string, RFC3339 timestamp The time the feed was updated $eq, $gt, $lt, $gte, $lte { updated_at: { $gte: '2023-12-04T09:30:20.45Z' } }
filter_tags list of strings Tags for filtering the feed $eq, $contains, $in { filter_tags: { $in: [ 'sports', 'news' ] } }
near object GEO point and distance (km) to filter by $eq { near: { $eq: { lat: 40.0, lng: -74.0, distance: 200 } } }
within_bounds object GEO bounding box to filter by $eq { within_bounds: { $eq: { ne_lat: 40.0, ne_lng: -115.0, sw_lat: 32.0, sw_lng: -125.0 } } }

Filter expressions can be combined using $or and $and operators as well.

Feeds can be sorted by created_at, updated_at, member_count, follower_count, and following_count.

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

Add Chat to my app: getstream.io/SKILL.md

The fastest way to build with Stream. Start a new project or improve an existing one. Full CLI and documentation integration out of the box.


Ask your agent:

/stream Build me a Social App with Feeds and Moderation.
/stream Any livestream calls running?
/stream Feeds Go v3: <Your Question>