@knawat/mp
TypeScript icon, indicating that this package has built-in type declarations

1.7.6 • Public • Published

Knawat

Join the chat at Knawat Average time to resolve an issue Percentage of issues still open npm npm

Knawat Node.js NPM Package (MP)

Codacy Badge

A Node.js package for Knawat Dropshipping Merchants REST API. Easily interact with the Knawat MP REST API using this library.

Installation

npm install @knawat/mp --save

yarn add @knawat/mp

Getting started

Check out the Knawat Dropshipping MP REST API endpoints and data that can be manipulated in our documentations.

Setup

Setup for the new Knawat Dropshipping REST API integration:

const MP = require('@knawat/mp');

// Provide instance with your store credentials
const mp = new MP({
  key: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
  secret: 'XXXXXXXXXXXXXXXXXXXXXXXX',
});

// Provide instance with a generated access_token
const mp = new MP({
  access_token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
});

// Or use your store id/URL
// Supported using basic auth only
const mp = new MP({
  store: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
});

Options

Option Type Required Description
key string conditional Your Store's API consumer key if token not provided this field is required
secret string conditional Your Store's API consumer secret if token not provided this field is required
store string conditional Your store current store URL
apiRateLimit object optional Overwrite the API rate limit (not recommended)
SET_ASYNC string optional Overwrite the async setting for api call

Getting Access tokens

Library Methods

Products Functions

All the functions mentioned here return a promise and it's an async function.

What's mentioned between [brackets] are the authentication method used for the functions.

Example

mp.getProducts() // return a promise.

Note: the methods with the Dev tag is still underdevelopment.

REST Function

This function is used internally as a wrapper for the library. An Async function that requests Data from server.

Params Type Description
Method string HTTP Methods for RESTful Services (Get, Put, Post, Patch, Delete)
Path string WooCommerce API endpoint, example: catalog/products or orders/{order_id}
options Object options { SET_ASYNC, queryParams, auth, body, headers }
mp.$fetch(method, path, (options = {}));

Example:

mp.$fetch('GET', '/catalog/categories', { auth: 'token' }); // returns object : count and categories array

postman and bearer token.

If you want to test the API on the postman you can get the bearer token by using this following methods:

mp.getTokenAuth(); // Async function
mp.getTokenAuth().then(console.log);

After that you can use the available methods to test and see the results you got!.

Reporting Security Issues

To disclose a security issue to our team, please submit a report here.

Support & Chat

Developers are welcome here, please create issue or chat with us https://gitter.im/Knawat/Lobby. This repository is not suitable for Knawat customers support. Please don't use our issue tracker for support requests, but for Knawat Dropshipping NPM Package issues only. Support can take place through Knawat support portal which is available for free.

Support requests in issues on this repository will be closed on sight.

Contributing to Knawat

If you have a patch or have stumbled upon an issue with Knawat NPM Package, you can contribute this back to the code. Please create a pull request.

Check also

Package Sidebar

Install

npm i @knawat/mp

Weekly Downloads

60

Version

1.7.6

License

SEE LICENSE IN LICENSE

Unpacked Size

78.8 kB

Total Files

8

Last publish

Collaborators

  • hazemkhaled
  • abdelrahman3d
  • greetly