swagchat-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.11.0 • Public • Published

MIT License npm version

swagchat SDK(TypeScript & JavaScript)

swagchat is an open source chat components for your webapps.

This is SDK for Chat API

Architecture

Architecture

Related repositories

Installation

CDN

<script src="https://unpkg.com/swagchat-sdk/dist/swagchat-sdk.min.js"></script>

npm

npm install --save swagchat-sdk

Please use TypeScript for development, but you do not need to install @types/swagchat-sdk.

Type definitions are included in this repository.

Usage

Browser

<script src="https://unpkg.com/swagchat-sdk/dist/swagchat-sdk.min.js"></script>
<script >
// Initialize client.
var sc = new SwagChat.Client({
  apiKey: "API_KEY",
  apiSecret: "API_SECRET",
  apiEndpoint: "http://localhost:9000/v0",
  realtime: {
    endpoint: "ws://localhost:9100/v0"
  }
});

// Create user.
sc.createUser({
  name: "USER_NAME",
}).then(function(res) {
  if (res.error) {
    console.log(res.error);
  } else {
    console.log(res.user);
  }
})
</script>

Node

import { Client } from "swagchat-sdk";

// Initialize client.
const sc = new Client({
  apiKey: "API_KEY",
  apiSecret: "API_SECRET",
  apiEndpoint: "http://localhost:9000/v0",
  realtime: {
    endpoint: "ws://localhost:9100/v0"
  }
});

// Create user.
sc.createUser({
  name: "USER_NAME",
}).then(function(res) {
  if (res.error) {
    console.log(res.error);
  } else {
    console.log(res.user);
  }
})

Document

Open doc/index.html in browser.

Generated using TypeDoc

License

MIT License.

Package Sidebar

Install

npm i swagchat-sdk

Weekly Downloads

0

Version

0.11.0

License

MIT

Last publish

Collaborators

  • betchi