The Node.js version of the mixin SDK https://developers.mixin.one/docs/api-overview
- More friendly type and code hints
- More standardized function naming
- More comprehensive test coverage
npm install @mixin.dev/mixin-node-sdk
If you use yarn
yarn add @mixin.dev/mixin-node-sdk
- Use Mixin API
const { MixinApi } = require('@mixin.dev/mixin-node-sdk');
const keystore = {
user_id: '',
private_key: '',
session_id: '',
pin: '',
pin_token: '',
client_secret: '',
};
const client = MixinApi({ keystore });
// Use Promise
client.user.profile().then(console.log);
// Use async await
async function getMe() {
const me = await client.user.profile();
console.log(me);
}
- Receive Mixin Messenger messages
const { MixinApi } = require('@mixin.dev/mixin-node-sdk');
const keystore = {
user_id: '',
private_key: '',
session_id: '',
pin: '',
pin_token: '',
client_secret: '',
};
const config = {
keystore,
blazeOptions: {
parse: true,
syncAck: true,
},
};
const client = MixinApi(config);
client.blaze.loop({
onMessage(msg) {
console.log(msg);
},
});
Copyright 2022 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.