The Ebay Merchandising API is the focus of this fourth and last article of the series dedicated to python and Ebay APIs.

This API provides less calls than the ones we previously saw, but among them, one that can be very useful: getMostWatchedItems: we will focus on it.

In this tutorial you will learn:

  • What are the calls provided by the Merchandising API
  • How to use the getMostWatchedItems call


Introduction to Ebay API with python: The Merchandising API - Part 4
Introduction to Ebay API with python: The Merchandising API - Part 4

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Operating system agnostic.
Software git and python3
Other Knowledge of the python programming language and of the basic object oriented concepts.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

The Merchandising API


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


The Merchandising API can be very useful to help a seller attract more buyers, by, for example, adapting his activity to existing buying habits or trends which can be analyzed by looking at the result of some specific calls like getMostWatchedItems. The just mentioned call is the one we will focus on in this tutorial.

The getMostWatchedItems call

At this point of the series, you should already be quite familiar with the way the python SDK let us work with Ebay APIs. At a low level, request and responses for an API call are represented by using an xml structure, but thanks to the Ebay python SDK we can further abstract their creation and manipulation, using object oriented concepts.

Just like we did in the other articles, we will focus on one specific call the API, in this case getMostWatchedItems. The name of the call is pretty self-explanatory: by using this it, we can retrieve data about the items with the highest watch count, for an entire site, or for a specific category we can specify in the request.

Setting the credentials in the ebay.yaml file

In this example we will run our API call on the production website instead of the sandbox, since we want to obtain real results, and the call its pretty safe. Although the endpoint for the Merchandising API is different from that of the Finding API, the used domain is the same: svcs.ebay.com. This means that if you already set your credentials like we did in the second article of this series, everything is already in place in your ebay.yaml file:



eBay Merchandising API Credentials
eBay Merchandising API Credentials

We will now create a new script and call it getmostwatcheditems.py. Inside of it we will create the code necessary to send a very simple request. Here it is:

#!/usr/bin/env python3
from ebaysdk.merchandising import Connection

if __name__ == '__main__':
    api = Connection(config_file='ebay.yaml')
    results = api.execute('getMostWatchedItems', {})

    for item in results.reply.itemRecommendations.item:
        print(f"The item {item.title} has been watched {item.watchCount} times")

As you can see in the code above, we provided an empty dictionary as our request. This is possible because the getMostWatchedItems call doesn't have required parameters: all the parameters are optional. When sent this way the call will provide us the 20 globally most watched items for an ebay site. If we execute the script, we obtain the following result:


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


The item Apple iPhone 5S 16GB "Factory Unlocked" 4G LTE iOS Smartphone has been watched 26076 times
The item Apple iPhone 6 16GB 64GB 128GB GSM"Factory Unlocked"Smartphone Gold Gray Silver* has been watched 23441 times
The item Apple iPhone 5C 16GB "Factory Unlocked" 4G LTE Smartphone has been watched 18514 times
The item Apple iPhone 6 64GB "Factory Unlocked" 4G LTE 8MP Camera WiFi iOS Smartphone has been watched 17683 times
The item Samsung G900 Galaxy S5 Verizon Wireless 4G LTE 16GB Android Smartphone has been watched 17651 times
The item Apple iPhone 5 16GB "Factory Unlocked" Black and White Smartphone has been watched 16946 times
The item Apple iPhone 6s- 16GB 64GB 128GB GSM "Factory Unlocked" Smartphone AND AT&T * has been watched 16569 times
The item Apple iPhone 6 16GB Factory Unlocked GSM Camera Smartphone has been watched 14097 times
The item Samsung Galaxy Note 8 SM-N950F/DS 64GB (FACTORY UNLOCKED) Black Gold Gray Pink has been watched 12678 times
The item Samsung N910 Galaxy Note 4 32GB Verizon Wireless 4G LTE Android Smartphone has been watched 12512 times
The item Apple iPhone 6+ Plus-16GB 64GB GSM Factory Unlocked Smartphone Gold Gray Silver* has been watched 12423 times
The item Samsung Galaxy S5 G900V 16GB Verizon + GSM (AT&T T-Mobile UNLOCKED SmartPhone SR has been watched 12276 times
The item Samsung Galaxy S6 SM-G920V 32GB Verizon + GSM Factory Unlocked LTE Smartphone has been watched 10283 times
The item Apple iPhone 7 32GB GSM Unlocked Smartphone has been watched 10206 times
The item Apple iPhone 6 Smartphone 16GB 64GB 128GB AT&T Verizon Unlocked T-Mobile Sprint has been watched 10167 times
The item Apple iPhone 6 4.7" 16GB GSM UNLOCKED Smartphone SRF has been watched 9797 times
The item Apple iPhone 6 Plus 5.5" 16 64 128GB 4G LTE GSM UNLOCKED Smartphone SRF has been watched 9609 times
The item Samsung Galaxy S8 SM-G950FD Dual Sim (FACTORY UNLOCKED) Black Gold Gray Blue has been watched 9608 times
The item Samsung G900 Galaxy S5 Verizon Wireless 4G LTE 16GB Android Smartphone has been watched 9544 times
The item Samsung Galaxy S7 32GB SM-G930T Unlocked GSM T-Mobile 4G LTE Android Smartphone has been watched 9253 times

Please notice that we here provide the list of the products as it is returned from the request at the moment of writing this guide: we mention the products without any advertising intent.

Restricting our request to a specific category

In the example above, as we already said, we obtained absolute results. What if we want to restrict our research to a specific category? Well it's very simple: suppose we want to know the most watched items in the "Video Games" category (id 1249): all we must do is to specify said category by using the categoryId key in our request, which becomes:



results = api.execute('getMostWatchedItems', {'categoryId': '1249'})

If we run the script again, with this modification, as expected, we obtain the list of the 20 most watched items for that category:


The item Microsoft Xbox LIVE 12 Month Gold Membership for Xbox 360 / XBOX ONE has been watched 28791 times
The item Sony PlayStation 4 (PS4) - 500 GB Black Console w/ accessories (controller, etc) has been watched 26219 times
The item Sony PlayStation Plus 1 Year Membership Subscription Card - NEW! has been watched 15664 times
The item Microsoft Xbox One 500gb Black Console Bundle w/ accessories ie. controller etc has been watched 15047 times
The item Nintendo Switch 32GB Console with Neon Blue and Neon Red Joy-Con has been watched 9402 times
The item Microsoft Xbox One Console 500GB - 1TB White Black has been watched 7489 times
The item Nintendo Switch with Neon Blue and Neon Red Joy-Con has been watched 7175 times
The item Microsoft Xbox One - 500 GB Black Console Only (60 Day Warranty) has been watched 5345 times
The item Sony PlayStation 4 PS4 Slim/Special Edition/PRO Option  PS4 Console has been watched 4569 times
The item Nintendo Switch Refurbished 32GB Console Gray Joy-Con Factory Warranty Included has been watched 4441 times
The item Sony PlayStation 4 PS4 1TB 500GB Console Only has been watched 3669 times
The item 2x For Sony PS2 2.4G Wireless Twin Shock Game Controller Joystick Joypad has been watched 3534 times
The item Microsoft Xbox One S 500gb White Console & accessories! has been watched 3234 times
The item Xbox One S 500GB Open Box - Good Retail Box [Factory Refurbished] has been watched 3004 times
The item Microsoft Xbox 360 Console System with HDMI White Pro 2 Year Warranty has been watched 2931 times
The item N64 NINTENDO 64 CONSOLE + CONTROLLERS + BONUS OFFER- SUPER MARIO KART SMASH BROS has been watched 2751 times
The item 2x Black Wireless Bluetooth Game Controller Pad For Sony PS3 Playstation 3 has been watched 2743 times
The item SNES Classic Mini Edition - Super Nintendo Entertainment System - Brand New! has been watched 2614 times
The item Official Microsoft Xbox One Elite Wireless Controller - Black - HM3-00001 In Box has been watched 2536 times
The item Official Sony PlayStation 4 PS4 Dualshock 4 Wireless Controller (Wave Blue) NEW has been watched 2534 times


Obtaining less results

One other option you may want to specify in the request is maxResults. By using it we can restrict the number of items returned by the call. The minimum value we can use is 1, while the maximum is 50. The default, as we mentioned before is 20.

Conclusions

In this fourth and last article of the series dedicated on python and Ebay APIs, we focused on the Merchandising API and specifically to the getMostWatchedItems call. This call, by default, returns information about items with the highest watch count for an ebay site, globally or relative to a specific category. How can this be useful for a seller?

Well, for starters, by analyzing the results of this call, one can see and identify buyers preferences and market trends; a seller can also take inspiration from titles and other formatting styles used in those listings. Those elements are very important and contribute relevantly to the visibility of an item. What do you thing about this series of articles? Are you interested in similar topics or further examples? Let us know!



Table of Content
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions