@knawat/mp
v1.7.6
Published
A Node.js package for the Knawat Dropshipping MP REST API
Downloads
649
Readme
Knawat Node.js NPM Package (MP)
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 |
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.
- My Products
- Orders
- Invoices
- Categories
- getAllCategories()
- getCategories([params])
- Payments
- addPayment(storeId, payment)
[Basic]
- listPayments([params])
- addPayment(storeId, payment)
- Logs
[Basic]
- getStoreLogs([params])
- createStoreLogs(log)
[Basic|Bearer]
- Products
[Basic]
- getProductsByVariationSku(sku)
- getProductBySku(sku[, params])
- Stores
[Basic]
- listStores([params])
- createStore(store)
- updateStore(id, store)
- getStoreByURL(storeId[, params])
- getStoresByUser(userEmail[, limit])
- Shipping
[Basic]
- getShippingRules(country, weight, price)
- getShippingCouriers()
- getAllShipmentPolicies()
- createShipmentPolicy(shipment)
- getShipmentPolicyById(id)
- updateShipmentPolicy(id, shipment)
- Subscriptions
[Basic]
- listSubscriptions([params])
- addSubscription(subscription)
- cancelSubscription(id)
- updateSubscription(id, subscription)
- Memberships
[Basic]
- listMemberships()
- getMembershipById(id[, params])
- createMembership(membership)
- updateMembership(id, membership)
- Coupons
[Basic]
- listCoupons([params])
- getCoupon(id[, params])
- createCoupon(coupon)
- updateCoupon(id coupon)
- Taxes
[Basic]
- getTaxRecords([params])
- createTaxRecord(tax)
- updateTaxRecord(id, tax)
- getTaxById(id)
- deleteTaxRecord(id)
- (Dev)Zones
[Basic]
- listZones()
- getZoneByID(id)
- getZoneByDomain(domain)
- updateZoneByID(id,[params])
- createZone(zone)
- paymentGateway
[Basic]
- createCustomer(gateway)
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.