Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dizys/lark-js-sdk

Third-party JavaScript Lark (Feishu, 飞书) SDK written in TypeScript
https://github.com/dizys/lark-js-sdk

client feishu javascript lark sdk typescript

Last synced: about 2 months ago
JSON representation

Third-party JavaScript Lark (Feishu, 飞书) SDK written in TypeScript

Awesome Lists containing this project

README

        

[![npm](https://img.shields.io/npm/v/lark-js-sdk?style=flat)](https://www.npmjs.com/package/lark-js-sdk)

# lark-js-sdk

Third-party JavaScript Lark (Feishu, 飞书) SDK written in TypeScript

## Installation

```bash
npm install --save lark-js-sdk
```

## Quick Start

Send message to groups that the bot is in:

```js
import {Lark} from 'lark-js-sdk';

async function sendMessage() {
let lark = new Lark('', '');

let {groups} = await lark.bot.group.getList();

let chatIds = groups.map(group => group.chat_id);

for (let chatId of chatIds) {
let {message_id} = await lark.message.send({
chat_id: chatId,
msg_type: 'text',
content: {text: 'Hello, Lark!'},
});

console.log(`Message (${message_id}) sent!`);
}
}

sendMessage();
```

Add user

```js
import {Lark} from 'lark-js-sdk';

let lark = new Lark('', '');

lark.contact.user
.add({
name: 'Dizy',
mobile: '18900000000',
department_ids: ['od-234355343342acdbef33'],
need_send_notification: true,
})
.then(data => {
let {user_info} = data;

console.log('User added:', user_info);
});
```

Use Feishu API Endpoint instead:

```js
import {Feishu, Lark} from 'lark-js-sdk';

let feishu = new Feishu('', '');

// or

let feishu = new Lark(
'',
'',
'https://open.feishu.cn/open-apis/',
);

// Feishu has the same apis as Lark...
```

## License

MIT, see the [LICENSE](/LICENSE) file for details.