dinarpay / bot-api-nodejs-client

Mixin API for JavaScript & Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bot-api-nodejs-client

The Node.js version of the mixin SDK https://developers.mixin.one/docs/api-overview

中文版

New version features

  1. More friendly type and code hints
  2. More standardized function naming
  3. More comprehensive test coverage

Install

npm install @mixin.dev/mixin-node-sdk

If you use yarn

yarn add @mixin.dev/mixin-node-sdk

Usage

  1. 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);
}
  1. 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);
  },
});

License

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.

About

Mixin API for JavaScript & Node.js

License:Apache License 2.0


Languages

Language:TypeScript 87.3%Language:JavaScript 12.7%