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
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>',
});

Removing Bookmarks

// 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);

Querying Bookmarks

// 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",
  },
});

Querying Bookmark Folders

// 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,
});
Β© Getstream.io, Inc. All Rights Reserved.