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
- Build a
GetFeedRequest
object using theGetFeedRequestBuilder
class. - Call the
getUniversalFeed()
function using an instance of theLMFeedClient
class. - 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:
Variable | Type | Description | Optional |
---|---|---|---|
page | int | Page number for pagination | |
pageSize | int | Number of items per page | |
topicIds | List<String> | List of topic IDs | ✔ |
widgetIds | List<String> | List of widget IDs | ✔ |
startFeedWithPostIds | List<String> | IDs of the posts to start the feed with | ✔ |
feedType | LMFeedThemeType | Type of feed theme | ✔ |
LMFeedThemeType (enum)
Available themes for feed customization:
Enum Value | String Value | Description |
---|---|---|
socialFeed | social_feed | Social feed theme |
qnaFeed | qna_feed | Question and Answer feed |
videoFeed | video_feed | Video content/reels feed |
GetFeedResponse
List of parameters for the GetFeedResponse
class:
Variable | Type | Description | Optional |
---|---|---|---|
success | bool | API success status | |
errorMessage | String | Error message in case of failure | ✔ |
posts | List<Post> | List of post models | ✔ |
users | Map<String, User> | Map of user models (key: user ID) | ✔ |
topics | Map<String, Topic> | Map of topic models (key: topic ID) | ✔ |
widgets | Map<String, WidgetModel> | Map of widget models (key: widget ID) | ✔ |
repostedPosts | Map<String, Post> | Map of reposted post models (key: post ID) | ✔ |
filteredComments | Map<String, Comment> | Map of filtered comments | ✔ |
userTopics | Map<String, List<String>> | Map of user topics (key: user ID) | ✔ |
startFeedWithPostIds | List<String>? | IDs of the posts to start the feed with | ✔ |