Exploratory Data Analysis using Ebay API

Huong Ly Ngo
Web Mining [IS688, Spring 2022]
5 min readFeb 12, 2022

In this article, I want to focus on my interest in ecommerce and then discuss about an exploratory of Ebay data using Ebay API.

INTRODUCTION TO ECOMMERCE

Even before the beginning of the pandemic, I have become heavily dependent to online shopping: from grocery to clothes, books, even home furniture etc. I well believe I am not the only one having this habit. It is today a big trend, especially during the COVID-19 era and this can be proven by the growth of ecommerce platforms such as Amazon, Shopify or Ebay. So why ecommerce has really changed the way that we shopped and the way that we do business?

Let’s look from the point of view of a seller:

- Easy to start a business

- Low product costs, thanks to the small service fees online instead of physical store rentals.

- Easy and more opportunities to reach bigger audience.

And below are some reasons that buyers, like me, want to shop online:

- More personalization

- Low product prices

- More convenient, easy to find reviews as well as to give feedbacks.

BIG QUESTIONS THAT EVERYONE WANTS TO KNOW THE ANSWERS

Of course, as a buyer, I always want to buy the best products with best reviews or rating with lowest prices. It is not evident when I am surround by thousands of products with the same functionality or colors or details etc. The “filter” and “sort” tools might be handy to narrow down the choices, but it does not really help to answer my questions: Which is the product that I should buy? What is the price that I should pay? The same logic applies to the sellers’ side: How can the sellers know which are the best-selling products on a particular marketplace? Which types of customers should we target? And of course, what price are the customers are willing to pay? All those questions are keys to the success of an ecommerce business. In this article, I want to try to explore the Ebay data using Ebay API to see if I can find the answers to my questions. I am particularly interested in Ebay more than other online platforms because Ebay is the first marketplace online in history. Ebay offers auction feature which is not available on other platforms. As this is my exploratory of data analysis using Ebay API, I will focus on one task: To find the most watched items on Ebay using Finding API.

WHAT IS API AND WHY IT IS INTERESTING TO USE API?

API, by definition, is “Application Programming Interface”. Ebay APIs are free and available to be used to collect data from Ebay databases and we can use those data for analysis reasons. Of course, there are more than one way to collect data: we can crawl public data using BeautifulSoup or Selenium but it is recommended to use APIs because the data will be more stable and require less data cleaning.

I will describe below all necessary steps:

STEP 1: Create an account on www.developer.ebay.com

Joining is free and Ebay will take up to 24 hours to verify your account.

STEP 2: Create application to get client ID and secret ID.

STEP 3: Using Python to install necessary packages and Ebay SDK(Soft Development Kits). Ebay SDK is available to help reduce time and simplify programming tasks (such as errors when we make API calls, here is Finding API.

pip install ebaysdkimport pandas as pd

STEP 4: Use the AppID to make the API calls. For this study, I want to find the most watched items on Ebay.

from ebaysdk.finding import Connection as Finding
from ebaysdk.exception import ConnectionError
from ebaysdk.merchandising import Connection as Merchandising
try:
api = Merchandising(appid="YOUR_APP_ID", config_file=None)
response = api.execute('getMostWatchedItems', {'maxResults': 100})
print(response.dict())
print(response.reply)
except ConnectionError as e:
print(e)
print(e.response.dict())
results= response.dict()
results['itemRecommendations']['item']
list_results= pd.DataFrame.from_dict(results['itemRecommendations']['item'])
list_results

The results I got from Finding API will need to be transformed from dictionary with a lot of key-value pairs to below data frame with better visual.

let’s take a closer look at this table. Below are details of the number of rows and fields of this results table that I got from Finding API to find the most watched items on Ebay

I am interested in the title of the items and the watchCount, below are the final results that I have:

That is surprising for me to see that the most watched items are Apple iPhone in all ranges of version. In my opinion, this result shows me that how useful the Ebay API is because this result is not the item that I think about in the beginning. There are more APIs for us to try: Buy APIs, sell APIs and Finding APIs on Ebay. The first exploratory data analysis using APIs is a success for me and I think definitely get a try with other available APIs.

--

--