slack-apimatic-sdk-sdk
v1.0.1
Published
Slack API SDK
Readme
Getting Started with Slack Web API
Introduction
One way to interact with the Slack platform is its HTTP RPC-based Web API, a collection of methods requiring OAuth 2.0-based user, bot, or workspace tokens blessed with related OAuth scopes.
Learn more about the Slack Web API: https://api.slack.com/web
Install the Package
Run the following command from your project directory to install the package from npm:
npm install [email protected]For additional package details, see the Npm page for the [email protected] npm.
Initialize the API Client
Note: Documentation for the client can be found here.
The following parameters are configurable for the API Client:
| Parameter | Type | Description |
| --- | --- | --- |
| environment | Environment | The API environment. Default: Environment.Production |
| timeout | number | Timeout for API calls.Default: 30000 |
| httpClientOptions | Partial<HttpClientOptions> | Stable configurable http client options. |
| unstableHttpClientOptions | any | Unstable configurable http client options. |
| logging | PartialLoggingOptions | Logging Configuration to enable logging |
| authorizationCodeAuthCredentials | AuthorizationCodeAuthCredentials | The credential object for authorizationCodeAuth |
The API client can be initialized as follows:
Code-Based Client Initialization
import {
Client,
Environment,
LogLevel,
OauthScope,
} from 'slack-apimatic-sdk-sdk';
const client = new Client({
authorizationCodeAuthCredentials: {
oauthClientId: 'OAuthClientId',
oauthClientSecret: 'OAuthClientSecret',
oauthRedirectUri: 'OAuthRedirectUri',
oauthScopes: [
OauthScope.Admin,
OauthScope.AdminAppsread
]
},
timeout: 30000,
environment: Environment.Production,
logging: {
logLevel: LogLevel.Info,
logRequest: {
logBody: true
},
logResponse: {
logHeaders: true
}
},
});Configuration-Based Client Initialization
import * as path from 'path';
import * as fs from 'fs';
import { Client } from 'slack-apimatic-sdk-sdk';
// Provide absolute path for the configuration file
const absolutePath = path.resolve('./config.json');
// Read the configuration file content
const fileContent = fs.readFileSync(absolutePath, 'utf-8');
// Initialize client from JSON configuration content
const client = Client.fromJsonConfig(fileContent);See the Configuration-Based Client Initialization section for details.
Environment-Based Client Initialization
import * as dotenv from 'dotenv';
import * as path from 'path';
import * as fs from 'fs';
import { Client } from 'slack-apimatic-sdk-sdk';
// Optional - Provide absolute path for the .env file
const absolutePath = path.resolve('./.env');
if (fs.existsSync(absolutePath)) {
// Load environment variables from .env file
dotenv.config({ path: absolutePath, override: true });
}
// Initialize client using environment variables
const client = Client.fromEnvironment(process.env);See the Environment-Based Client Initialization section for details.
Environments
The SDK can be configured to use a different environment for making API calls. Available environments are:
Fields
| Name | Description | | --- | --- | | Production | Default |
Authorization
This API uses the following authentication schemes.
List of APIs
- Admin Apps
- Admin Apps Approved
- Admin Apps Requests
- Admin Apps Restricted
- Admin Conversations
- Admin Conversations Ekm
- Admin Conversations Restrict Access
- Admin Emoji
- Admin Invite Requests
- Admin Invite Requests Approved
- Admin Invite Requests Denied
- Admin Teams Admins
- Admin Teams
- Admin Teams Owners
- Admin Teams Settings
- Admin Usergroups
- Admin Users
- Admin Users Session
- Api
- Apps Event Authorizations
- Apps Permissions
- Apps Permissions Resources
- Apps Permissions Scopes
- Apps Permissions Users
- Apps
- Auth
- Bots
- Calls
- Calls Participants
- Chat
- Chat Scheduled Messages
- Conversations
- Dialog
- Dnd
- Emoji
- Files Comments
- Files
- Files Remote
- Migration
- Oauth
- Oauth V 2
- Pins
- Reactions
- Reminders
- Rtm
- Search
- Stars
- Team
- Team Profile
- Usergroups
- Usergroups Users
- Users
- Users Profile
- Views
- Workflows
SDK Infrastructure
Configuration
- HttpClientOptions
- RetryConfiguration
- ProxySettings
- Configuration-Based Client Initialization
- Environment-Based Client Initialization
- PartialLoggingOptions
- PartialRequestLoggingOptions
- PartialResponseLoggingOptions
- LoggerInterface
