3

Does getstream provide a way to retrieve the number of activities within a feed? I have a notification feed setup. I can retrieve the activities using paginated get. However, I would like to display the number of items within the feed.

jgdreyes
  • 169
  • 1
  • 6

3 Answers3

0

Unfortunately not, there is no API endpoint to retrieve the amount of activities within a feed.

Matthisk
  • 1,501
  • 10
  • 20
0

At the moment there's no way to count activities directly. You can try

  • Use a custom feed and use reactions. So now you call count from reactions.
  • Other way is store in your app (cache/db/etc).

It worked for me:

signature = Stream::Signer.create_jwt_token('activities', '*', '<your_secret>', '*')

uri = URI("https://us-east-api.stream-io-api.com/api/v1.0/enrich/activities/?api_key=<api_key>&ids=<id1,id2,...>&withReactionCounts=true")
req = Net::HTTP::Get.new(uri)
req['Content-Type'] = "application/json"
req['Stream-Auth-Type'] = "jwt"
req['Authorization'] = signature

res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) {|http|
  http.request(req)
}

puts JSON.parse(res.body)

References:

Retrieve

reactions_read-feeds

activities

ruby client

fct
  • 311
  • 3
  • 18
0

Update 2022

You can only get the number of activities in groups within aggregated or notification feeds. Flat feeds are still not supported. Source

The best solution is to store important numbers in the database which Stream provides. Source

Nico
  • 195
  • 1
  • 13