Top 10 Python Libraries for E-commerce

5/5 - (1 vote)
Top 10 Python Libraries for E-commerce

In this article, we explore 10 Python libraries, platforms, tools, and frameworks that are useful for e-commerce. Criteria for the list included their relevance to e-commerce, popularity, the level of maintenance that is given to the code base, and their usefulness. We searched far and wide and narrowed down our search to the following:

  1. Saleor
  2. Oscar
  3. Shuup
  4. Shopify Python API
  5. WooCommerce Python API
  6. Pandas
  7. NumPy
  8. analytics-python (Twilio Segment)
  9. Django Google Optimize
  10. Waffle

The first three chosen are specifically created for e-commerce: Saleor, Oscar, and Shuup. They have the main functionalities that you would expect from an e-commerce website, including a cart, checkout process, and user management. However, each of these offers many more advanced features.

After these three, we chose two API libraries. The Shopify Python API and the WooCommerce Python API. These are very useful for a Python developer working in the e-commerce space since these two platforms are the most used e-commerce platforms on the web. These libraries can be leveraged for data analytics using other python libraries.

The rest of the libraries chosen have different functionalities that are useful for e-commerce websites, and they are detailed below. This list is not in a particular order, as each of these libraries can be useful depending on the requirements of a given project.

Saleor – E-Commerce platform

Saleor is a startup based in Poland and the United States. They describe their software as: “An open-source, GraphQL-first e-commerce platform delivering ultra-fast, dynamic and personalized shopping experiences”.

It is a full-fledged e-commerce platform, and it solves many of the issues that a developer would need to tackle if coding from scratch. These include the management of customers, orders, products, shipping, site administration, among others.

Saleor is a headless e-commerce platform. This means that Saleor delivers content as data via an API instead of delivering web pages. This makes this software highly compatible with a large variety of front-end technologies.

1, a website built using Saleor

The architecture of Saleor is made up of three main components.

  • The first is the Saleor core, which is the backend of the system. The core is coded using Python and the Django framework. It communicates with the other components via its GraphQL API.
  • The second component is the dashboard which is a front-end React application.
  • The third component of Saleor is the Storefront. They provide an example storefront coded in React. But developers can create custom storefronts with other technologies using the Saleor SDK.

There are two strategies through which developers can extend Saleor’s functionality. They may use an app-based approach to create external apps that interact with Saleor’s API. Or they may choose to create a plugin within the Saleor server. Plugins use function callbacks to extend the behavior of Saleor’s functionalities. But plugins are not supported by Saleor’s cloud service.

Saleor provides a developer guide to get started. There you will find instructions on how to install and deploy Saleor in a variety of cloud providers. Or you may deploy to your server using Docker. 

Oscar – E-Commerce Framework

Oscar is: “…an open-source e-commerce framework for Django.”

It comes with many features out of the box including a cart, analytics, a dashboard, offers, wishlists, and search. Oscar seems like a good option for B2B e-commerce. With Oscar, Sales representatives can create orders on behalf of their clients. While Customers can use many payment sources for a single order. Oscar also supports ERP Integration. And merchants can have many fulfillment partners for the same product.

The Oscar framework boasts a heavy focus on customizability and extensibility. They accomplish this customizability by relying on a design architecture based on abstract models that contain fields that are generally relevant to any e-commerce domain. The idea is that each domain will implement these basic models and create its domain-specific models based on their needs. The design also features a dynamic class loading system that prioritizes and picks up any custom classes created for a project at run time, otherwise using Oscar’s default classes.

Oscar has extensive documentation and sample projects to get started as well as recipes with solutions to common problems on their site. They also provide a live sample site that has been set up with all the default configurations to explore the system’s features, shown below.

2 Oscar Sandbox Store

Shuup – Marketplace Software

Shuup is an “out-of-the-box and fully customizable true multi-vendor marketplace software”. As this description suggests, Shuup is intended to be used for creating marketplace websites in the same vein as eBay or Amazon. Like the other products on this list, it is open source. It is flexible in terms of its offering, with the ability to have multiple types of products including physical products, digital downloads, or even services. Shuup is also a headless system, which means, as explained above, that it offers the opportunity to use any front-end technology to develop a marketplace. Additionally, Shuup allows you to use any Content Management System (CMS).  

Shuup offers Artificial Intelligence (AI) capabilities for customer experience personalization. These features include advanced search results, automated chatbots, recommendations engines that display information that users are likely to want to see, and the display of personalized ads and promotions. Their AI services also include the automation of daily processes for e-commerce operations. Examples of this include the automation of repetitive tasks, marketing automation, and customer service automation. However, these specialized services are not included with the open-source version of Shuup.

Although Shuup offers licensing of their product for businesses, they offer their open-source software for free for developers. They have documentation available here.

Shopify Python API – API Library

Shopify Python API is a library that will allow Python developers to access data in the admin area of Shopify stores. Shopify is one of the most used e-commerce platforms on the Internet today. For clients that already have a Shopify store, the Shopify Python API could help you unleash the power of Python for their benefit.

To use this library to communicate with a store’s admin page, a Shopify application needs to be created first. The application can be a private application created for a specific store or a public application created by a Shopify partner that can be used by many stores. For authentication, public apps generate tokens using OAuth, while private apps use standard HTTP authentication.

The Shopify Python API supports both GraphQL and REST. It will allow you to create, read, update, delete, the data in Shopify Stores. The API can work on many aspects of the store including customers, discounts, events, products, inventory, shipping, fulfillment, orders, Shopify payments, billing, marketing events, and many more. You can find more information about Shopify Python API here, and the documentation for the Shopify Admin API here. The REST Admin API has a rate limit of 40 requests per app per store per minute. The allotment of requests recovers at 2 requests per second. 

WooCommerce Python API – API Library

WooCommerce Python API is a library that will help python developers access data in WooCommerce stores. WooCommerce is a WordPress plugin that adds e-commerce capabilities to WordPress websites. WooCommerce, like Shopify, is one of the most used e-commerce platforms on the Internet today. The WooCommerce Python API has a similar concept to the Shopify Python API. For clients that already have a WooCommerce store, you can create Python apps that interact with their store. By using Python, you can leverage machine learning, neural networks, and other data science tools that can generate value.

In contrast to the Shopify API, the WooCommerce API only supports REST. For authentication, API keys need to be generated in the WooCommerce settings. The key that is created will be associated with a WordPress user. The API will have the user’s access levels.

The WooCommerce API can be used on just about every aspect of the store including coupons, customers, orders, refunds, products, product variations, product attributes, settings, payment gateways, and many more. The WooCommerce API responds to requests in JSON format. For information on the API endpoints, you can find documentation via this link. The repository for the python WooCommerce API can be found here.

Pandas – Data Analysis library

What if the tools listed above do not allow you to meet a project requirement? For example, you may want to create a custom report that includes data from several different platforms and do a specific mathematical analysis. This is where a tool like Pandas may be considered. Pandas (“Python Data Analysis Library”) is a mathematical analysis library.

? You can see a brief introduction to Pandas in Finxter’s 10 Minutes to Pandas (in 5 Minutes) video.

Pandas is widely used for so-called “data wrangling”. This is the act of cleaning data and/or transforming it to a different format and using it later for another purpose. With the many platforms and tools that are used for an e-commerce operation, this can be a very valuable tool. Pandas can be used to consolidate data from different sources into a manageable format that is useful for analytics. Because of its use for data wrangling, Pandas is also widely used for machine learning.  

Pandas is also useful for data visualization when combined with the matplotlib library. Visualization is also a key feature of ecommerce. Data visualization is crucial for decision-making in any business.

In the following example, we read a CSV file with data collected about the libraries that we researched for this article. Then we plot some of the data in a bar chart:

The full code for plotting the data is this:

import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('Data.csv')
df.plot(kind='bar', figsize=(15, 8), color=['blue'])
plt.xticks(range(10),df.loc[:,"Platform or Library"],rotation=20, horizontalalignment="center")
plt.title('Stars on GitHub for Top E-commerce Libraries')

The following is a step-by-step explanation of the code. First we import pandas and matplotlib:

import pandas as pd
import matplotlib.pyplot as plt

This function obtains the data from a CSV file and stores it in a data frame:

df = pd.read_csv('Data.csv')

This defines the type of graph, the size of the figure, and its color:

df.plot(kind='bar', figsize=(15, 8), color=['blue'])

Here we define the values for the labels of the bars in the chart (the names of the platforms or libraries):

plt.xticks(range(10), df.loc[:,"Platform or Library"], rotation=20, horizontalalignment="center")

Here we define the labels of the axes:


This defines the title of the figure:

plt.title('Stars on GitHub for Top E-commerce Libraries')

This function displays the figure:
3:Stars on GitHub for Top E-commerce Libraries

Pandas is an extremely useful Python library. We invite you to learn more about it in the Finxter blog.

NumPy – Scientific Computing Library

Most mathematical analysis tools and libraries that use Python rely on NumPy. In fact, Pandas also depends on NumPy. This library can be useful for any mathematical analysis done for an ecommerce operation. You can learn more about NumPy in Finxter’s NumPy Tutorial.

One of the reasons why NumPy is so prevalent is its optimized performance. NumPy was designed with vectorized python code. They avoided the use of for loops using the Python language. Instead, they wrote loops in C which is a precompiled language. Using precompiled code for complex computations means that NumPy is highly performant.

A key concept in NumPy is the multi-dimensional array: ndarray object. NumPy arrays have their size determined at creation and they must also have items with the same data type. When the size of a NumPy array is changed, the original array is deleted and a new one is created with the new size. NumPy can be used to do basic statistical calculations on these arrays of data including mean, median, variance, and standard deviation. NumPy also has all the basic mathematical operations you would expect. An important capability of NumPy is that it can be used for linear algebra operations.

Check out our collection of NumPy cheat sheets to help you keep your NumPy knowledge sharp.

analytics-python (Twilio Segment) – Analytics Library

analytics-python is a library that lets you record analytics from python code. The library allows you to connect to Twilio’s Segment service, which is a Customer Data Platform. The library is compatible with the Django Framework, and they offer instructions on how to set it up with Django in their documentation.

The library contains six main function calls that are used to store user data: Identify, Track, Page, Screen, Group, and Alias

  1. Identify gives each user a unique ID and lets you add traits about them in a dictionary.
  2. Track lets you record any actions a user does on your page such as adding an item to their cart.
  3. Page records page views and additional information about the page. This is tracked by default if you use the Segment client-side library.
  4. Screen records screen views in mobile apps along with additional optional information about the user’s screen such as their brightness setting.
  5. Group associates a user with a group, which could be an organization, company, or another type of group.
  6. Alias allows you to tie together different identities. This can be useful for certain platforms to tie together an anonymous user with their new account once they sign up.

Segment has a free tier that allows you to track up to 1,000 visitors per month from two sources (for example a website and a mobile app) and allows 300+ integrations. Segment also offers paid tiers from $120 a month with more capacity for visitors, sources, and integrations as well as additional features.

Django Google Optimize – A/B Testing

Django Google Optimize is a Django application that allows you to integrate Google Optimize with Django-based websites. Google Optimize is an A/B testing tool by Google which makes it easy to create server-side A/B tests. This type of test allows website admins to show different pieces of content to portions of their audience while measuring the outcomes. Based on the test results, the most effective piece of content can be chosen. This is extremely useful for e-commerce websites because this could directly translate to a percentage increase in sales.

Google Optimize is free, and it has a visual editor to create the different experiences that will be shown to users. It has a low barrier to entry. And it could be a great tool for small businesses that already handle analytics using Google Analytics. However, being a free option, it does have some limitations. One can only run 5 tests at a time with this tool.  Another disadvantage is that the tool does not have a segments feature. It does not allow you to divide your customers into segments for which you assign personalized experiences.

Considering these limitations, Google Optimize seems to be a good fit for smaller companies that already use Google Analytics and do not have the time to delve into more complex tools that may have a steeper learning curve.

Waffle – Feature Flipper

Waffle is a feature flipper built using Django. A feature flipper lets you change what features are loaded by your app based on a series of flags. These flags can be set by using the Django admin page. Interestingly, Flickr uses feature flipping to keep a single branch of their code-base at any given time. They use a single branch on all their servers but turn features on and off depending on the environment. This way they can test new features without affecting their production site. But how can a feature flipper be useful for e-commerce? It can be used as a part of an A/B testing toolkit.

Waffle includes tools for small-scale tests with individual users or known groups. Controlling a flag for an individual user is simple by adding the user’s account to the flag’s list of users. The flag can determine which version of the page you will show to users. However, you would need to create custom code to perform large-scale tests with a subset of production users. They suggest using page or session variables like the ones used by Google Analytics to measure the impact of changing flags on client-side metrics. In their documentation, they describe how to do server-side A/B tests for performance testing.