rotsiapi

1.1.2 • Public • Published

ROTSI API Node.js SDK

NPM

The wrapper provides convenient access to the ROTSI API from applications written for Node.js.

Install

You can install the package from npm by running:

$ npm i rotsiapi

Usage

The package needs to be configured with your app username and secret_key, which you can get from the dashboard.

// Import the npm package
const Rotsi = require('rotsiapi'); 

const username = 'xxxxxxxx';
const secretKey = 'xxxxxxxxxxxxxxxxxxxxxxx';

// Set additional options if needed
const credentials = {
    secretKey: username,
    username: secretKey,
};
const rotsiInstance = Rotsi(credentials);
const stkParams = {
    amount: 1,
    phone: '254711222333', 
};
rotsiInstance.STK.initiateSTK(stkParams)
    .then(response => {
        console.log('STK initiated successfully:', response);
    })
    .catch(error => {
        console.error('Error initiating STK: ', error.response ? error.response.data : error.message);
    });

Initialization

Initialize the SDK as a requirement by doing require('rotsiapi')(credentials). After initialization, you can get instances of offered services as follows:

Development

Run all tests:

$ npm install
$ npm test

or on Windows...

$ npm install
$ npm run test-windows

Issues

If you find a bug, please file an issue on our issue tracker on GitHub.

Package Sidebar

Install

npm i rotsiapi

Weekly Downloads

3

Version

1.1.2

License

MIT

Unpacked Size

46.7 kB

Total Files

26

Last publish

Collaborators

  • alvinwachira