Stream - Get the total number of followers
Asked Answered
C

2

15

I've created a feed reference and fetched the followers like so:

var admin = client.feed('user', 'admin');
const res = await admin.followers();

But the returned result contains paginated data. How can I count the total number of followers?

Will this feature be available or any rough estimation on the roadmap?

Is there any other recommended architecture to get this total count when working with Stream?

Connoisseur answered 17/1, 2018 at 19:4 Comment(1)
Did you ever figure this out?Lassitude
S
3

Looks like this is not supported yet.

Dwight Gunning wrote on github on 3rd of May, 2018:

Thanks for the interest. This is still on our long-range backlog.

https://github.com/GetStream/stream-django/issues/42

Soni answered 21/5, 2019 at 9:0 Comment(0)
F
3

It's now supported with the client.followStats() function:

// get follower and following stats of the feed 
client.feed('user', 'me').followStats() 
 
// get follower and following stats of the feed but also filter with given slugs 
// count by how many timelines follow me 
// count by how many markets are followed 
client.feed.followStats({followerSlugs: ['timeline'], followingSlugs: ['market']})

Which returns something like:

{  
  results: { 
    followers: { count: 1529, feed: 'user:me' }, 
    followings: { count: 81, feed: 'user:me' }   
  }, 
  duration: '1.92ms' 
}

Here is the API documentation for it: https://getstream.io/activity-feeds/docs/node/following/?language=javascript#reading-follow-stats

Fussbudget answered 17/2, 2021 at 6:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.