Skip to content

Instantly share code, notes, and snippets.

@one-data-cookie
Last active December 4, 2020 13:11
Show Gist options
  • Save one-data-cookie/e419d680755e2e64945085090488f735 to your computer and use it in GitHub Desktop.
Save one-data-cookie/e419d680755e2e64945085090488f735 to your computer and use it in GitHub Desktop.
import requests as rq
import pandas as pd
channel_url = 'https://slack.com/api/conversations.list'
channel_headers = {'content-type': 'application/x-www-form-urlencoded'}
channel_params = {
'token': 'xoxp-XXXXXXXXXXXX-XXXXXXXXXXXX-XXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'limit': 1000,
'exclude_archived': True
}
channel_res = rq.get(url=channel_url, headers=channel_headers, params=channel_params)
channel_data = []
for i in channel_res.json()['channels']:
channel_data.append({
'id': i['id'],
'name': i['name'],
'created': i['created'],
'members': i['num_members'],
'is_group': i['is_group']
})
channel_df = pd.DataFrame(channel_data).sort_values('members', ascending=False)
print(channel_df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment