Home

Awesome

SWUbanner

NPM version NPM download GitHub issues GitHub license

Mi Band 2 JS library

A clean implementation of Mi Band 2 library for Browsers and Node.js, using WebBluetooth API. demo

Setting up

It's best to unbind your Mi Band 2 from MiFit App first.
You should be able to bind it back again, but no guaranee here ;)

Browser

LIVE DEMO

You need a browser with WebBluetooth support. Tested with:

Node.js

npm install miband -g
miband-test

This should work on Windows, Linux and OSX.
On Linux, you need to grant Bluetooth access for Node.js:

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

Features

API usage example

const MiBand = require('miband');

const device = await bluetooth.requestDevice({
  filters: [
    { services: [ MiBand.advertisementService ] }
  ],
  optionalServices: MiBand.optionalServices
});

const server = await device.gatt.connect();

let miband = new MiBand(server);
await miband.init();

log('Notifications demo...')
await miband.showNotification('message');

Here you can find more API examples


Contributing

Please check out DEVELOPMENT.md