JSPM

  • Created
  • Published
  • Downloads 74364
  • Score
    100M100P100Q50171F
  • License Apache-2.0

Slack API client writ in JS

Package Exports

  • slack
  • slack/methods/_exec-browser.js
  • slack/methods/_exec.js
  • slack/methods/chat.postMessage

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (slack) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Slack Web bitHound Code bitHound Dependencies Codeship Status for smallwins/slack

slack is a SUPER low level building block web api client written in es2015 JavaScript.

  • Pure functions (no stateful things like classes, or using new)
  • Perfect symmetry (method sigs match api docs, method sigs are node style)
  • Opt in (selectivly use the parts of the api surface you want w/o the entire payload)
  • Works in Node and the browser (per above)
  • Future friendly 1/2 published to npm as es5
  • Future friendly 2/2 no in-progress es* features, avoid polyfills and runtime
  • Heavily tested, CI and Apache2 licensed

install

npm i slack

usage

This module works in es5 environments by default. It is tested for Node and the browser.

var slack = require('slack')

// logs {args:{hello:'world'}}
slack.api.test({hello:'word'}, console.log)

Usage with es2015 works well too. This module itself is writen using Babel. Also nice, you can specify only the methods you need which can be nice to trim the payload if you using slack in a web browser.

import test from 'slack/methods/api.test'

// logs {args:{hyper:'card'}}
test({hyper:'card'}, console.log)

test setup

Clone this repo and create a file called .env in the root with the following:

SLACK_TOKEN=xxxx
SLACK_CLIENT_ID=xxxx
SLACK_CLIENT_SECRET=xxxx

You can get a SLACK_TOKEN for testing here. You need to register an app for a SLACK_CLIENT_ID and SLACK_CLIENT_SECRET.

run the tests

Test in Node:

npm test

Or a browser:

npm run btest

Or kick up a repl:

currently implemented api

(If the method signature below is not syntax highlighted then it needs parameter validation and tests. See the channels.history for a good example of how to do this if you want to contibute. Of course, all contributions are super ppreciated! There are many ways this library can be improved.

  • api.test(params, (err, data)=>)
  • auth.test(token, (err, data)=>)
  • channels.archive
  • channels.create
  • channels.history({token, channel}, (err, data)=>)
  • channels.info
  • channels.invite
  • channels.join
  • channels.kick
  • channels.leave
  • channels.list({token, exclude_archived}, (err, data)=>)
  • channels.mark
  • channels.rename
  • channels.setPurpose
  • channels.setTopic
  • channels.unarchive
  • chat.delete
  • chat.postMessage({token, text, channel}, (err, data)=>)
  • chat.update
  • emoji.list
  • files.delete
  • files.info
  • files.list
  • files.upload
  • groups.archive
  • groups.close
  • groups.create
  • groups.createChild
  • groups.history
  • groups.info
  • groups.invite
  • groups.kick
  • groups.leave
  • groups.list
  • groups.mark
  • groups.open
  • groups.rename
  • groups.setPurpose
  • groups.setTopic
  • groups.unarchive
  • im.close
  • im.history
  • im.list
  • im.mark
  • im.open
  • oauth.access({client_id, client_secret, code}, (err, data)=>)
  • reactions.add
  • reactions.get
  • reactions.list
  • reactions.remove
  • rtm.start({token}, (err, data)=>)
  • search.all
  • search.files
  • search.messages
  • stars.list
  • team.accessLogs
  • team.info(token, (err, data)=>)
  • team.info
  • users.getPresence
  • users.info
  • users.list(token, (err, data)=>)
  • users.setActive
  • users.setPresence