consume-lazada-open-platform-get-api
v1.0.2
Published
Consume Lazada Open Platform's API ( get data from lazada ) by generating needed url with valid signature
Downloads
6
Maintainers
Readme
consume-lazada-open-platform-api-nodeJs
Consume Lazada Open Platform's GET method API's ( get data from lazada ) by generating needed url with valid signature.
With this package we can call any Lazada Open Platform's Restful GET method API for any Region by generating valid signature.
Here you just need to populate two object's along with credentails as input as given in official document https://open.lazada.com/doc/api.htm
- commonParamsObj - Common Parameters key/value pair
- requestParamsObj - Request Parameters key/value pair
To store the credentails i am using the 'config' package (https://www.npmjs.com/package/config) create a a file in a folder "config" as "default.json" and add the credentails as
{
"appKey": "[YOUR APP KEY]",
"accessToken": "[YOUR ACCESS TOKEN]",
"appSecret": "[YOUR SERVER SECRET KEY]"
}
Example:
const appKey = config.get('appKey');
const accessToken = config.get('accessToken');
const appSecret = config.get('appSecret');
const apiPath = '/order/get'; // Order API - GetOrder
const endPoint = 'https://api.lazada.co.th/rest'; // for Thailand Region
const commonParamsObj = {};
commonParamsObj.app_key = appKey;
commonParamsObj.access_token = accessToken;
commonParamsObj.timestamp = Date.now();
commonParamsObj.sign_method = 'sha256';
commonParamsObj.sign = '';
const requestParamsObj = {};
requestParamsObj.order_id = '[your order ID OR demo order id]';
Please check the example.js file for reference
modification in example.js file
- npm i consume-lazada-open-platform-get-api
- npm i config
- create a a file in a folder "config" as "default.json" and add the credentails as { "appKey": "[YOUR APP KEY]", "accessToken": "[YOUR ACCESS TOKEN]", "appSecret": "[YOUR SERVER SECRET KEY]" }
- copy example.js file in your root folder
- update the apiPath/endPoint/order_id values corrospondingly as per your server configuration
- change following line const lazada = require('./lazadaGetData'); with const lazada = require('consume-lazada-open-platform-get-api');
- run node example.js