Skip to main content
Published: May 22 2015, 10:18:00 AMUpdated: July 29 2022, 10:20:33 AM

How to retrieve a seller's items that are not:
1) Vehicles
2) Real Estate

 

Summary

    You can use PrimaryCategory.CategoryName property to identify an item's listing category.  
     PrimaryCategory.CategoryName is returned in GetSellerList, GetItem and GetBidderList
   As you can see that to accommodate the mentioned use case - be able to filter out the 
certain items based on its listing catetory is to use GetSellerList api call. However; the GetSellerList call returns large amount of data, you need to follow the best practice provided in the KB article Guidelines for using DetailLevel and GranularityLevel in GetSellerList to control the volume of the response.


Detailed Description

  The PrimaryCategory.CategoryName property returns a fully qualified category name like
          Collectibles:Decorative Collectibles,  eBay Motors:Cars Trucks, ..
    as it would appear on the eBay Web site, and  we can then use Java String startWith() api to get the item's most top level Category names like Art, Books, Music ... The below Java code shows how to filter the unwanted items from the
GetSellerList response.

 public void request(ApiContext apiContext){
        try{     
             String from = "2022-07-19 00:00:00", to = "2022-07-19 23:00:00";
             java.util.Date dtfrom = eBayUtil.fromAPITimeString(from),  dtto = eBayUtil.fromAPITimeString(to);          
             java.util.Calendar calFrom = java.util.Calendar.getInstance(), calTo = java.util.Calendar.getInstance();
             calFrom.setTime(dtfrom);
             calTo.setTime(dtto);
             TimeFilter tf = new TimeFilter(calFrom, calTo);
           
             PaginationType pt = new PaginationType();
             pt.setEntriesPerPage(new Integer("200"));
             pt.setPageNumber(new Integer("1"));
           
             GetSellerListCall gslc = new GetSellerListCall(apiContext);
             gslc.setStartTimeFilter(tf);
             gslc.setEndTimeFilter(tf);         
             // set the GranulatityLevel to Medium for getting ListingType property
             gslc.setGranularityLevel(GranularityLevelCodeType.Medium);
             gslc.setPagination(pt);
           
 //execute the GetSellerList call
             ItemType[] retItems = gslc.getSellerList();

             //iterate through the seller's items 

             for (ItemType item : retItems){ 
                   String listingType = item.getListingType().toString();
                   String categoryName = item.getPrimaryCategory().getCategoryName();
                  
  // filter out both the Real Estate and eBay Motors items
                   
// <CategoryName>eBay Motors:Cars Trucks:Honda:Civic</CategoryName>                      
                    //
<CategoryName>Real Estate:Land</CategoryName>

                     if( ( ! categoryName.startsWith("Real Estate")) && ( ! categoryName.startsWith("eBay Motors")) ){
                       
     // get the sold items only
                            if ((item.getSellingStatus().getQuantitySold().intValue() !=0)){
                                 System.out.println("item: "+ item.getItemID().getValue() +" is listed in categoryName: [ "+ categoryName+" ]");
                                 System.out.println("Item Current price :" +item.getSellingStatus().getCurrentPrice().getValue());
                                 System.out.println("Item sold: " + item.getSellingStatus().getQuantitySold().intValue());
                           }
                      }               
                
            }       
        }catch(Exception e){}
    }


Version Info

The code example above was based on the versions specified below:

 

 

API Schema Version967
Java SDK Versionjavasdk v883.0 P

 

 

Attachments
How well did this answer your question?
Answers others found helpful