// Adding a bookmark to a new folder
let bookmark = try await feed.addBookmark(activityId: "activity_123")
// Adding to an existing folder
let bookmarkWithFolder = try await feed.addBookmark(
activityId: "activity_123",
request: .init(folderId: "folder_456")
)
// Update a bookmark (without a folder initially) - add custom data and move it to a new folder
let updatedBookmark = try await feed.updateBookmark(
activityId: "activity_123",
request: .init(
custom: ["color": "blue"],
newFolder: .init(
custom: ["icon": "π"],
name: "New folder name"
)
)
)
// Update a bookmark - move it from one existing folder to another existing folder
let movedBookmark = try await feed.updateBookmark(
activityId: "activity_123",
request: .init(
folderId: "folder_456",
newFolderId: "folder_789"
)
)
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"
)
)
// Adding a bookmark to a new folder
const bookmark = await client.addBookmark({
activity_id: "activity_123",
});
// Adding to an existing folder
const bookmarkWithFolder = await client.addBookmark({
activity_id: "activity_123",
folder_id: "folder_456",
});
// Update a bookmark (without a folder initially) - add custom data and move it to a new folder
const updatedBookmark = await client.updateBookmark({
activity_id: "activity_123",
folder_id: "<old folder id>",
new_folder: {
name: "New folder name",
custom: {
icon: "π",
},
},
custom: {
color: "blue",
},
});
// Update a bookmark - move it from one existing folder to another existing folder
const movedBookmark = await client.updateBookmark({
activity_id: "activity_123",
folder_id: "<old folder id>",
new_folder_id: "<new folder id>",
});
// Adding a bookmark to a new folder
const bookmark = await client.feeds.addBookmark({
activity_id: "activity_123",
user_id: "<user_id>",
});
// Adding to an existing folder
const bookmarkWithFolder = await client.feeds.addBookmark({
activity_id: "activity_123",
folder_id: "folder_456",
user_id: "<user_id>",
});
// Update a bookmark (without a folder initially) - add custom data and move it to a new folder
const updatedBookmark = await client.feeds.updateBookmark({
activity_id: "activity_123",
folder_id: "<old folder id>",
new_folder: {
name: "New folder name",
custom: {
icon: "π",
},
},
custom: {
color: "blue",
},
user_id: "<user_id>",
});
// Update a bookmark - move it from one existing folder to another existing folder
const movedBookmark = await client.feeds.updateBookmark({
activity_id: "activity_123",
folder_id: "<old folder id>",
new_folder_id: "<new folder id>",
user_id: "<user_id>",
});
response, err := feedsClient.AddBookmark(ctx, activityID, &getstream.AddBookmarkRequest{
UserID: &testUserID,
NewFolder: &getstream.AddFolderRequest{
Name: testBookmarkFolder,
},
})
AddBookmarkRequest bookmarkRequest =
AddBookmarkRequest.builder()
.userID(testUserId)
.newFolder(AddFolderRequest.builder().name("test-bookmarks1").build())
.build();
AddBookmarkResponse response =
feeds.addBookmark(activityId, bookmarkRequest).execute().getData();
$response = $this->feedsV3Client->addBookmark(
$activityId,
new GeneratedModels\AddBookmarkRequest(
userID: $this->testUserId,
newFolder: new GeneratedModels\AddFolderRequest(name: 'test-bookmarks1')
)
);
var response = await _feedsV3Client.AddBookmarkAsync(
activityId,
new AddBookmarkRequest
{
UserID = _testUserId,
NewFolder = new AddFolderRequest { Name = "test-bookmarks1" }
}
);
response = self.client.feeds.add_bookmark(
activity_id,
user_id=self.test_user_id,
new_folder=AddFolderRequest(name="test-bookmarks1"),
)
Removing Bookmarks
// Removing a bookmark
try await feed.deleteBookmark(
activityId: "activity_123",
folderId: "folder_456"
)
// When you read a feed we include the bookmark
try await feed.getOrCreate()
print(feed.state.activities[0].ownBookmarks)
// 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)
}
// Removing a bookmark
await client.deleteBookmark({
activity_id: activityId,
});
// When you read a feed we include the bookmark
const response = await feed.getOrCreate({ watch: true });
console.log(feed.state.getLatestValue().activities?.[0].own_bookmarks);
console.log(feed.state.getLatestValue().activities?.[0].bookmark_count);
// Removing a bookmark
await serverClient.feeds.deleteBookmark({
activity_id: activityId,
user_id: testUser2.id,
});
// When you read a feed we include the bookmark
const response = await feed.getOrCreate({ user_id: "sara" });
console.log(results.activities[0].own_bookmarks);
console.log(results.activities[0].bookmark_count);
folderID := bookmarkResponse.Data.Bookmark.Folder.ID
response, err := feedsClient.UpdateBookmark(ctx, activityID, &getstream.UpdateBookmarkRequest{
FolderID: &folderID,
UserID: &testUserID,
})
UpdateBookmarkRequest updateRequest =
UpdateBookmarkRequest.builder().folderID(folderID).userID(testUserId).build();
UpdateBookmarkResponse response =
feeds.updateBookmark(activityId, updateRequest).execute().getData();
$bookmarkData = $bookmarkResponse->getData();
$folderID = $bookmarkData->bookmark->folder->id;
$response = $this->feedsV3Client->updateBookmark(
$activityId,
new GeneratedModels\UpdateBookmarkRequest(
folderID: $folderID,
userID: $this->testUserId
)
);
var response = await _feedsV3Client.UpdateBookmarkAsync(
activityId,
new UpdateBookmarkRequest
{
UserID = _testUserId,
FolderID = folderId // Use existing folder ID, not create new folder
}
);
bookmark_data = bookmark_response.data
folder_id = bookmark_data.bookmark.folder.id
response = self.client.feeds.update_bookmark(
activity_id, folder_id=folder_id, user_id=self.test_user_id
)
Querying Bookmarks
// Query bookmarks
let query = BookmarksQuery(limit: 5)
let bookmarkList = client.bookmarkList(for: query)
let page1 = try await bookmarkList.get()
// Get next page
let page2 = try await bookmarkList.queryMoreBookmarks(limit: 3)
// Query by activity ID
let activityBookmarkList = client.bookmarkList(
for: .init(
filter: .equal(.activityId, "activity_123")
)
)
let activityBookmarks = try await activityBookmarkList.get()
// Query by folder ID
let folderBookmarkList = client.bookmarkList(
for: .init(
filter: .equal(.folderId, "folder_456")
)
)
let folderBookmarks = try await folderBookmarkList.get()
// 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()
// Query bookmarks
const firstPage = await client.queryBookmarks({
limit: 2,
});
// Get next page
const secondPage = await client.queryBookmarks({
limit: 2,
next: firstPage.next,
});
// Query by activity ID
const response = await client.queryBookmarks({
filter: {
activity_id: "activity_123",
},
});
// Query by folder ID
const response = await client.queryBookmarks({
filter: {
folder_id: "folder_456",
},
});
// Query bookmarks
const firstPage = await client.feeds.queryBookmarks({
filter: {
user_id: "<user id>",
},
limit: 2,
});
// Get next page
const secondPage = await client.feeds.queryBookmarks({
filter: {
user_id: "<user id>",
},
limit: 2,
next: firstPage.next,
});
// Query by activity ID
const response = await client.feeds.queryBookmarks({
filter: {
user_id: "<user id>",
activity_id: "activity_123",
},
});
// Query by folder ID
const response = await client.feeds.queryBookmarks({
filter: {
user_id: "<user id>",
folder_id: "folder_456",
},
});
response, err := feedsClient.QueryBookmarks(ctx, &getstream.QueryBookmarksRequest{
Limit: getstream.PtrTo(10),
Filter: map[string]interface{}{
"user_id": testUserID,
},
})
Map<String, Object> filter = new HashMap<>();
filter.put("user_id", testUserId);
QueryBookmarksRequest request =
QueryBookmarksRequest.builder().limit(10).filter(filter).build();
QueryBookmarksResponse response = feeds.queryBookmarks(request).execute().getData();
$response = $this->feedsV3Client->queryBookmarks(
new GeneratedModels\QueryBookmarksRequest(
limit: 10,
filter: (object)['user_id' => $this->testUserId]
)
);
var response = await _feedsV3Client.QueryBookmarksAsync(
new QueryBookmarksRequest
{
Limit = 10,
Filter = new Dictionary<string, object> { ["user_id"] = _testUserId }
}
);
response = self.client.feeds.query_bookmarks(
limit=10, filter={"user_id": self.test_user_id}
)
Querying Bookmark Folders
// Query bookmark folders
let query = BookmarkFoldersQuery(limit: 5)
let bookmarkFolderList = client.bookmarkFolderList(for: query)
let page1 = try await bookmarkFolderList.get()
// Get next page
let page2 = try await bookmarkFolderList.queryMoreBookmarkFolders(limit: 3)
// Query by folder name (partial matching)
let projectFolderList = client.bookmarkFolderList(
for: .init(
filter: .contains(.folderName, "project")
)
)
let projectFolders = try await projectFolderList.get()
// 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()
// Query bookmark folders
const firstPage = await client.queryBookmarkFolders({
limit: 2,
});
// Get next page
const secondPage = await client.queryBookmarkFolders({
limit: 2,
next: firstPage.next,
});
const response = await client.queryBookmarkFolders({
filter: {
folder_name: {
$contains: "project",
},
},
limit: 2,
next: firstPage.next,
});
// Query bookmark folders
const firstPage = await client.feeds.queryBookmarkFolders({
filter: {
user_id: '<user id>'
},
limit: 2
});
// Get next page
const secondPage = await client.feeds.queryBookmarkFolders({
filter: {
user_id: '<user id>'
}
limit: 2,
next: firstPage.next,
});
const response = await client.feeds.queryBookmarkFolders({
filter: {
user_id: '<user id>',
folder_name: {
$contains: 'project'
}
},
limit: 2,
next: firstPage.next,
});
response, err := feedsClient.QueryBookmarks(ctx, &getstream.QueryBookmarksRequest{
Limit: getstream.PtrTo(10),
Filter: map[string]interface{}{
"user_id": testUserID,
},
})
Map<String, Object> filter = new HashMap<>();
filter.put("user_id", testUserId);
QueryBookmarksRequest request =
QueryBookmarksRequest.builder().limit(10).filter(filter).build();
QueryBookmarksResponse response = feeds.queryBookmarks(request).execute().getData();
$response = $this->feedsV3Client->queryBookmarks(
new GeneratedModels\QueryBookmarksRequest(
limit: 10,
filter: (object)['user_id' => $this->testUserId]
)
);
var response = await _feedsV3Client.QueryBookmarksAsync(
new QueryBookmarksRequest
{
Limit = 10,
Filter = new Dictionary<string, object> { ["user_id"] = _testUserId }
}
);
response = self.client.feeds.query_bookmarks(
limit=10, filter={"user_id": self.test_user_id}
)