Skip to content

Topics

Create Topics

You can create and manage topics from the Dashboard and HTTP API. To create topics from the dashboard navigate to the Topics page and click on the New Topic button.

Create Topic - GetSocial Dashboard

Topic creation needs the following information:

  1. Topic id: this is a unique id that you provide to identify the topic
  2. Name and Description: Name of the topic and description that you can make visible to your users. You can also enable users to search and discover topics by topic name. These can also be localized to 36+ supported languages.
  3. Icon: Topic icon is optional. Icon can be displayed with name and description in the app
  4. Permissions: with topic permissions you can define which users can post activity and interact with the topic. Interaction includes comments and reactions. You can enable everyone to post and interact, or only followers or a combination of one or more.
  5. Properties: additional metadata that you can add to the topic e.g custom data that might define UI elements for topic like topic color.

Get Topics

You can get a paginated list of all topics in your application:

val query = TopicsQuery.all()
val pagingQuery = PagingQuery(query)
Communities.getTopics(pagingQuery, { result: PagingResult<Topic> ->
    val topics = result.entries
    Log.d("Communities", "Topics: $topics")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get list of topics: $error")
})
let query = TopicsQuery.all()
let pagingQuery = TopicsPagingQuery(query)
Communities.topics(pagingQuery, success: { result in
    print("Topics: \(result.topics)")
}, failure: { error in
    print("Failed to get list of topics: \(error)")
})
var query = TopicsQuery.All();
var pagingQuery = new PagingQuery<TopicsQuery>(query);

Communities.GetTopics(pagingQuery,
    (result) => {
        Debug.Log("Topics: " + result.Entries);
    },
    (error) => {
        Debug.Log("Failed to get list of topics, error: " + error);
    });
var query = TopicsQuery.all();
var pagingQuery = PagingQuery(query);
Communities.getTopics(pagingQuery)
    .then((result) {
        var topics = result.entries;
        print('Topics: $topics');
    }).catchError((error) => { print('Failed to get list of topics, error: $error') });
const query = TopicsQuery.all();
const pagingQuery = new PagingQuery(query);
Communities.getTopics(pagingQuery)
    .then((result) => {
        var topics = result.entries;
        console.log('Topics: ' + topics);
    }, (error) => {
        console.log('Failed to get list of topics, error: ' + error.message);
    });
const query = GetSocialSDK.TopicsQuery.all();
GetSocialSDK.Communities.getTopics(new GetSocialSDK.PagingQuery(query))
    .then((result) => {
        var topics = result.entries;
        console.log('Topics: ', topics);
    }, (error) => {
        console.log('Failed to get list of topics, error: ', error);
    });

This method uses the PagingQuery concept that is used across our SDK. Read more about this.

Find Topics

You can also search topics by a query. Method returns all topics that contains the provided query as a substring in ID or Title. It is also case-insensitive.

val searchString = "cat"
val query = TopicsQuery.find(searchString)
val pagingQuery = PagingQuery(query)
Communities.getTopics(pagingQuery, { result: PagingResult<Topic> ->
    val topics = result.entries
    Log.d("Communities", "Topics contains $searchString: $topics")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get list of topics: $error")
})
let searchString = "cat"
let query = TopicsQuery.find(searchString)
let pagingQuery = TopicsPagingQuery(query)
Communities.topics(pagingQuery, success: { result in
    print("Topics containing \(searchString): \(result.topics)")
}, failure: { error in
    print("Failed to get list of topics: \(error)")
})
var query = TopicsQuery.Find("cats");
var pagingQuery = new PagingQuery<TopicsQuery>(query);

Communities.GetTopics(pagingQuery,
    (result) => {
        Debug.Log("Topics including `cats`: " + result.Entries);
    },
    (error) => {
        Debug.Log("Failed to search for topics, error: " + error);
    });
var searchString = 'cat';
var query = TopicsQuery.find(searchString);
var pagingQuery = PagingQuery(query);
Communities.getTopics(pagingQuery)
    .then((result) {
        var topics = result.entries;
        print('Topics contain "cat": $topics');
    }).catchError((error) => { print('Failed to find topics, error: $error') });
const searchString = 'cat';
const query = TopicsQuery.find(searchString);
const pagingQuery = new PagingQuery(query);
Communities.getTopics(pagingQuery)
    .then((result) => {
        const topics = result.entries;
        console.log('Topics contain "cat": ' + topics);
    }, (error) => {
        console.log('Failed to find topics, error: ' + error.message);
    });
const searchString = 'cat';
const query = GetSocialSDK.TopicsQuery.find(searchString);
GetSocialSDK.Communities.getTopics(new GetSocialSDK.PagingQuery(query))
    .then((result) => {
        const topics = result.entries;
        console.log('Topics contain "cat": ', topics);
    }, (error) => {
        console.log('Failed to find topics, error: ', error);
    });

This method uses the PagingQuery concept that is used across our SDK. Read more about this.

It is possible to get trending topics:

val query = TopicsQuery.find("cats").onlyTrending(true)
let query = TopicsQuery.find("cats").onlyTrending(true)
var query = TopicsQuery.Find("cats").OnlyTrending(true);
var query = TopicsQuery.find('cats').onlyTrending(true);
const query = TopicsQuery.find('cats').onlyTrending(true);
const query = GetSocialSDK.TopicsQuery.find('cats').onlyTrending(true);

Get Topics Count

Use the same query as you’re using to Get or Find topics.

val searchString = "cat"
val query = TopicsQuery.find(searchString)
Communities.getTopicsCount(query, { result: Int ->
    Log.d("Communities", "Topics count contains $searchString: $result")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get number of topics: $error")
})
let searchString = "cat"
let query = TopicsQuery.find(searchString)
Communities.topicsCount(query, success: { topicsCount in
    print("Topics count containing \(searchString): \(topicsCount)")
}, failure: { error in
    print("Failed to get number of topics: \(error)")
})
var query = TopicsQuery.Find("cats");

Communities.GetTopicsCount(query,
    (result) => {
        Debug.Log("Number of topics including `cats`: " + result);
    },
    (error) => {
        Debug.Log("Failed to get number of topics, error: " + error);
    });
var searchString = 'cat';
var query = TopicsQuery.find(searchString);
Communities.getTopicsCount(query)
    .then((result) {
        print('Topics count containing "cat": $result');
    }).catchError((error) => { print('Failed to get topics count, error: $error') });
const searchString = 'cat';
const query = TopicsQuery.find(searchString);
Communities.getTopicsCount(query)
    .then((result) => {
        console.log('Topics count containing "cat": ' + result);
    }, (error) => {
        console.log('Failed to get topics count, error: ' + error.message);
    });
const searchString = 'cat';
const query = GetSocialSDK.TopicsQuery.find(searchString);
GetSocialSDK.Communities.getTopicsCount(query)
    .then((result) => {
        console.log('Topics count containing "cat": ', result);
    }, (error) => {
        console.log('Failed to get topics count, error: ', error);
    });

Get Topic By ID

If you have just an ID of topic, you can get the topic object:

val topicId = "topic-id"

Communities.getTopic(topicId, { topic ->
    Log.d("Communities", "Topic with id $topicId: $topic")
}, { error ->
    Log.d("Communities", "Failed to get a topic: $error")
})
let topicId = "topic-id"
Communities.topic(topicId, success: { topic in
    print("Topic with id '\(topicId): \(topic)")
}, failure: { error in
    print("Failed to get topic: \(error)")
})
var topicId = "topic-id";

Communities.GetTopic(topicId,
    (result) => {
        Debug.Log("Topic: " + result);
    },
    (error) => {
        Debug.Log("Failed to get topic, error: " + error);
    });
var topicId = 'topic-id';
Communities.getTopic(topicId)
    .then((result) {
        print('Topic: $result');
    }).catchError((error) => { print('Failed to get topic, error: $error') });
const topicId = 'topic-id';
Communities.getTopic(topicId)
    .then((result) => {
        console.log('Topic: ' + result);
    }, (error) => {
        console.log('Failed to get topic, error: ' + error.message);
    });
GetSocialSDK.Communities.getTopic('topic-id')
    .then((result) => {
        console.log('Topic: ', result);
    }, (error) => {
        console.log('Failed to get topic, error: ', error);
    });

Work With Topic Object

Learn what can you do with topic object in Android and iOS.

Follow

To follow topics use:

Communities.follow(FollowQuery.topics("dogs", "cats", "daily-challenges"), { topicsFollowing ->
    Log.d("Communities", "Successfully followed the topics. Now you follow $topicsFollowing topics!")
}, { error ->
    Log.d("Communities", "Failed to follow topics: $error")
})
Communities.follow(FollowQuery.topics(["dogs", "cats", "daily-challenges"]), success: { topicsFollowing in
    print("Successfully followed the topics. Now you follow \(topicsFollowing) topics!")
}, failure: { error in
    print("Failed to follow topics: \(error)")
})
Communities.Follow(FollowQuery.Topics("dogs", "cats", "daily-challenges"),
    (topicsFollowing) => {
        Debug.Log("Successfully followed the topics. Number of followed topics: " + topicsFollowing);
    },
    (error) => {
        Debug.Log("Failed to follow topics, error " + error);
    });
Communities.follow(FollowQuery.topics(['dogs', 'cats', 'daily-challenges']))
    .then((result) => print('Successfully followed the topics. Number of followed topics: $result'))
    .catchError((error) => print('Failed to follow topics, error: $error'));
Communities.follow(FollowQuery.topics(['dogs', 'cats', 'daily-challenges']))
    .then((result) => { console.log('Successfully followed the topics. Number of followed topics: ' + result); },(error) => { console.log('Failed to follow topics, error: ' + error.message); });
GetSocialSDK.Communities.follow(GetSocialSDK.FollowQuery.topics(['dogs', 'cats', 'daily-challenges']))
    .then((result) => {
        console.log('Successfully followed the topics. Number of followed topics: ', result);
    },
    (error) => {
        console.log('Failed to follow topics, error: ', error);
    });

Unfollow

Unfollow works in the same way, as Follow, just use method unfollow:

Communities.unfollow(FollowQuery.topics("dogs", "cats", "daily-challenges"), { topicsFollowing ->
    Log.d("Communities", "Successully unfollowed the topics. Now you follow $topicsFollowing topics!")
}, { error ->
    Log.d("Communities", "Failed to follow topics: $error")
})
Communities.unfollow(FollowQuery.topics(["dogs", "cats", "daily-challenges"]), success: { topicsFollowing in
    print("Successully unfollowed the topics. Now you follow \(topicsFollowing) topics!")
}, failure: { error in
    print("Failed to follow topics: \(error)")
})
Communities.Unfollow(FollowQuery.Topics("dogs", "cats", "daily-challenges"),
    (topicsFollowing) => {
        Debug.Log("Successfully unfollowed the topics. Number of followed topics: " + topicsFollowing);
    },
    (error) => {
        Debug.Log("Failed to unfollow topics, error " + error);
    });
Communities.unfollow(FollowQuery.topics(['dogs', 'cats', 'daily-challenges']))
    .then((result) => print('Successfully unfollowed the topics. Number of followed topics: $result'))
    .catchError((error) => print('Failed to unfollow topics, error: $error'));
Communities.unfollow(FollowQuery.topics(['dogs', 'cats', 'daily-challenges']))
    .then((result) => { console.log('Successfully unfollowed the topics. Number of followed topics: ' + result); },(error) => { console.log('Failed to unfollow topics, error: ' + error.message); });
GetSocialSDK.Communities.unfollow(GetSocialSDK.FollowQuery.topics(['dogs', 'cats', 'daily-challenges']))
    .then((result) => {
        console.log('Successfully unfollowed the topics. Number of followed topics: ', result);
    }, (error) => {
        console.log('Failed to unfollow topics, error: ', error);
    });

Is Following

To check if a certain user is following topics, use:

Communities.isFollowing(UserId.currentUser(), FollowQuery.topics("cats", "dogs"), { isFollowing ->
    Log.d("Communities", "Current user is following topic 'cats': ${isFollowing["cats"]}")
    Log.d("Communities", "Current user is following topic 'dogs': ${isFollowing["dogs"]}")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get followers of topic: $error")
})
Communities.isFollowing(UserId.currentUser(), query: FollowQuery.topics(["cats", "dogs"]), success: { isFollowing in
    print("Current user is following topic 'cats': \(isFollowing["cats"])")
    print("Current user is following topic 'dogs': \(isFollowing["dogs"])")
}, failure: { error in
    print("Failed to check followers of topics: \(error)")
})
Communities.IsFollowing(UserId.CurrentUser(), FollowQuery.Topics("cats", "dogs"),
    (result) => {
        Debug.Log("Current user is following topic 'cats': " + result["cats"]);
        Debug.Log("Current user is following topic 'dogs': " + result["dogs"]);
    },
    (error) => {
        Debug.Log("Failed to check followers of topics, error: " + error);
    }
);
Communities.isFollowing(UserId.currentUser(), FollowQuery.topics(['cats', 'dogs']))
    .then((result) {
        var catsFollowed = result['cats'];
        var dogsFollowed = result['dogs'];
        print('Current user is following topic "cats": $catsFollowed');
        print('Current user is following topic "dogs": $dogsFollowed');
    })
    .catchError((error) => { print('Failed to check followers of topics, error: $error') });
Communities.isFollowing(UserId.currentUser(), FollowQuery.topics(['cats', 'dogs']))
    .then((result) => {
        var catsFollowed = result['cats'];
        var dogsFollowed = result['dogs'];
        console.log('Current user is following topic "cats": ' + catsFollowed);
        console.log('Current user is following topic "dogs": ' + dogsFollowed);
    }, (error) => {
        console.log('Failed to check followers of topics, error: ' + error.message);
    });
GetSocialSDK.Communities.isFollowing(GetSocialSDK.UserId.currentUser(), GetSocialSDK.FollowQuery.topics(['cats', 'dogs']))
    .then((result) => {
        var catsFollowed = result['cats'];
        var dogsFollowed = result['dogs'];
        console.log('Current user is following topic "cats": ', catsFollowed);
        console.log('Current user is following topic "dogs": ', dogsFollowed);
    }, (error) => {
        console.log('Failed to check followers of topics, error: ', error);
    });

First parameter is a user ID. We’re checking if current user is following some topics. The result is a map of String -> Boolean, where key is the id of the topic passed to FollowQuery and value is true, is user is following this topic or false otherwise.

Unexisting topics won’t be included in the result map.

Get Followers

To get followers of a topic:

val followersQuery = FollowersQuery.ofTopic("cats")
val pagingQuery = PagingQuery(followersQuery).withLimit(25)
Communities.getFollowers(pagingQuery, { result: PagingResult<User> ->
    val followersOfCatsTopic = result.entries
    Log.d("Communities", "Followers of topic 'cats': $followersOfCatsTopic")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get followers of the topic: $error")
})
let followersQuery = FollowersQuery.ofTopic("cats")
let pagingQuery = FollowersPagingQuery.init(followersQuery)
pagingQuery.limit = 25

Communities.followers(pagingQuery, success: { result in
    print("Followers of topic 'cats': \(result.followers)")
}, failure: { error in
    print("Failed to get followers of topic: \(error)")
})
var followersQuery = FollowersQuery.OfTopic("cats");
var pagingQuery = new PagingQuery<FollowersQuery>(followersQuery);
Communities.GetFollowers(pagingQuery,
    (result) => {
        Debug.Log("Followers of topic 'cats': " + result.Entries);
    },
    (error) => {
        Debug.Log("Failed to get followers of topic: " + error);
    });
var followersQuery = FollowersQuery.ofTopic('cats');
var pagingQuery = PagingQuery(followersQuery);
pagingQuery.limit = 25;
Communities.getFollowers(pagingQuery)
    .then((result) {
        var followers = result.entries;
        print('Followers of topic "cats": $followers');
    })
    .catchError((error) => { print('Failed to check followers of topic, error: $error') });
const followersQuery = FollowersQuery.ofTopic('cats');
const pagingQuery = new PagingQuery(followersQuery);
pagingQuery.limit = 25;
Communities.getFollowers(pagingQuery)
    .then((result) => {
        var followers = result.entries;
        console.log('Followers of topic "cats":' + followers);
    }, (error) => {
        console.log('Failed to check followers of topic, error: ' + error.message);
    });
const followersQuery = GetSocialSDK.FollowersQuery.ofTopic('cats');
const pagingQuery = new GetSocialSDK.PagingQuery(followersQuery);
pagingQuery.limit = 25;
GetSocialSDK.Communities.getFollowers(pagingQuery)
    .then((result) => {
        var followers = result.entries;
        console.log('Followers of topic "cats":', followers);
    }, (error) => {
        console.log('Failed to check followers of topic, error: ', error);
    });

This method uses the PagingQuery concept that is used across our SDK. Read more about this.

Followers Count

To get the followers count of a topic:

val topicsFollowers = FollowersQuery.ofTopic("level1")
Communities.getFollowersCount(topicsFollowers, { followersCount: Int ->
    Log.d("Communities", "Followers count of topic 'level1': $followersCount")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get followers of topic: $error")
})
let topicFollowers = FollowersQuery.ofTopic("level1")
Communities.followersCount(topicFollowers, success: { followersCount in
    print("Followers count of topic 'level1': \(followersCount)")
}, failure: { error in
    print("Failed to get followers count of topic: \(error)")
})
var topicFollowers = FollowersQuery.OfTopic("cats");
Communities.GetFollowersCount(topicFollowers,
    (result) => {
        Debug.Log("Followers count of topic 'cats': " + result);
    },
    (error) => {
        Debug.Log("Failed to get followers count of topic: " + error);
    });
var topicFollowers = FollowersQuery.ofTopic('level1');
Communities.getFollowersCount(topicFollowers)
    .then((result) {
        print('Followers count of topic "level1": $result');
    })
    .catchError((error) => { print('Failed to check followers count of topic, error: $error') });
const topicFollowers = FollowersQuery.ofTopic('level1');
Communities.getFollowersCount(topicFollowers)
    .then((result) => {
        console.log('Followers count of topic "level1": ' + result);
    }, (error) => {
        console.log('Failed to check followers count of topic, error: ' + error.message);
    });
const topicFollowers = GetSocialSDK.FollowersQuery.ofTopic('level1');
GetSocialSDK.Communities.getFollowersCount(topicFollowers)
    .then((result) => {
        console.log('Followers count of topic "level1": ', result);
    }, (error) => {
        console.log('Failed to check followers count of topic, error: ', error);
    });

Get Following Topics

You can also get all the topics that are followed by a certain user:

val query = TopicsQuery.followedBy(UserId.currentUser())
val pagingQuery = PagingQuery(query)
Communities.getTopics(pagingQuery, { result: PagingResult<Topic> ->
    val topics = result.entries
    Log.d("Communities", "Topics followed by current user: $topics")
}, { error: GetSocialError ->
    Log.d("Communities", "Failed to get list of topics: $error")
})
let query = TopicsQuery.followedBy(UserId.currentUser())
let pagingQuery = TopicsPagingQuery(query)
Communities.topics(pagingQuery, success: { result in
    print("Topics followed by current user: \(result.topics)")
}, failure: { error in
    print("Failed to get list of topics: \(error)")
})
var query = TopicsQuery.FollowedBy(UserId.CurrentUser());
var pagingQuery = new PagingQuery<TopicsQuery(query);
Communities.GetTopics(pagingQuery,
    (result) => {
        Debug.Log("Topics followed by current user: " + result.Entries);
    },
    (error) => {
        Debug.Log("Failed to get list of topics: " + error);
    });
var query = TopicsQuery.all().followedBy(UserId.currentUser());
var pagingQuery = PagingQuery(query);
Communities.getTopics(pagingQuery)
    .then((result) {
        var topics = result.entries;
        print('Topics followed by current user: $topics');
    }).catchError((error) => { print('Failed to get list of topics, error: $error') });
const query = TopicsQuery.all().followedBy(UserId.currentUser());
const pagingQuery = new PagingQuery(query);
Communities.getTopics(pagingQuery)
    .then((result) => {
        var topics = result.entries;
        console.log('Topics followed by current user: ' + topics);
    }, (error) => {
        console.log('Failed to get list of topics, error: ', error);
    });
const query = GetSocialSDK.TopicsQuery.all().followedBy(GetSocialSDK.UserId.currentUser());
GetSocialSDK.Communities.getTopics(new GetSocialSDK.PagingQuery(query))
    .then((result) => {
        var topics = result.entries;
        console.log('Topics followed by current user: ', topics);
    }, (error) => {
        console.log('Failed to get list of topics, error:', error);
    });

Topic Feed

Every topic has its own feed where users can interact with each other and see the topic’s post on their timeline.

In addition to this, you can also post announcements on specific topic from the dashboard.

Learn what how can you Load Content from a Topic Feed or Post in a Topic feed.

Give us your feedback! Was this article helpful?

😀 🙁