npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

slack-api

v0.1.14

Published

A javascript API wrapper for Slack.

Downloads

285

Readme

slack-api

A javascript wrapper for the Slack API.

Installation

Installation is easy, like any package on npm, you can add it to your project by typing the following in the terminal in your project directory:

npm install --save slack-api

Usage

slack-api uses the same structure as the Slack Web API, and follows Node convention for calling methods.

'use strict';

var Slack = require('slack-api');

Slack.api.test({}, function (error, data) {
  console.log(data);
});

API

slack-api shares the same methods as the Slack Web API, but with a few additions.

You can find the full Slack Web API documentation on their site.

If slack-api is missing a method let us know, or better yet, update it.

oauth.getUrl(options, [callback=noop])

This method generates the url used for step 1 of the Slack OAuth flow.

Arguments

  1. options (Object) - options hash should have the following properties:
client_id    - issued when you created your application (required)
redirect_uri - URL to redirect back to (see below) (optional)
scope        - permissions to request (see below) (optional)
state        - unique string to be passed back upon completion
team         - Slack team ID to restrict to (optional)
  1. [callback=noop] (Function) - Function to be called upon completion. If none is provided, this method will simply execute silently.

Returns

This method invokes the callback argument function in the standard node.js style (callback(error, data)), where data is the url (String) that the user should be redirected to to start the OAuth process for slack.

oauth.access(options, [state], [callback=noop])

This method allows you to exchange a temporary OAuth code for an API access token. This is used as part of the OAuth authentication flow.

This method will optionally perform the state check for you, should you provide it.

Arguments

  1. options (Object) - options hash should have the following properties:
client_id     - issued when you created your application (required)
client_secret	- issued when you created your application (required)
code	        - the code param returned via the OAuth callback (required)
redirect_uri	- this must match the originally submitted URI (if one was sent)
  1. [state] (String) - unique string passed to the original authorization call (optional)
  2. [callback=noop] (Function) - Function to be called upon completion. If none is provided, this method will simply execute silently.

Returns

This method invokes the callback argument function in the standard node.js style (callback(error, data)).

promisify()

This method returns a promisified version of the Slack API library.

'use strict';

var Slack = require('slack-api').promisify();

Slack.api.test({}).then(function (data) {
  console.log(data);
}).catch(Slack.errors.SlackError, function (error) {
  console.log('Slack did not like what you did: ' + error.message);
}).catch(Slack.errors.CommunicationError, function (error) {
  console.error('Error communicating with Slack. ' + error.message);
}).catch(Slack.errors.SlackServiceError, function (error) {
  console.error('Error communicating with Slack. ' + error.message);
  //To get error details
  console.error(error.errorDetails);
});

Errors

The slack-api comes with some custom errors, and their constructors are included under the errors property.

  • CommunicationError - This error is thrown if the https request fails e.g. because of a network problem.
  • SlackError - If Slack returns an error, this error will be passed to the callback function as the first argument for error-handling.
  • SlackServiceError - If Slack returns a non-200 status code, this error will be passed to the callback function as the first argument for error-handling. The error details are provided as a property on the error called errorDetails. SlackServiceError is different from SlackError because the Slack API returns a 200 status code for the kinds of errors identified by SlackError.

Development and testing

If you want to contribute, simply clone this repo, and run

npm install

Tests are written for mocha, and can be run with

npm test