Skip to main content

Get Universal Feed

The getUniversalFeed() function is used to retrieve 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 the instance of the LMFeedClient class.

  3. Use the response as per your requirement.

     // Build the request object
    final GetFeedRequest universalFeedRequest = (GetFeedRequestBuilder()
    ..page(1)
    ..pageSize(10)
    ..topicIds(["topic-id-1", "topic-id-2"]))
    .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
topicsList<String>List of topic IDs
widgetIdsList<String>List of widget IDs

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)