-
public interface FeedsClientSingle entry point for interacting with the Stream Feeds service.
-
-
Method Summary
Modifier and Type Method Description abstract Result<StreamConnectedUser>connect()Establishes a connection to the Stream service. abstract Result<Unit>disconnect()Disconnects the current FeedsClient. abstract Feedfeed(String group, String id, Function3<FeedQuery, ActivityData, String, InsertionAction> onNewActivity)Creates a feed instance for the specified group and id. abstract Feedfeed(FeedId fid, Function3<FeedQuery, ActivityData, String, InsertionAction> onNewActivity)Creates a feed instance for the specified feed ID. abstract Feedfeed(FeedQuery query, Function3<FeedQuery, ActivityData, String, InsertionAction> onNewActivity)Fetches a feed based on the provided FeedQuery. abstract FeedListfeedList(FeedsQuery query)Creates a feed list instance based on the provided query. abstract FollowListfollowList(FollowsQuery query)Creates a follow list instance based on the provided query. abstract Activityactivity(String activityId, FeedId fid)Creates an activity instance for the specified activity ID and feed ID. abstract ActivityListactivityList(ActivitiesQuery query)Creates an activity list instance based on the provided query. abstract ActivityReactionListactivityReactionList(ActivityReactionsQuery query)Creates an activity reaction list instance based on the provided query. abstract Result<ActivityData>addActivity(AddActivityRequest request)Adds a new activity to the specified feeds. abstract Result<List<ActivityData>>upsertActivities(List<ActivityRequest> activities)Upserts (inserts or updates) multiple activities. abstract Result<DeleteActivitiesResponse>deleteActivities(DeleteActivitiesRequest request)Deletes multiple activities from the specified feeds. abstract Result<Unit>activityFeedback(String activityId, ActivityFeedbackRequest request)Submits feedback for an activity. abstract BookmarkListbookmarkList(BookmarksQuery query)Creates a bookmark list instance based on the provided query. abstract BookmarkFolderListbookmarkFolderList(BookmarkFoldersQuery query)Creates a bookmark folder list instance based on the provided query. abstract Result<BookmarkFolderData>updateBookmarkFolder(String folderId, UpdateBookmarkFolderRequest request)Updates a bookmark folder by its ID. abstract Result<Unit>deleteBookmarkFolder(String folderId)Deletes a bookmark folder by its ID. abstract CommentListcommentList(CommentsQuery query)Creates a comment list instance based on the provided query. abstract ActivityCommentListactivityCommentList(ActivityCommentsQuery query)Creates an activity comment list instance based on the provided query. abstract CommentReplyListcommentReplyList(CommentRepliesQuery query)Creates a comment reply list instance based on the provided query. abstract CommentReactionListcommentReactionList(CommentReactionsQuery query)Creates a comment reaction list instance based on the provided query. abstract MemberListmemberList(MembersQuery query)Creates a member list instance based on the provided query. abstract PollVoteListpollVoteList(PollVotesQuery query)Creates a poll vote list instance based on the provided query. abstract PollListpollList(PollsQuery query)Creates a poll list instance based on the provided query. abstract ModerationConfigListmoderationConfigList(ModerationConfigsQuery query)Creates a moderation configuration list instance based on the provided query. abstract UserListuserList(UsersQuery query)Creates a user list instance based on the provided query. abstract Result<AppData>getApp()Retrieves the application configuration and settings. abstract Result<GetOGResponse>getOG(String url)Fetches Open Graph metadata for a URL. abstract Result<List<CollectionData>>readCollections(List<String> refs)Read collections, filtering by collection references. abstract Result<List<CollectionData>>createCollections(CreateCollectionsRequest request)Create new collections in a batch operation. abstract Result<Unit>deleteCollections(List<String> refs)Delete collections in a batch operation. abstract Result<List<CollectionData>>updateCollections(UpdateCollectionsRequest request)Update existing collections in a batch operation. abstract Result<ListDevicesResponse>queryDevices()Queries all devices associated with the current user. abstract Result<Unit>createDevice(String id, PushNotificationsProvider pushProvider, String pushProviderName)Creates a new device for push notifications. abstract Result<Unit>deleteDevice(String id)Deletes a device by its unique identifier. abstract Result<UpsertPushPreferencesResponse>updatePushNotificationPreferences(UpsertPushPreferencesRequest request)Updates the push notification preferences for the current user. abstract Result<Unit>deleteFile(String url)Deletes a previously uploaded file from the CDN. abstract Result<Unit>deleteImage(String url)Deletes a previously uploaded image from the CDN. abstract Result<BatchFollowData>getOrCreateFollows(FollowBatchRequest request)Creates follow relationships in batch. abstract Result<List<FollowData>>getOrCreateUnfollows(UnfollowBatchRequest request)Deletes follow relationships in batch. abstract StreamApiKeygetApiKey()Provides the API key used for authentication and service access. abstract UsergetUser()Provides the user associated with this client. abstract Uploader<FeedUploadContext>getUploader()Provides an instance of FeedUploader for uploading files. abstract ModerationgetModeration()Provides an instance of Moderation for managing moderation-related operations. abstract StateFlow<StreamConnectionState>getState()Exposes the current connection state of the FeedsClient as a StateFlow. abstract Flow<WSEvent>getEvents()Exposes a Flow of real-time WebSocket events received by the client. -
-
Method Detail
-
connect
abstract Result<StreamConnectedUser> connect()
Establishes a connection to the Stream service.
This method sets up authentication and initializes the WebSocket connection for real-time updates. It should be called before using any other client functionality.
-
disconnect
abstract Result<Unit> disconnect()
Disconnects the current FeedsClient.
-
feed
abstract Feed feed(String group, String id, Function3<FeedQuery, ActivityData, String, InsertionAction> onNewActivity)
Creates a feed instance for the specified group and id.
This method creates a Feed object that represents a specific feed. The feed can be used to fetch activities, manage follows, and receive real-time updates.
Example:
val userFeed = client.feed(group = "user", id = "john") val timelineFeed = client.feed(group = "timeline", id = "flat")- Parameters:
group- The feed group identifier (e.g., "user", "timeline", "notification").id- The specific feed identifier within the group (e.g., "john", "flat").onNewActivity- Determines if and where new activities should be inserted.
-
feed
abstract Feed feed(FeedId fid, Function3<FeedQuery, ActivityData, String, InsertionAction> onNewActivity)
Creates a feed instance for the specified feed ID.
This method creates a Feed object that represents a specific feed. The feed can be used to fetch activities, manage follows, and receive real-time updates.
Example:
val feedId = FeedId(group = "user", id = "john") val userFeed = client.feed(feedId)- Parameters:
fid- The FeedId identifier containing the group and ID.onNewActivity- Determines if and where new activities should be inserted.
-
feed
abstract Feed feed(FeedQuery query, Function3<FeedQuery, ActivityData, String, InsertionAction> onNewActivity)
Fetches a feed based on the provided FeedQuery.
This method creates a Feed object using a FeedQuery that can include additional configuration such as activity filters, limits, and feed data for creation.
Example:
val query = FeedQuery( fid = FeedId(group = "user", id = "john"), activityLimit = 20, data = FeedInput(name = "John's Feed") ) val feed = client.feed(query)- Parameters:
query- The feed query containing the feed identifier and optional configuration.onNewActivity- Determines if and where new activities should be inserted.
-
feedList
abstract FeedList feedList(FeedsQuery query)
Creates a feed list instance based on the provided query.
This method creates a FeedList object that represents a collection of feeds matching the specified query. The feed list can be used to fetch multiple feeds, manage feed groups, and receive real-time updates for all feeds in the list.
- Parameters:
query- The feeds query containing filtering and pagination parameters.
-
followList
abstract FollowList followList(FollowsQuery query)
Creates a follow list instance based on the provided query.
This method creates a FollowList object that represents a collection of follow relationships matching the specified query. The follow list can be used to fetch followers, following relationships, and manage follow data with pagination support.
- Parameters:
query- The follows query containing filtering, sorting, and pagination parameters.
-
activity
abstract Activity activity(String activityId, FeedId fid)
Creates an activity instance for the specified activity ID and feed ID.
This method creates an Activity object that represents a specific activity within a feed. The activity can be used to manage comments, reactions, and other activity-specific operations.
Example:
val feedId = FeedId(group = "user", id = "john") val activity = client.activity(activityId = "activity-123", fid = feedId)- Parameters:
activityId- The unique identifier of the activity.fid- The feed identifier where the activity belongs.
-
activityList
abstract ActivityList activityList(ActivitiesQuery query)
Creates an activity list instance based on the provided query.
This method creates an ActivityList object that represents a collection of activities matching the specified query. The activity list can be used to fetch activities, manage activity pagination, and receive real-time updates for activity-related events.
- Parameters:
query- The activities query containing filtering, sorting, and pagination parameters.
-
activityReactionList
abstract ActivityReactionList activityReactionList(ActivityReactionsQuery query)
Creates an activity reaction list instance based on the provided query.
This method creates an
ActivityReactionListobject that represents a collection of reactions for a specific activity. The activity reaction list can be used to fetch reactions for an activity, manage reaction pagination, and receive real-time updates for reaction-related events.- Parameters:
query- The activity reactions query containing the activity identifier and pagination parameters.
-
addActivity
abstract Result<ActivityData> addActivity(AddActivityRequest request)
Adds a new activity to the specified feeds.
- Parameters:
request- The request containing the activity data to be added.
-
upsertActivities
abstract Result<List<ActivityData>> upsertActivities(List<ActivityRequest> activities)
Upserts (inserts or updates) multiple activities.
- Parameters:
activities- The list of activities to be upserted.
-
deleteActivities
abstract Result<DeleteActivitiesResponse> deleteActivities(DeleteActivitiesRequest request)
Deletes multiple activities from the specified feeds.
- Parameters:
request- The request containing the activities to delete.
-
activityFeedback
abstract Result<Unit> activityFeedback(String activityId, ActivityFeedbackRequest request)
Submits feedback for an activity.
Example:
// Hide an activity client.activityFeedback("activity-123", ActivityFeedbackRequest(hide = true)) // Unhide an activity client.activityFeedback("activity-123", ActivityFeedbackRequest(hide = false))- Parameters:
activityId- The unique identifier of the activity.request- The feedback request to be submitted.
-
bookmarkList
abstract BookmarkList bookmarkList(BookmarksQuery query)
Creates a bookmark list instance based on the provided query.
This method creates a BookmarkList object that represents a collection of bookmarks matching the specified query. The bookmark list can be used to fetch user bookmarks, manage bookmark folders, and receive real-time updates for bookmark-related events.
-
bookmarkFolderList
abstract BookmarkFolderList bookmarkFolderList(BookmarkFoldersQuery query)
Creates a bookmark folder list instance based on the provided query.
This method creates a BookmarkFolderList object that represents a collection of bookmark folders matching the specified query. The bookmark folder list can be used to fetch user bookmark folders, manage folder organization, and receive real-time updates for folder-related events..
- Parameters:
query- The bookmark folders query containing filtering, sorting, and pagination parameters.
-
updateBookmarkFolder
abstract Result<BookmarkFolderData> updateBookmarkFolder(String folderId, UpdateBookmarkFolderRequest request)
Updates a bookmark folder by its ID.
- Parameters:
folderId- The unique identifier of the bookmark folder to update.request- The request containing the updated folder data.
-
deleteBookmarkFolder
abstract Result<Unit> deleteBookmarkFolder(String folderId)
Deletes a bookmark folder by its ID. All bookmarks in the folder will also be deleted.
- Parameters:
folderId- The unique identifier of the bookmark folder to delete.
-
commentList
abstract CommentList commentList(CommentsQuery query)
Creates a comment list instance based on the provided query.
This method creates a CommentList object that represents a collection of comments matching the specified query. The comment list can be used to fetch comments, manage comment pagination, and receive real-time updates for comment-related events.
- Parameters:
query- The comments query containing filtering, sorting, and pagination parameters.
-
activityCommentList
abstract ActivityCommentList activityCommentList(ActivityCommentsQuery query)
Creates an activity comment list instance based on the provided query.
This method creates an ActivityCommentList object that represents a collection of comments for a specific activity. The activity comment list can be used to fetch comments for an activity, manage comment pagination, and receive real-time updates for comment-related events.
- Parameters:
query- The activity comments query containing the activity identifier and pagination parameters.
-
commentReplyList
abstract CommentReplyList commentReplyList(CommentRepliesQuery query)
Creates a comment reply list instance based on the provided query.
This method creates a CommentReplyList object that represents a collection of replies for a specific comment. The comment reply list can be used to fetch replies to a comment, manage reply pagination, and receive real-time updates for reply-related events.
- Parameters:
query- The comment replies query containing the comment identifier and pagination parameters.
-
commentReactionList
abstract CommentReactionList commentReactionList(CommentReactionsQuery query)
Creates a comment reaction list instance based on the provided query.
This method creates a CommentReactionList object that represents a collection of reactions for a specific comment. The comment reaction list can be used to fetch reactions for a comment, manage reaction pagination, and receive real-time updates for reaction-related events.
- Parameters:
query- The comment reactions query containing the comment identifier and pagination parameters.
-
memberList
abstract MemberList memberList(MembersQuery query)
Creates a member list instance based on the provided query.
This method creates a MemberList object that represents a collection of feed members matching the specified query. The member list can be used to fetch feed members, manage member pagination, and receive real-time updates for member-related events.
- Parameters:
query- The members query containing filtering, sorting, and pagination parameters.
-
pollVoteList
abstract PollVoteList pollVoteList(PollVotesQuery query)
Creates a poll vote list instance based on the provided query.
This method creates a PollVoteList object that represents a collection of poll votes matching the specified query. The poll vote list can be used to fetch poll votes, manage vote pagination, and receive real-time updates for vote-related events.
- Parameters:
query- The poll votes query containing filtering, sorting, and pagination parameters.
-
pollList
abstract PollList pollList(PollsQuery query)
Creates a poll list instance based on the provided query.
This method creates a PollList object that represents a collection of polls matching the specified query. The poll list can be used to fetch polls, manage poll pagination, and receive real-time updates for poll-related events.
- Parameters:
query- The polls query containing filtering, sorting, and pagination parameters.
-
moderationConfigList
abstract ModerationConfigList moderationConfigList(ModerationConfigsQuery query)
Creates a moderation configuration list instance based on the provided query.
This method creates a
ModerationConfigListobject that represents a collection of moderation configurations matching the specified query. The moderation configuration list can be used to fetch configurations, manage configuration pagination, and receive real-time updates for configuration-related events.- Parameters:
query- The moderation configurations query containing filtering, sorting, and pagination parameters.
-
userList
abstract UserList userList(UsersQuery query)
Creates a user list instance based on the provided query.
This method creates a UserList object that represents a collection of users matching the specified query. The user list can be used to fetch users, manage user pagination, and observe the current list of users.
Use this to search for users, for example when implementing @mention autocomplete.
- Parameters:
query- The query parameters for filtering, sorting, and paginating users.
-
getApp
abstract Result<AppData> getApp()
Retrieves the application configuration and settings.
This method fetches the current application data including configuration settings, file upload configurations, and feature flags.
The returned
AppDatacontains:Async URL Enrichment: Whether automatic URL enrichment is enabled
Auto Translation: Whether automatic translation is enabled
File Upload Config: Configuration for file uploads including allowed extensions, MIME types, and size limits
Image Upload Config: Configuration for image uploads including allowed extensions, MIME types, and size limits
Application Name: The name of the application
Important: The result is cached after the first successful request to avoid unnecessary API calls.
-
getOG
abstract Result<GetOGResponse> getOG(String url)
Fetches Open Graph metadata for a URL.
This is useful for showing URL enrichment to users before an activity or comment is sent. You can then persist the OG data in
attachmentswhen sending the activity or comment (setskipEnrichUrlto avoid duplicate previews).- Parameters:
url- The URL to fetch OG metadata for.
-
readCollections
abstract Result<List<CollectionData>> readCollections(List<String> refs)
Read collections, filtering by collection references. By default, users can only read their own collections.
- Parameters:
refs- List of collection references to read in the format "<name>:<id>".
-
createCollections
abstract Result<List<CollectionData>> createCollections(CreateCollectionsRequest request)
Create new collections in a batch operation. Collections are data objects that can be attached to activities for managing shared data across multiple activities.
- Parameters:
request- The CreateCollectionsRequest containing the collections to be created.
-
deleteCollections
abstract Result<Unit> deleteCollections(List<String> refs)
Delete collections in a batch operation. Users can only delete their own collections.
- Parameters:
refs- List of collection references to delete in the format "<name>:<id>".
-
updateCollections
abstract Result<List<CollectionData>> updateCollections(UpdateCollectionsRequest request)
Update existing collections in a batch operation. Only the custom data field is updatable. Users can only update their own collections.
- Parameters:
request- The UpdateCollectionsRequest containing the collections to be updated.
-
queryDevices
abstract Result<ListDevicesResponse> queryDevices()
Queries all devices associated with the current user.
-
createDevice
abstract Result<Unit> createDevice(String id, PushNotificationsProvider pushProvider, String pushProviderName)
Creates a new device for push notifications.
- Parameters:
id- The unique identifier for the device.pushProvider- The push notifications provider of the device (e.g.pushProviderName- The name of the push provider.
-
deleteDevice
abstract Result<Unit> deleteDevice(String id)
Deletes a device by its unique identifier.
- Parameters:
id- The unique identifier of the device to be deleted.
-
updatePushNotificationPreferences
abstract Result<UpsertPushPreferencesResponse> updatePushNotificationPreferences(UpsertPushPreferencesRequest request)
Updates the push notification preferences for the current user.
- Parameters:
request- The request containing the push notification preferences to be updated.
-
deleteFile
abstract Result<Unit> deleteFile(String url)
Deletes a previously uploaded file from the CDN.
This is typically used for videos, or other non-image attachments. The method makes an asynchronous request to the global file deletion endpoint.
- Parameters:
url- The URL of the file to be deleted.
-
deleteImage
abstract Result<Unit> deleteImage(String url)
Deletes a previously uploaded image from the CDN.
This is intended for removing images such as user-uploaded photos or thumbnails. The method makes an asynchronous request to the global image deletion endpoint.
- Parameters:
url- The URL of the image to be deleted.
-
getOrCreateFollows
abstract Result<BatchFollowData> getOrCreateFollows(FollowBatchRequest request)
Creates follow relationships in batch. Differently from Feed.follow, this operation is idempotent: if any of the requested follow relationships already exists, the operation still succeeds and returns the existing data.
- Parameters:
request- The request containing the list of follow relationships to create.
-
getOrCreateUnfollows
abstract Result<List<FollowData>> getOrCreateUnfollows(UnfollowBatchRequest request)
Deletes follow relationships in batch. Differently from Feed.unfollow, this operation is idempotent: if any of the requested follow relationships already does not exist, the operation still succeeds and returns the ones that were actually deleted.
- Parameters:
request- The request containing the list of follow relationships to delete.
-
getApiKey
abstract StreamApiKey getApiKey()
Provides the API key used for authentication and service access.
This API key is the same one that was passed in the FeedsConfig provided during client initialization.
-
getUser
abstract User getUser()
Provides the user associated with this client.
This user is the same one that was passed during client initialization. It represents the authenticated user for whom the client operates.
-
getUploader
abstract Uploader<FeedUploadContext> getUploader()
Provides an instance of FeedUploader for uploading files.
This uploader is the same as the one passed in the FeedsConfig provided during client initialization. If none was provided, a default uploader will be used that uploads files to the Stream CDN.
-
getModeration
abstract Moderation getModeration()
Provides an instance of Moderation for managing moderation-related operations.
-
getState
abstract StateFlow<StreamConnectionState> getState()
Exposes the current connection state of the FeedsClient as a StateFlow.
Example:
client .state .collect { state -> // Handle connection state changes }
-
getEvents
abstract Flow<WSEvent> getEvents()
Exposes a Flow of real-time WebSocket events received by the client. Allows you to subscribe to specific event types by filtering the main event stream. It's useful when you only want to handle certain types of events.
Example:
client .events .collect { event -> // Handle the event types you care about }
-
-
-
-