skip to Main Content

On the E-Bay web site you can search for e. g. bracelets with main color being silver (see screenshot below).

Screenshot

Is it possible to run such query (find newest bracelets with main color silver) programmatically (via the eBay Search API)? If yes – how?

I looked at findItemsAdvanced, but didn’t find any reference to color search there.

3

Answers


  1. you probably want to use AspectFilters. the input for that can be found in the previous query (as stated in the documentation. see aspectHistogrammContainer)

    Login or Signup to reply.
  2. VariationType appears to be able to do that.

    Login or Signup to reply.
  3. Refining searches with the Finding API is done through Aspect Filters which are defined in the documentation as:

    Aspects are well-known, standardized characteristics of an item. For
    example, “Screen Size,” “Processor Type,” and “Processor Speed” could
    be aspects of Laptop PCs. Aspects can vary for different kinds of
    items. For example, the aspects of Laptop PCs are different from those
    of Women’s Dresses (aspects for Women’s Dresses might include “Sleeve
    Style,” “Dress Length,” and “Size”).

    Performing a search is a two step process.

    1. Determine what aspects are available for the category you are searching in.
    2. Choose what aspects you will use and integrate them as filters in your search request.

    The following examples use the Finding Kit that eBay provide as part of their Java SDK.

    The first example shows how to obtain the aspects that are available. This is achieved via the getHistograms operation. For this example we will use the category Jewelry & Watches > Fashion Jewelry > Rings (67681) that is found on the US eBay site.

    import java.util.List; 
    import com.ebay.services.client.ClientConfig; 
    import com.ebay.services.client.FindingServiceClientFactory; 
    import com.ebay.services.finding.*; 
    
    public class GetHistograms { 
        public static void main(String[] args) { 
            try { 
                ClientConfig config = new ClientConfig(); 
                config.setApplicationId("<YOUR EBAY APP ID>"); 
    
                FindingServicePortType serviceClient = FindingServiceClientFactory.getServiceClient(config); 
    
                GetHistogramsRequest request = new GetHistogramsRequest(); 
    
                request.setCategoryId("67681");
    
                GetHistogramsResponse result = serviceClient.getHistograms(request); 
    
                AspectHistogramContainer aspectHistogramContainer = result.getAspectHistogramContainer();
                List<Aspect> aspects = aspectHistogramContainer.getAspect();
                for(Aspect aspect : aspects) {
                    System.out.println("* " + aspect.getName() + " *");
                    List<AspectValueHistogram> values = aspect.getValueHistogram();
                    for(AspectValueHistogram value : values) {
                        System.out.println(value.getValueName());
                    }
                }
            } catch (Exception ex) { 
    
            } 
        } 
    }   
    

    Each category can have multiple aspects that consist of a name, such as Color, and several values such as Red, White, Blue. An example of the output produced by this code is shown below.

    • Metal Purity
    • 10k
    • 14k
    • 18k
    • Main Stone
    • No Stone
    • Abalone
    • Agate
    • Main Color
    • Aqua
    • Black
    • Blue

    The names and values returned from getHistograms can now be used as filters in the findItemsAdvanced operation. For the second example we will use the Brand and Main Color aspects. This example also uses the same category as the first.

    import java.util.List; 
    import com.ebay.services.client.ClientConfig; 
    import com.ebay.services.client.FindingServiceClientFactory; 
    import com.ebay.services.finding.*; 
    
    public class FindItem { 
        public static void main(String[] args) { 
            try { 
                ClientConfig config = new ClientConfig(); 
                config.setApplicationId("<YOUR EBAY APP ID>"); 
    
                FindingServicePortType serviceClient = FindingServiceClientFactory.getServiceClient(config); 
    
                FindItemsAdvancedRequest request = new FindItemsAdvancedRequest(); 
    
                request.getCategoryId().add("67681");
    
                AspectFilter aspectFilter = new AspectFilter();
                aspectFilter.setAspectName("Brand");
                aspectFilter.getAspectValueName().add("Paula Abdul");
                aspectFilter.getAspectValueName().add("Tiffany");
                aspectFilter.getAspectValueName().add("Tommy Hilfiger");      
                request.getAspectFilter().add(aspectFilter);
    
                aspectFilter = new AspectFilter();
                aspectFilter.setAspectName("Main Color");
                aspectFilter.getAspectValueName().add("Gold");
                aspectFilter.getAspectValueName().add("Silver");
                request.getAspectFilter().add(aspectFilter);
    
                PaginationInput pi = new PaginationInput(); 
                pi.setEntriesPerPage(2); request.setPaginationInput(pi); 
    
                FindItemsAdvancedResponse result = serviceClient.findItemsAdvanced(request); 
    
                System.out.println("Found " + result.getSearchResult().getCount() + " items." ); 
                List<SearchItem> items = result.getSearchResult().getItem(); 
    
                for(SearchItem item : items) { 
                    System.out.println(item.getTitle()); 
                } 
            } catch (Exception ex) { 
    
            } 
        } 
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search