This is a Node.js package written in Typescript that makes talking to the Sendbird Platform API easier. With this library you can extend your Sendbird integration to include advanced features like message-, and channel automation, user management, create user authentication tokens, and create bots.
import {
createConfiguration,
ServerConfiguration,
UserApi,
UserApiCreateAUserRequest,
UserApiListUsersRequest,
} from "sendbird-platform-sdk-typescript";
const APP_ID = "YOUR_APP_ID_FROM_DASHBOARD";
const API_TOKEN = "YOUR_MASTER_API_TOKEN_FROM_DASHBOARD";
const serverConfig = new ServerConfiguration(
`https://api-${APP_ID}.sendbird.com`,
{ app_id: APP_ID }
);
const configuration = createConfiguration({
baseServer: serverConfig,
});
const userApi = new UserApi(configuration);
const listUsersParams: UserApiListUsersRequest = {
limit: 10,
apiToken: API_TOKEN,
};
const users = await userApi.listUsers(listUsersParams);
console.log("Listing first 10 users:\n", users);
const createUserParams: UserApiCreateAUserRequest = {
createAUserRequest: {
userId: "bob_smith",
nickname: "Bob",
profileUrl: "https://cataas.com/c",
},
apiToken: API_TOKEN,
};
const user = await userApi.createAUser(createUserParams);
console.log("User created:\n", user);
- This library is intended for server to server requests. Do not use in a browser environment. This SDK uses the Master API Token, which must never be exposed in public environments such as web pages or apps.
In order to make requests with this SDK you will need you master API token. This can be found through the Sendbird dashboard. Each app you create in Sendbird has its own master api token. These tokens can be found in Settings > Application > General.
You will need Node.js installed. This has been developed and tested with NodeJS 17+.
You can install the SDK directly from npm:
# Using npm
npm install sendbird-platform-sdk-typescript
# Using yarn
yarn add sendbird-platform-sdk-typescript
⚠️ This SDK is intended for the server-side environment only. Do not use this in browsers or frontend applications.
- Clone the repository
- cd to the
sendbird-platform-sdk-typescript
directory - run
npm install
- cd to your project directory
- run
npm install /path/to/sendbird-platform-sdk-typescript --save
All the documentation for this project lives in the root directory of this repo.
Documentation | |
---|---|
Announcement | AnnouncementApi.md |
Bot | BotApi.md |
GroupChannel | GroupChannelApi.md |
Message | MessageApi.md |
OpenChannel | OpenChannelApi.md |
User | UserApi.md |