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

Bookmarks

Overview

The API includes built-in support for bookmarking activities. Here’s a quick example of how to use the bookmark API.

Adding Bookmarks

// Adding a bookmark to a new folder
val bookmark: Result<BookmarkData> = feed.addBookmark(activityId = "activity_123")

// Adding to an existing folder
val bookmarkWithFolder: Result<BookmarkData> = feed.addBookmark(
    activityId = "activity_123",
    request = AddBookmarkRequest(folderId = "folder_456")
)

// Update a bookmark (without a folder initially) - add custom data and move it to a new folder
val updatedBookmark: Result<BookmarkData> = feed.updateBookmark(
    activityId = "activity_123",
    request = UpdateBookmarkRequest(
        custom = mapOf("color" to "blue"),
        newFolder = AddFolderRequest(
            custom = mapOf("icon" to "πŸ“"),
            name = "New folder name"
        )
    )
)

// Update a bookmark - move it from one existing folder to another existing folder
val movedBookmark: Result<BookmarkData> = feed.updateBookmark(
    activityId = "activity_123",
    request = UpdateBookmarkRequest(
        folderId = "folder_456",
        newFolderId = "folder_789"
    )
)

Removing Bookmarks

// Removing a bookmark
feed.deleteBookmark(
    activityId = "activity_123",
    folderId = "folder_456"
)

// When you read a feed we include the bookmark
feed.getOrCreate()
feed.state.activities.collect { activities ->
    println(activities.first().ownBookmarks)
}

Querying Bookmarks

// Query bookmarks
val query = BookmarksQuery(limit = 5)
val bookmarkList = client.bookmarkList(query = query)
val page1: Result<List<BookmarkData>> = bookmarkList.get()

// Get next page
val page2: Result<List<BookmarkData>> = bookmarkList.queryMoreBookmarks(limit = 3)

// Query by activity ID
val activityBookmarkList = client.bookmarkList(
    query = BookmarksQuery(
        filter = Filters.equal("activity_id", "activity_123")
    )
)
val activityBookmarks: Result<List<BookmarkData>> = activityBookmarkList.get()

// Query by folder ID
val folderBookmarkList = client.bookmarkList(
    query = BookmarksQuery(
        filter = Filters.equal("folder_id", "folder_456")
    )
)
val folderBookmarks: Result<List<BookmarkData>> = folderBookmarkList.get()

Querying Bookmark Folders

// Query bookmark folders
val query = BookmarkFoldersQuery(limit = 5)
val bookmarkFolderList = client.bookmarkFolderList(query = query)
val page1: Result<List<BookmarkFolderData>> = bookmarkFolderList.get()

// Get next page
val page2: Result<List<BookmarkFolderData>> = bookmarkFolderList.queryMoreBookmarkFolders(limit = 3)

// Query by folder name (partial matching)
val projectFolderList = client.bookmarkFolderList(
    query = BookmarkFoldersQuery(
        filter = Filters.contains("folder_name", "project")
    )
)
val projectFolders: Result<List<BookmarkFolderData>> = projectFolderList.get()
Β© Getstream.io, Inc. All Rights Reserved.