A Node.js package for Knawat Suppliers REST API. Easily interact with the Knawat Suppliers REST API using this library.
npm install --save @knawat/suppliers
Check out the Knawat Suppliers REST API endpoints and data that can be manipulated in https://knawat-suppliers.restlet.io/.
Setup for the new Knawat Suppliers REST API integration:
// define environment to deploy on production. default is devlopment
process.env.KNAWAT_ENV = 'production'
const { Suppliers, Products } = require('@knawat/suppliers');
const sa = new Products({
key: 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
secret: 'XXXXXXXXXXXXXXXXXXXXXXXX',
});
Option | Type | Required | Description |
---|---|---|---|
key |
string |
conditional | Your Store's API consumer key. this field is required |
secret |
string |
conditional | Your Store's API consumer secret. this field is required |
https://knawat-suppliers.restlet.io/#operation_get_token
/*
* Set Environment variables for Suppliers methods
* BASIC_USER : XXXXXXXXXX
* BASIC_PASS : XXXXXXXXXX
*/
const { Suppliers, Products, WeightRules } = require('@knawat/suppliers');
const suppliers = new Suppliers();
const weightRules = new WeightRules();
Retrieve the list of all products or products for this channel, sorted by create date DESC
const filter = {
limit : 20,
page : 2,
qualified : null,
category_id : null,
keyword : null,
stock : null,
price : null,
sort_by : null,
sort_asc : null,
language : "en"
}
sa.getProducts(filter);
Params | Type | Required | Description |
---|---|---|---|
limit |
Number |
No | Number of products to retrieve. Default: 10 |
page |
Number |
No | Number of the page to retrieve. Default: 1 |
qualified |
Number |
No | Number = 1: Qualified, 2: Needs to review, 4: Disqualified, 5 : Draft Default: null |
category_id |
String |
No | String of category_id, Default: null |
if category_id = -1, get all un-categories products | |||
keyword |
String |
No | Text to search in product SKU or name Default: null |
stock |
Object |
No | stock : { stock_from: Number,stock_to: Number } Default: null |
price |
Object |
No | price : { price_from: Number, price_to: Number } Default: null |
sort_by |
String |
No | allowed fields :name, stock, qualified, price, stock Default: null |
sort_asc |
String |
No | sort_asc: 1 = acs, -1 = desc Default: -1 |
language |
String |
No | tr, en, ar Default: tr |
https://knawat-suppliers.restlet.io/#operation_get_list_of_products
Add products to my list
sa.addProducts(products);
Option | Type | Required | Description |
---|---|---|---|
products |
array |
yes | Array of Products Object [{ sku: '1234' }] |
https://knawat-suppliers.restlet.io/#operation_add_to_my_products
Retrieve single product information by Product SKU. product should be under this store
sa.getProductBySku(sku);
Params | Type | Description |
---|---|---|
sku |
string |
SKU of Product you want to get |
https://knawat-suppliers.restlet.io/#operation_get_product_by_sku
Retrieve products information using bulk update. product should be under this store
sa.updateBulkProduct(data);
Params | Type | Description |
---|---|---|
data |
object |
```JSON |
{"products":[{"sku":"4646030019238","barcode":"1234567890","url":"https://example.com/product.php?id=123","name":{"tr":"DAR KALIP PEMBE GÖMLEK","en":"Slimline Pink Shirt"},"description":{"tr":"Some Turkish text here, html allowed","en":"Some English text here, html allowed"},"brand":{"tr":"Defacto","en":"Defacto"},"images":["https://cdnp4.knawat.com/buyuk/788f8a17-d5d8-4ccb-b218-9e428b199228.jpg"],"attributes":[{"name":{"tr":"Beden","en":"Size"},"options":[{"tr":"S","en":"S"},{"tr":"M","en":"M"}]}],"variations":[{"sku":"4646030019238-S","barcode":"1234567890123","sale_price":9.74,"market_price":11.99,"weight":0.5,"quantity":123,"attributes":[{"name":{"tr":"Beden","en":"Size"},"option":{"tr":"S","en":"S"}}]}]}]}
https://knawat-suppliers.restlet.io/#operation_update_product
Update imported product External IDs by SKU
sa.updateProductBySku(products);
Option | Type | Required | Description |
---|---|---|---|
data |
object |
yes | Check mp documentation |
https://knawat-suppliers.restlet.io/#operation_update_product
Get all categories.
sa.getCategories();
https://knawat-suppliers.restlet.io/#operation_get_list_of_categories
sa.getOrders(limit, page);
Params | Type | Description |
---|---|---|
limit |
Number |
Number of orders to retrieve. Default: 1 |
page |
Number |
Number of the page to retrieve. Default: 1 |
https://knawat-suppliers.restlet.io/#operation_get_order_s_
sa.getOrderById(order_id);
Params | Type | Description |
---|---|---|
order_id |
string |
Knawat Order ID |
https://knawat-suppliers.restlet.io/#operation_order_by_id
sa.createOrder(order_data);
Params | Type | Description |
---|---|---|
order_data |
object |
Array of Order Data for create order |
https://knawat-suppliers.restlet.io/#operation_create_order
sa.updateOrder(order_id, order_data);
Params | Type | Description |
---|---|---|
order_id |
string |
Knawat Order ID |
order_data |
object |
Array of Updated Order Data for create order |
https://knawat-suppliers.restlet.io/#operation_update_order
suppliers.getSuppliers();
https://knawat-suppliers.restlet.io/#operation_get_all_suppliers
suppliers.createSupplier(supplier);
Params | Type | Description |
---|---|---|
supplier |
object |
Object of supplier |
https://knawat-suppliers.restlet.io/#operation_create_a_supplier
suppliers.getSupplierKeys(supplier_id);
Params | Type | Description |
---|---|---|
supplier_id |
string |
Id of supplier |
https://knawat-suppliers.restlet.io/#operation_get_suppliers_keys
sa.updateSupplier(supplier);
Params | Type | Description |
---|---|---|
supplier |
object |
Object of supplier |
{"supplier": { "name" : "john", "url": "https://example.com.tr","logo": "https://example.com.tr/logo.png","currency": "TRY", "address": [array of addresses], "contacts": [array of contacts] } }
https://knawat-suppliers.restlet.io/#operation_update_a_supplier_2
weightRules.getWeightRules();
Params | Type | Description |
---|---|---|
limit |
number |
limit of data in response |
page |
number |
page number |
sort |
number |
sort data in response |
https://knawat-suppliers.restlet.io/#operation_get_all_weight_rules
weightRules.createWeightRule(weightRules);
Params | Type | Description |
---|---|---|
weightRules |
object |
Object of weightRules |
"weightRules": { "keyword" : "Shirt", "weight": 5 }
https://knawat-suppliers.restlet.io/#operation_create_a_supplier
weightRules.updateWeightRule(id, weightRules);
Params | Type | Description |
---|---|---|
id |
string |
Id of weight rule |
weightRules |
object |
Object of parameters to update |
"weightRules": { "keyword" : "Shirt", "weight": 5 }
https://knawat-suppliers.restlet.io/#operation_update_weight_rule
weightRules.deleteWeightRule(id);
Params | Type | Description |
---|---|---|
id |
string |
Id of weight rule |
https://knawat-suppliers.restlet.io/#operation_delete_weight_rule
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 Suppliers 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.