{"library":"slack-web-api-client","title":"Slack Web API Client","description":"The `slack-web-api-client` is a fetch-based, type-safe client library for interacting with the Slack Web API, designed for broad runtime compatibility across environments like Node.js, Deno, and Cloudflare Workers. Currently stable at version 1.1.11, it is part of the `slack-edge` ecosystem and is utilized internally by the `slack-edge` library itself. A key differentiator is its \"zero additional dependencies\" approach, minimizing install footprint and potential conflicts, which simplifies integration and reduces supply chain risks. It provides strong TypeScript types for all API responses and Block Kit elements, significantly enhancing the developer experience with predictive coding and robust error checking. The project appears to be actively maintained, with updates available via `npm i slack-web-api-client@latest`. Its fetch-based implementation makes it highly portable, a significant advantage over clients relying on Node.js-specific HTTP modules.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install slack-web-api-client"],"cli":null},"imports":["import { SlackAPIClient } from 'slack-web-api-client';","import { SlackAPIError } from 'slack-web-api-client';","import { WebClientOptions } from 'slack-web-api-client';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { SlackAPIClient } from \"slack-web-api-client\";\n\n// Ensure SLACK_BOT_TOKEN is set in your environment\nconst token = process.env.SLACK_BOT_TOKEN ?? '';\n\nconst client = new SlackAPIClient(token, {\n  // Log level can be set to 'DEBUG', 'INFO' (default), 'WARN', 'ERROR'\n  logLevel: \"INFO\", \n  // By default, the client throws SlackAPIError for API failures (ok: false)\n  throwSlackAPIError: true\n});\n\nasync function postGreeting() {\n  if (!token) {\n    console.error('SLACK_BOT_TOKEN environment variable is not set.');\n    return;\n  }\n  try {\n    const response = await client.chat.postMessage({\n      channel: \"#general\", // Replace with your desired channel ID or name\n      text: \":wave: Hello from slack-web-api-client!\",\n      blocks: [\n        {\n          \"type\": \"section\",\n          \"text\": {\n            \"type\": \"mrkdwn\",\n            \"text\": \"Hey there! I just posted this message using the `slack-web-api-client` library. :rocket:\"\n          }\n        },\n        {\n          \"type\": \"actions\",\n          \"elements\": [\n            {\n              \"type\": \"button\",\n              \"text\": {\n                \"type\": \"plain_text\",\n                \"text\": \"View GitHub\"\n              },\n              \"url\": \"https://github.com/slack-edge/slack-web-api-client\"\n            }\n          ]\n        }\n      ]\n    });\n    console.log('Message posted:', response.ts);\n  } catch (error) {\n    if (error instanceof SlackAPIClient) {\n      console.error('Slack API Error:', error.code, error.response);\n    } else {\n      console.error('An unexpected error occurred:', error);\n    }\n  }\n}\n\npostGreeting();","lang":"typescript","description":"This quickstart demonstrates how to instantiate the SlackAPIClient, configure it, and use it to post a message with Block Kit to a specified Slack channel, including basic error handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}