Using slack API to get conversation lists

751 views Asked by At

I am trying to invoke following slack API to fetch private and public channels. https://api.slack.com/methods/conversations.list

By default as per slack documentation 200 channels are returned at a time when limit is given 1000.

I am passing types= “private_channel,public_channel“ to get the private as well as public channels.

  1. If I pass the types = public_channel with limit 1000 or 9999,
  • 162 channels are returned
  1. If I pass the types= private_channel,public_channel with limit 1000 or 9999,
  • 105 channels are returned

Can anybody please answer same.

1

There are 1 answers

0
Taylor Singletary On

With the way pagination works in that API, it's possible to get fewer than the number of results you're asking for, even if there are more results in the total collection to return. You'll need to check if there are additional pages of results and crawl through all of them to build the complete set.

This is because of the way data is retrieved in the back end -- it includes archived data, data of other types -- all the filtering that happens for your result happens after the data is fetched, making additional API calls required to get the next window of data to be filtered and then presented to you.

Here's the relevant documentation:

It's possible to receive fewer results than your specified limit, even when there are additional results to retrieve. Avoid the temptation to check the size of results against the limit to conclude the results have been completely returned. Instead, check the next_cursor value in the response_metadata object to make sure that it's empty, null, or non-existent.