Skip to main content

Get Universal Feed

The getUniversalFeed() function retrieves the universal feed, including posts, users, topics, widgets, and reposted posts based on specified parameters.

Steps to Get Universal Feed

  1. Build a GetFeedRequest object using the GetFeedRequestBuilder class.
  2. Call the getUniversalFeed() function using an instance of the LMFeedClient class.
  3. Use the response according to your requirements.
// Build the request object
final GetFeedRequest universalFeedRequest = (GetFeedRequestBuilder()
..page(1)
..pageSize(10)
..topicIds(["topic-id-1", "topic-id-2"])
..widgetIds(["widget-id-1"])
..startFeedWithPostIds(["post-id-1", "post-id-2"])
..feedType(LMFeedThemeType.socialFeed))
.build();

// Get the response from calling the function
final GetFeedResponse universalFeedResponse = await lmFeedClient.getUniversalFeed(universalFeedRequest);

// Process the response, as per requirement
if (universalFeedResponse.success) {
// your function to handle successful retrieval of universal feed
handleUniversalFeedSuccess(universalFeedResponse);
} else {
// your function to handle error message
handleUniversalFeedError(universalFeedResponse.errorMessage);
}
tip

Fetching the universal feed allows you to provide users with a curated feed based on specified topics and widgets.

Models

GetFeedRequest

List of parameters for the GetFeedRequest class:

VariableTypeDescriptionOptional
pageintPage number for pagination
pageSizeintNumber of items per page
topicIdsList<String>List of topic IDs
widgetIdsList<String>List of widget IDs
startFeedWithPostIdsList<String>IDs of the posts to start the feed with
feedTypeLMFeedThemeTypeType of feed theme

LMFeedThemeType (enum)

Available themes for feed customization:

Enum ValueString ValueDescription
socialFeedsocial_feedSocial feed theme
qnaFeedqna_feedQuestion and Answer feed
videoFeedvideo_feedVideo content/reels feed

GetFeedResponse

List of parameters for the GetFeedResponse class:

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageStringError message in case of failure
postsList<Post>List of post models
usersMap<String, User>Map of user models (key: user ID)
topicsMap<String, Topic>Map of topic models (key: topic ID)
widgetsMap<String, WidgetModel>Map of widget models (key: widget ID)
repostedPostsMap<String, Post>Map of reposted post models (key: post ID)
filteredCommentsMap<String, Comment>Map of filtered comments
userTopicsMap<String, List<String>>Map of user topics (key: user ID)
startFeedWithPostIdsList<String>?IDs of the posts to start the feed with