npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xlanor/mercury

v0.1.3

Published

A wrapper for the open lazada API

Downloads

7

Readme

mercury

A NodeJS wrapper for the open lazada API.

Still a WIP. Not all endpoints will be covered. Please feel free to contribute

License

AGPL v3.

I've been seeing a few clones of this repo, I suspect it's from ecommerce companies integrating with the new lazada API before the hard deadline of 31st May (Because it's such a good idea to give a 2 months deadline and spend 1 month of that time waiting for paperwork and approval.), so I want to make this explictly clear.

This software is licensed under the GNU Affero General Public License v3.

Please read the licensing file for terms and conditions, but for a tl;dr,

If you use the software as is in your application, no problem.

If you make ANY changes to it, you MUST make avaliable the source code of the MODIFIED version of this project.

It'd be nice if you can submit it as a PR so that we can all benefit together.

I wrote this SDK adaptation and the subsequent wrappers around the various API Calls without even knowing nodeJS, relying entirely on my knowledge of front-end jquery and basic JS, so this might not be the most optimal way to do it, and I'd really appreciate experienced nodeJS developers who can steer this on the right track, since lazada doesn't seem to have released a node SDK.

API Calls

.validateSeller, calls /auth/token/create, 'GET'

validateSeller(appkey,secretkey,access_code).then((success)=>{
	console.log("SUCCESS!");
	console.log(success);
}).catch((error)=>{
	console.log("ERROR CAUGHT");
	console.log(error);
});

.getOrderItems, calls /order/items/get, 'GET'

getOrderItems(country,app_key,secret_key,access_key,param).then((success)=>{
	console.log((success));
}).catch((error)=>{
	console.log(error);

.getOrders, calls /orders/get, 'GET'

// first, define the params and populate w/ whatever you want.
var params = new Object();
param['created_after'] = '2018-03-22T12:27:44+08:00';
param['status'] = 'pending';
param['offset'] = 0; 
param['limit'] = 100;

getOrders(country,access_key,app_key,secret_key,params).then((success)=>{
	console.log((success));
}).catch((error)=>{
	console.log(error);

.updatePriceQuantity, calls /product/price_quantity/update, 'POST

	var array_of_json_object =[Object({
			SellerSku:"7YOONA95",
			// price must be a float.
			Quantity:"89999999",
			Price:"100000000"
		})];
	methods.updatePriceQuantity(country,access_key,app_key,secret_key,array_of_json_object).then((success)=>{
		console.log(success);
	}).catch((error)=>{
		console.log(error);
	});

Some Custom API Calls.

.getAllOrders, a recursive function for .getOrders, 'GET'

// first, define the params and populate w/ whatever you want.
var params = new Object();
param['created_after'] = '2018-03-22T12:27:44+08:00';
param['status'] = 'pending';
param['offset'] = 0; // the offset for this function will be incremeneted for each recursion loop until count reaches 0
param['limit'] = 100;

getAllOrders(country,access_key,app_key,secret_key,params,[]).then((success)=>{
	console.log((success));
}).catch((error)=>{
	console.log(error);

Some Samples

Getting Orders With Items

function getNewOrdersWithItems(){
    // populates your parameters
    var param = new Object();
    param['created_after'] = '2018-03-22T12:27:44+08:00';
    param['status'] = 'pending';
    param['offset'] = 0;
    param['limit'] = 100;

    getAllOrders('sg',access_key,app_key,secret_key,param,[]).then((success)=>{
      return success;
    }).then((list_of_orders)=>{
      // list_of_orders is the list of all orders based on parameters.
      // recursion handles offsets.
      var promise_arr = [];
      // we utilize Promise.all to execute multiple calls simultaneously to getOrderItems
      for(var i=0; i < list_of_orders.length; i++){
        var order_item_params = new Object();
        order_item_params['order_id'] = list_of_orders[i]['order_id'];
        promise_arr.push(getOrderItems('sg',app_key,secret_key,access_key,order_item_params));	
      }
      return handleChainedPromise(promise_arr,list_of_orders);
    }).then((list_of_items_and_orders)=>{
      // we merge the items and orders
      return mergeOrderList(list_of_items_and_orders);
    }).then((mergedOrderList)=>{
      // now we have the orders with items
      console.log(mergedOrderList);
    }).catch((error)=>{
      console.log(error);
    });
}