https://github.com/kevlened/talkjs-node
A Node.js wrapper for the talkjs rest api
https://github.com/kevlened/talkjs-node
api-client rest rest-client sdk talkjs
Last synced: 3 months ago
JSON representation
A Node.js wrapper for the talkjs rest api
- Host: GitHub
- URL: https://github.com/kevlened/talkjs-node
- Owner: kevlened
- License: mit
- Created: 2019-09-05T21:36:31.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-22T13:32:38.000Z (over 3 years ago)
- Last Synced: 2024-04-24T19:12:38.378Z (over 1 year ago)
- Topics: api-client, rest, rest-client, sdk, talkjs
- Language: TypeScript
- Size: 185 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# talkjs-node
A Node.js wrapper for the talkjs rest api## Install
This library is compatible with Node v10+
```
npm i talkjs-node# or
yarn add talkjs-node
```## Usage
```javascript
const {TalkJS} = require('talkjs-node');
// or
import {TalkJS} from 'talkjs-node';const client = new TalkJS({
appId: 'YOUR_APP_ID',
apiKey: 'YOUR_API_KEY'
});(async function main() {
// List all the users
for await (const user of client.users.list()) {
console.log(user.name);
}
})();
```A `oneOnOneId` generator [using the TalkJS recommendation](https://talkjs.com/docs/api/index.html#oneononeid) is included to generate a predictable conversation id for two participants.
```javascript
const {oneOnOneId} = require('talkjs-node');
// or
import {oneOnOneId} from 'talkjs-node';console.log(oneOnOneId('userId1', 'userId2'));
```## Methods
The methods match those provided by [the TalkJS REST api](https://talkjs.com/docs/Reference/REST_API/index.html).
* `oneOnOneId(userId1: string, userId2: string)`
* `client.import.conversations.messages({conversationId: string, messages: Array})`
* `client.users.create(userId: string, user: User)`
* `client.users.get(userId: string)`
* `client.users.update(userId: string, user: User)`
* `client.users.list({limit?: number, isOnline?: boolean, startingAfter?: string})`
* `client.users.sessions.list({userId: string})`
* `client.users.conversations.list({userId: string, limit?: number, startingAfter?: string, lastMessageAfter?: number, lastMessageBefore?: number, unreadsOnly?: boolean})`
* `client.conversations.create(conversationId: string, conversation: Conversation)`
* `client.conversations.get(conversationId: string)`
* `client.conversations.update(conversationId: string, conversation: Conversation)`
* `client.conversations.list({limit?: number, startingAfter?: string, lastMessageAfter?: number, lastMessageBefore?: number, filter?: Map})`
* `client.conversations.notifications.send(conversationId: string, notification: Notification)`
* `client.conversations.messages.send({conversationId: string, messages: Array})`
* `client.conversations.messages.get(conversationId: string, messageId: string)`
* `client.conversations.messages.update(conversationId: string)`
* `client.conversations.messages.list({conversationId: string})`
* `client.conversations.participants.add({conversationId: string, userId: string, details: Map})`
* `client.conversations.participants.update({conversationId: string, userId: string, details: Map})`
* `client.conversations.participants.remove({conversationId: string, userId: string})`## License
MIT