Understanding how follow counts are computed between different feed groups is crucial for implementing accurate social features when working with Stream's Activity Feeds. This article explains the key concepts and default behaviors.
Default Feed Groups
Stream uses two primary feed groups by default:
- timeline: Used for following relationships
- user: Used for follower relationships
How Follow Counts Are Computed
Following Counts:
The following count represents how many user feeds a timeline feed follows. Specifically, it counts relationships where timeline:user_id follows feeds in the user feed group.
Follower Counts:
The follower count represents how many timeline feeds follow a user feed. Specifically, it counts relationships where user:user_id is followed by feeds in the timeline feed group.
Customizing Feed Groups
While Stream provides default feed groups, you can customize which feed groups are used to count followers and followers.
This is done using query parameters in your API requests:
- following_slug: Customize the feed group for the following (default is 'timeline')
- follower_slug: Customize the feed group for followers (default is 'user')
Why Counts Might Appear Different
If you notice different counts between various APIs, remember that the counts are specific to relationships between particular feed groups. The counts don't represent all follows/followers across all feed groups, but rather the specific relationships between the designated feed groups.
This targeted counting mechanism allows for more precise control over social relationships in your application, enabling you to structure your feed relationships according to your specific needs.
Here's the related cURL -
curl --location --request GET 'https://singapore.stream-io-api.com/api/v1.0/user/seetha?api_key=3ektw92qb4ew&with_follow_counts=true&following_slug=timeline&follower_slug=user' \
--header 'Content-Type: application/json' \
--header 'Stream-Auth-Type: jwt' \
--header 'Authorization: TOKEN' \
--data '{
"id": "seetha"
}'
Comments
0 comments
Please sign in to leave a comment.