Activity Feeds v3 is in beta β€” try it out!

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 _, err = client.Feeds().AddBookmark(context.Background(), activityID, &getstream.AddBookmarkRequest{  UserID: getstream.PtrTo("john"), }) if err != nil {  log.Fatal("Error adding bookmark:", err) }  // Adding to an existing folder _, err = client.Feeds().AddBookmark(context.Background(), activityID, &getstream.AddBookmarkRequest{  FolderID: getstream.PtrTo("folder_456"),  UserID: getstream.PtrTo("john"), }) if err != nil {  log.Fatal("Error adding bookmark to folder:", err) }  // Update a bookmark (without a folder initially) - add custom data and move it to a new folder _, err = client.Feeds().UpdateBookmark(context.Background(), activityID, &getstream.UpdateBookmarkRequest{  FolderID: getstream.PtrTo("old folder id"),  NewFolder: &getstream.AddFolderRequest{  Name: "New folder name",  Custom: map[string]any{  "icon": "πŸ“‚",  },  },  Custom: map[string]any{  "color": "blue",  },  UserID: getstream.PtrTo("john"), }) if err != nil {  log.Fatal("Error updating bookmark:", err) }  // Update a bookmark - move it from one existing folder to another existing folder _, err = client.Feeds().UpdateBookmark(context.Background(), activityID, &getstream.UpdateBookmarkRequest{  FolderID: getstream.PtrTo("old folder id"),  NewFolderID: getstream.PtrTo("new folder id"),  UserID: getstream.PtrTo("john"), }) if err != nil {  log.Fatal("Error moving bookmark:", err) }

Removing Bookmarks

_, err = client.Feeds().DeleteBookmark(context.Background(), activityID, &getstream.DeleteBookmarkRequest{  FolderID: getstream.PtrTo(folderID),  UserID: getstream.PtrTo("john"), })

Querying Bookmarks

// Query bookmarks firstPage, err := client.Feeds().QueryBookmarks(context.Background(), &getstream.QueryBookmarksRequest{  Filter: map[string]any{  "user_id": "john",  },  Limit: getstream.PtrTo(2), }) if err != nil {  log.Fatal("Error querying bookmarks:", err) }  // Get next page _, err = client.Feeds().QueryBookmarks(context.Background(), &getstream.QueryBookmarksRequest{  Filter: map[string]any{  "user_id": "john",  },  Limit: getstream.PtrTo(2),  Next: firstPage.Data.Next, }) if err != nil {  log.Fatal("Error querying next page bookmarks:", err) }  // Query by activity ID _, err = client.Feeds().QueryBookmarks(context.Background(), &getstream.QueryBookmarksRequest{  Filter: map[string]any{  "user_id": "john",  "activity_id": activityID,  }, }) if err != nil {  log.Fatal("Error querying bookmarks by activity ID:", err) }  // Query by folder ID _, err = client.Feeds().QueryBookmarks(context.Background(), &getstream.QueryBookmarksRequest{  Filter: map[string]any{  "user_id": "john",  "folder_id": folderID,  }, }) if err != nil {  log.Fatal("Error querying bookmarks by folder ID:", err) }

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 bookmark folders firstPage, err := client.Feeds().QueryBookmarkFolders(context.Background(), &getstream.QueryBookmarkFoldersRequest{  Filter: map[string]any{  "user_id": "<user id>",  },  Limit: getstream.PtrTo(2), }) if err != nil {  log.Fatal("Error querying bookmark folders:", err) } // Get next page _, err = client.Feeds().QueryBookmarkFolders(context.Background(), &getstream.QueryBookmarkFoldersRequest{  Filter: map[string]any{  "user_id": "<user id>",  },  Limit: getstream.PtrTo(2),  Next: firstPage.Data.Next, }) if err != nil {  log.Fatal("Error querying bookmark folders second page:", err) }  // Query with folder name filter _, err = client.Feeds().QueryBookmarkFolders(context.Background(), &getstream.QueryBookmarkFoldersRequest{  Filter: map[string]any{  "user_id": "<user id>",  "folder_name": map[string]any{  "$contains": "project",  },  },  Limit: getstream.PtrTo(2),  Next: firstPage.Data.Next, }) if err != nil {  log.Fatal("Error querying bookmark folders with filter:", err) }

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.