sendbird-platform-sdk
v0.0.16
Published
Server side JavaScript SDK for Sendbirds Platform API
Downloads
2,062
Readme
Sendbird JavaScript Platform SDK
This is a Node.js package that makes talking to the Sendbird Platform API easier. With this library you can extend your Sendbird integration to include advanced features like channel automation and user management.
Install
npm install sendbird-platform-sdk
🔥 Quick start
import SendbirdPlatformSdk from 'sendbird-platform-sdk';
const userId = "1234";
const name = "bob";
const profileUrl = "https://picsum.photos/200";
const apiToken = "YOUR_API_TOKEN";
const appId = "YOUR_APP_ID";
const opts = {
'createUserData': new SendbirdPlatformSdk.CreateUserData(userId, name, profileUrl),
};
async function createUser() {
const userApiInstance = new SendbirdPlatformSdk.UserApi();
userApiInstance.apiClient.basePath = `https://api-${appId}.sendbird.com`;
try {
const data = await userApiInstance.createUser(apiToken, opts);
console.log(data);
} catch (e) {
console.log(e);
}
}
createUser();
⚒️ Prerequisite
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.
💻 Requirements
You will need Node.js installed. This has been developed and tested with NodeJS 17+.
🤓 Local Development
To run locally we need to make use of the npm link command. You will require two terminal tabs.
Please follow these steps:
Terminal 1
- Clone this repo to your machine
git clone [email protected]:sendbird/sendbird-platform-sdk
- Move into the newly cloned repo
cd sendbird-platform-sdk
- Install node modules
npm install
- Build the bundled JS
npm run build
- Link the package
npm link
Terminal 2
- Create a new npm package or move into and existing one
mkdir app-using-sendbird-chat
npm init -y
- Link package to sendbird-platform-sdk
npm link path/to/sdk/sendbird-platform-sdk
The linking step is demonstrated visually here.
🗃️ Documentation
All the documentation for this project lives in the /docs directory of this repo.
Helpful links
| | Documentation | | ----------- | ----------- | | Announcement | docs/AnnouncementApi.md| | Application | docs/ApplicationApi.md | | Bot | docs/BotApi.md | | GroupChannel | docs/GroupChannelApi.md | | Message | docs/MessageApi.md | | OpenChannel | docs/OpenChannelApi.md | | User | docs/UserApi.md | | Webhooks | docs/WebhooksApi.md |