Skip to content

Instantly share code, notes, and snippets.

View nickcanfield29's full-sized avatar
💭
Looking for Data Science Jobs!

nickcanfield29

💭
Looking for Data Science Jobs!
View GitHub Profile
@bahoo
bahoo / export-users-from-slack-channel.py
Created February 2, 2017 21:28
Export users (first name, last name, email address) from a given Slack channel
import requests
SLACK_API_TOKEN = "xoxo-asdfghjkl..." # get one from https://api.slack.com/docs/oauth-test-tokens
CHANNEL_NAME = "general"
channel_list = requests.get('https://slack.com/api/channels.list?token=%s' % SLACK_API_TOKEN).json()['channels']
channel = filter(lambda c: c['name'] == CHANNEL_NAME, channel_list)[0]
channel_info = requests.get('https://slack.com/api/channels.info?token=%s&channel=%s' % (SLACK_API_TOKEN, channel['id'])).json()['channel']
members = channel_info['members']