Max Ciccotosto
posted this on February 17, 2011 09:04 pm
The Product Count API can be used to determine how many products an item source will provide given a search term and optional category. This can be used in turn to decide how a domain should be configured, or if it should be configured at all.
Usage To use this, you must simply use a well-formed url. The following are examples that will work:
http://productportals.wishpot.com/product_count_api/bedding
This is the most basic form of the url. After the host, you'll notice the path starts with 'product_count_api'. This is a required part of the url. After that, there is the search term, which in this case is 'bedding'. Because we have only included a search term, the item source is assumed to be Wishpot CPC Blend (the default), and the category is the home category.
http://productportals.wishpot.com/product_count_api/bedding?source=8
In this example, we see the addition of a 'source' parameter. You'll note that it's a number, and not a name; this has to do with url encoding and numerical convensions that exist in the codebase already. Basically, each item source is mapped to a value. Wishpot CPC Blend is mapped to 2, and PriceGrabber is mapped to 8.
http://productportals.wishpot.com/product_count_api/bedding?source=...
This example adds a category to the previous one. Notice the '+' where a space would normally go for the category name. This is in place to ensure the url is well-formed. You are encouraged to replace all spaces with plus symbols for both category names and search terms.
Another important note here: the category values that are accepted in the request url are item source-specific. So, in this case, "Bedroom Bedding" only works when the source is set to 8. If you were to set it to 2 (Wishpot CPC Blend), you would receive an error.
Response The response is in xml. The following is an example:
So, if you were to create a bedding-based domain on PriceGrabber using 'Bedding' as a search term and the category "Bedroom Bedding", PriceGrabber would have 4203 results available.
Constraints Some item sources are wary of too many requests, especially if they are from non-human agents. Because of this, we have constrained this call such that you may only make one request per second.