Skip to main content

Get Topics

The getTopics() function is used to fetch a list of topics, which can be utilized for creating posts or other interactions within the community.

Steps to Get Topics

  1. Build a GetTopicsRequest object using the GetTopicsRequestBuilder class.
  2. Call the getTopics() function using the instance of the LMFeedClient class.
  3. Use the response as per your requirement.
note

isEnabled key is nullable, if you want to fetch enabled topics send isEnabled = true. For disabled topics send isEnabled = false and to fetch all the existing topics send send isEnabled = null

 // Build the request object
GetTopicsRequest request = (GetTopicsRequestBuilder()
..isEnabled(true)
..page(1)
..pageSize(10)
..search("example")
..searchType("type")
)
.build();

// Get the response from calling the function
final GetTopicsResponse response = await lmFeedClient.getTopics(request);

// Process the response, as per requirement
if(response.success){
// your function to handle successful retrieval of topics
handleTopics(response.topics);
}else{
// your function to handle error message
handleTopicsError(response.errorMessage);
}
tip

Fetching topics is essential for creating posts and engaging with the community. You can use the retrieved topics to provide users with relevant content and discussions.

Models

GetTopicsRequest

List of parameters for the GetTopicsRequest class

VariableTypeDescriptionOptional
isEnabledboolFlag indicating whether topics are enabled
pageintPage number for pagination
pageSizeintNumber of items per page
searchStringSearch query for filtering topics
searchTypeStringType of search query
parentIdsList<String>A list of parent topic IDs that this topic is associated with.
orderByList<String>Specifies the order in which topics should be sorted.

GetTopicsResponse

List of parameters for the GetTopicsResponse class

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageStringError message in case of failure
topicsList<Topic>List of topic models
widgetsMap<String, WidgetModel>Map of widget IDs to WidgetModel entities
childTopicsMap<String,List< Topic>>Map of parent topic IDs to List of child topics