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

AddBookmarkRequest bookmarkRequest =
    AddBookmarkRequest.builder()
        .userID(testUserId)
        .newFolder(AddFolderRequest.builder().name("test-bookmarks1").build())
        .build();

AddBookmarkResponse response =
    feeds.addBookmark(activityId, bookmarkRequest).execute().getData();

Removing Bookmarks

UpdateBookmarkRequest updateRequest =
    UpdateBookmarkRequest.builder().folderID(folderID).userID(testUserId).build();

UpdateBookmarkResponse response =
    feeds.updateBookmark(activityId, updateRequest).execute().getData();

Querying Bookmarks

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

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

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

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' } }

Managing Bookmark Folders

Update bookmark folder

The endpoint performs a partial update: only the fields you include in the request are changed, and each of those fields is completely overwritten.

Updating a bookmark folder sends feeds.bookmark_folder.updated event to the clients of the user who owns the folder. There are no default client-side SDK handlers for this event, but you can add a custom handler if your UI needs to be updated.

Delete bookmark folder

Use the delete bookmark folder endpoint to remove a folder by ID. All bookmarks in that folder are removed.

Deleting a bookmark folder sends feeds.bookmark_folder.deleted event to the clients of the user who owns the folder. There are no default client-side SDK handlers for this event, but you can add a custom handler if your UI needs to be updated.

// Add a bookmark with a new folder
AddBookmarkResponse addResponse = feeds.addBookmark(activityId,
    AddBookmarkRequest.builder()
        .userID(testUserId)
        .newFolder(AddFolderRequest.builder()
            .name("Breakfast recipes")
            .custom(Map.of("icon", "🍳"))
            .build())
        .build()).execute().getData();

String folderId = addResponse.getBookmark().getFolder().getId();

// Update the folder
UpdateBookmarkFolderResponse updateResponse = feeds.updateBookmarkFolder(folderId,
    UpdateBookmarkFolderRequest.builder()
        .name("Sweet Breakfast Recipes")
        .custom(Map.of("icon", "🥞"))
        .build()).execute().getData();

// Delete the folder (and all bookmarks in it)
feeds.deleteBookmarkFolder(updateResponse.getBookmarkFolder().getId()).execute();