Skip to content

Instantly share code, notes, and snippets.

@figaw
Created September 30, 2019 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save figaw/cb12691bcc4d7cbe18f4ee7547934b54 to your computer and use it in GitHub Desktop.
Save figaw/cb12691bcc4d7cbe18f4ee7547934b54 to your computer and use it in GitHub Desktop.
An example of using the Slack Api

Slack API Example: How to get a list of channels.

Create a new app

  1. Go to https://api.slack.com/
  2. Click "Start Building"
  3. Create a new app

Figure out needed permissions

As a reference: conversations.list can be used with the permission channels:read.

Give your App permissions

  1. Go to Features -> OAuth & Permissions
  2. Navigate to Scopes add the permission, e.g. channels:read

Authenticate your app, (Install it into your workspace)

  1. Go to Settings -> Install App

Get the OAuth Access Token

  1. Go to Settings -> Install App
  2. Copy the token xo......202

Use the token in the Tester for the call

  1. Go to your needed call, e.g. conversations.list
  2. Choose "Tester"
  3. Paste token
  4. (Optionally) Increase limit
  5. Choose "Test Method"

Analyze output

  1. Save the output to a dump.json file

  2. Run it through jq to get desired information

    cat dump.json | jq .channels[].name > res.txt

    output json object has an entry channels. channels is a list. Each object in the list has an entry name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment