The Node.js version of the mixin SDK
- More friendly type and code hints
- More standardized function naming
- More comprehensive test coverage
npm install mixin-node-sdk
If you use yarn
yarn add mixin-node-sdk
- Use Mixin API
const { Client } = require('mixin-node-sdk');
const client = new Client({
client_id: '',
session_id: '',
pin_token: '',
private_key: '',
pin: '',
client_secret: '',
});
// Use Promise
client.userMe().then(console.log);
// use async await
async function getMe() {
const me = await client.userMe();
console.log(me);
}
- Receive Mixin Messenger messages
const { BlazeClient } = require('mixin-node-sdk');
const client = new BlazeClient(
{
client_id: '',
session_id: '',
pin_token: '',
private_key: '',
pin: '',
client_secret: '',
},
{ parse: true, syncAck: true },
);
client.loopBlaze({
onMessage(msg) {
console.log(msg);
},
onAckReceipt(msg) {
console.log('ack', msg);
},
});
BlazeClient directly inherits Client, so all Client methods BlazeClient can be called directly.
- If you are using the version of
[email protected]
, please see https://github.com/liuzemei/mixin-node-sdk/tree/v2
Acceptable PRs.
Copyright 2021 Mixin.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.