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
bookmark_request = GetStream::Generated::Models::AddBookmarkRequest.new(
  user_id: 'user123',
  new_folder: GetStream::Generated::Models::AddFolderRequest.new(
    name: 'test-bookmarks1'
  )
)

response = client.feeds.add_bookmark(activity_id, bookmark_request)

# Adding to an existing folder
bookmark_with_folder_request = GetStream::Generated::Models::AddBookmarkRequest.new(
  user_id: 'user123',
  folder_id: 'folder_456'
)

response = client.feeds.add_bookmark(activity_id, bookmark_with_folder_request)

# Update a bookmark (without a folder initially) - add custom data and move it to a new folder
update_request = GetStream::Generated::Models::UpdateBookmarkRequest.new(
  user_id: 'user123',
  custom: {
    color: 'blue'
  },
  new_folder: GetStream::Generated::Models::AddFolderRequest.new(
    name: 'New folder name',
    custom: {
      icon: 'πŸ“'
    }
  )
)

response = client.feeds.update_bookmark(activity_id, update_request)

# Update a bookmark - move it from one existing folder to another existing folder
move_request = GetStream::Generated::Models::UpdateBookmarkRequest.new(
  user_id: 'user123',
  folder_id: 'folder_456',
  new_folder_id: 'folder_789'
)

response = client.feeds.update_bookmark(activity_id, move_request)

Removing Bookmarks

# Removing a bookmark
response = client.feeds.delete_bookmark(activity_id, folder_id, 'user123')

# When you read a feed we include the bookmark
feed_response = client.feeds.get_or_create('user', 'user123')
puts feed_response.activities[0].own_bookmarks
puts feed_response.activities[0].bookmark_count

Querying Bookmarks

# Query bookmarks
query_request = GetStream::Generated::Models::QueryBookmarksRequest.new(
  limit: 10,
  filter: {
    user_id: 'user123'
  }
)

response = client.feeds.query_bookmarks(query_request)

# Query by activity ID
activity_query_request = GetStream::Generated::Models::QueryBookmarksRequest.new(
  filter: {
    user_id: 'user123',
    activity_id: 'activity_123'
  }
)

response = client.feeds.query_bookmarks(activity_query_request)

# Query by folder ID
folder_query_request = GetStream::Generated::Models::QueryBookmarksRequest.new(
  filter: {
    user_id: 'user123',
    folder_id: 'folder_456'
  }
)

response = client.feeds.query_bookmarks(folder_query_request)

Bookmarks Queryable Built-In Fields

nametypedescriptionsupported operationsexample
user_idstring or list of stringsThe ID of the user who owns the bookmark$in, $eq{ user_id: { $eq: 'user_123' } }
activity_idstring or list of stringsThe ID of the activity that was bookmarked$in, $eq{ activity_id: { $eq: 'activity_123' } }
folder_idstring or list of stringsThe ID of the folder containing the bookmark$eq, $in, $exists{ folder_id: { $exists: true } }
created_atstring, must be formatted as an RFC3339 timestampThe time the bookmark was created$eq, $gt, $gte, $lt, $lte{ created_at: { $gte: '2023-12-04T09:30:20.45Z' } }
updated_atstring, must be formatted as an RFC3339 timestampThe time the bookmark was last updated$eq, $gt, $gte, $lt, $lte{ updated_at: { $gte: '2023-12-04T09:30:20.45Z' } }

Querying Bookmark Folders

# Query bookmarks
query_request = GetStream::Generated::Models::QueryBookmarksRequest.new(
  limit: 10,
  filter: {
    user_id: 'user123'
  }
)

response = client.feeds.query_bookmarks(query_request)

# Query by activity ID
activity_query_request = GetStream::Generated::Models::QueryBookmarksRequest.new(
  filter: {
    user_id: 'user123',
    activity_id: 'activity_123'
  }
)

response = client.feeds.query_bookmarks(activity_query_request)

# Query by folder ID
folder_query_request = GetStream::Generated::Models::QueryBookmarksRequest.new(
  filter: {
    user_id: 'user123',
    folder_id: 'folder_456'
  }
)

response = client.feeds.query_bookmarks(folder_query_request)

Bookmark Folders Queryable Built-In Fields

nametypedescriptionsupported operationsexample
user_idstring or list of stringsThe ID of the user who owns the folder$in, $eq{ user_id: { $eq: 'user_123' } }
folder_namestring or list of stringsThe name of the bookmark folder$eq, $in, $contains{ folder_name: { $contains: 'work' } }
created_atstring, must be formatted as an RFC3339 timestampThe time the folder was created$eq, $gt, $gte, $lt, $lte{ created_at: { $gte: '2023-12-04T09:30:20.45Z' } }
updated_atstring, must be formatted as an RFC3339 timestampThe time the folder was last updated$eq, $gt, $gte, $lt, $lte{ updated_at: { $gte: '2023-12-04T09:30:20.45Z' } }
Β© Getstream.io, Inc. All Rights Reserved.