A Node.js package for Knawat Dropshipping Merchants REST API. Easily interact with the Knawat MP REST API using this library.
npm install @knawat/mp --save
yarn add @kanwat/mp
Check out the Knawat Dropshipping MP REST API endpoints and data that can be manipulated in our documentations.
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',
});
// Or use your store id/URL
// Supported using basic auth only
const mp = new MP({
store: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
});
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) |
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)
Note: the methods with the Dev tag is still underdevelopment.
This function is used internally as a warpper 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 { queryParams, auth, body, headers } |
mp.$fetch(method, path,options={});
Example:
mp.$fetch('GET', '/catalog/categories', { auth: 'token' }); // returns object : count and categories array
If you want to test the API on the postman you can get the bearer token by using this following mettohds:
mp.getTokenAuth() // Async function
mp.getToeknAuth().then(console.log)
After that you can use the available methods to test and see the results you got!.
To disclose a security issue to our team, please submit a report here.
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.
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.