🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@slack/web-api

Package Overview
Dependencies
Maintainers
10
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slack/web-api

Official library for using the Slack Platform's Web API

7.9.1
latest
Source
npm
Version published
Weekly downloads
2.7M
12.7%
Maintainers
10
Weekly downloads
 
Created

What is @slack/web-api?

The @slack/web-api npm package is a JavaScript client for Slack's Web API. It provides an easy-to-use interface for interacting with various Slack API methods, allowing developers to integrate their applications with Slack services. With this package, developers can send messages, manage channels, handle users, and more, all within their Node.js applications.

What are @slack/web-api's main functionalities?

Sending Messages

This feature allows you to send messages to channels or users in Slack. The code sample demonstrates how to use the `chat.postMessage` method to send a 'Hello world!' message to a specified channel.

const { WebClient } = require('@slack/web-api');
const web = new WebClient(process.env.SLACK_TOKEN);

async function sendMessage(channel, message) {
  try {
    const result = await web.chat.postMessage({
      channel: channel,
      text: message
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

sendMessage('C1234567890', 'Hello world!');

Managing Channels

This feature enables the creation, modification, and management of channels. The code sample shows how to create a new channel using the `conversations.create` method.

const { WebClient } = require('@slack/web-api');
const web = new WebClient(process.env.SLACK_TOKEN);

async function createChannel(name) {
  try {
    const result = await web.conversations.create({
      name: name
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

createChannel('new-channel');

Handling Users

This feature deals with user information and actions, such as listing users, getting user info, and updating user profiles. The code sample illustrates how to list all users in a Slack workspace using the `users.list` method.

const { WebClient } = require('@slack/web-api');
const web = new WebClient(process.env.SLACK_TOKEN);

async function listUsers() {
  try {
    const result = await web.users.list();
    console.log(result.members);
  } catch (error) {
    console.error(error);
  }
}

listUsers();

Other packages similar to @slack/web-api

Keywords

slack

FAQs

Package last updated on 26 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts