For full functionality of this site it is necessary to enable JavaScript.
Here are the instructions how to enable JavaScript in your web browser.

Knowledge base

Find the answer to your question

Advanced Search PView

Search terms
Search Type
Product
Category
Language
Format
SDK
Sort by
Direction

Best Practices for GetCategories API call

  • Answer ID 597
  • Published 08/08/2006 04:47 PM
  • Updated 10/20/2013 06:41 AM
  • Permalink https://ebaydts.com/eBayKBDetails?KBid=597
Product
Best practices for GetCategories API call

All metadata calls and GetCategories in particular, have a significantly large response size when retrieved in full.  Here are some suggestions to optimize the usage and increase the efficiency of your application:

  • Set up an admin function to run on a scheduled basis.   Make a call to GetCategories for the first time with DetailLevel ReturnAll, download the entire structure and store it in your database.  Once you have that, make a call everyday with no DetailLevel and get just the CategoryVersion.  Compare this with the CategoryVersion in your database.  If there is a change, then make a call to GetCategories with DetailLevel ReturnAll and get the new structure.
  • Use compression.  If you use the .NET or the Java SDK, compression is turned on by default.  If you use other technologies, see this KB article: Implementing Compression: When and How.
  • Inspite of compression, if you run into time issues when you try to get the entire structure, use LevelLimit to first get the top level categories.  Then for each of the top level categories, set it as the CategoryParent and get the hierarchy below them.  This mechanism is also very useful if you list in a few verticals and you can get just those branches of interest.

    Sample GetCategories XML request to get the top level categories:
    <?xml version="1.0" encoding="utf-8"?>
    <
    GetCategoriesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
      <
    CategorySiteID>0</CategorySiteID>
      <
    DetailLevel>ReturnAll</DetailLevel>
      <
    RequesterCredentials>
        <
    eBayAuthToken>*****</eBayAuthToken>
      </
    RequesterCredentials>
      <
    LevelLimit>1</LevelLimit>
    </
    GetCategoriesRequest>

Sample GetCategories XML request to get the hierarchy for a top level category:
<?xml version="1.0" encoding="utf-8"?>
<
GetCategoriesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  <
CategorySiteID>0</CategorySiteID>
  <
DetailLevel>ReturnAll</DetailLevel>
  <
RequesterCredentials>
    <
eBayAuthToken>*****</eBayAuthToken>
  </
RequesterCredentials>
  <CategoryParent>
20081</CategoryParent>
  </
GetCategoriesRequest>

If you already have items listed with an old category, and if there is a change, where category is mapped to new CategoryID, a quick way to find the mappings is to call GetCategoryMappings.

How well did this answer your question?

Answers others found helpful

Print Email This Page Delicious Digg Facebook Reddit StumbleUpon Twitter