tags:

views:

127

answers:

4

Basically, when a user inputs a product name (such as "iPhone 3g"), I would like to know the parent categories of that item (such as Electronics / Mobile phones). Is there a web api (ie. for ebay, amazon etc.) or any other way to figure out that information?

A: 

For something like that you're going to have to ask them to specify a category. I've never heard of such a thing.

Gthompson83
+1  A: 

Yahoo Product API has a ton of information. Now, there is no authoritative source, just Yahoo's hierarchy or individual store results, so you could just pick the first one (look under "Categories" to get the category info). http://developer.yahoo.com/shopping/V3/productSearch.html

e.g. http://shopping.yahooapis.com/ShoppingService/v3/productSearch?appid=YahooDemo&query=iphone

http://shopping.yahooapis.com/ShoppingService/v3/productSearch?appid=YahooDemo&query=ipod

Matt Rogish
Thank you. That was exactly what I needed. I also like the "spellSuggestion" field, which would be really useful.
Boolean
A: 

You could download Wikipedia's database and use its category information. For example, Wikipedia specifies the following categories for iPhone:

2007 introductions | Apple Inc. mobile phones | Apple personal digital assistants | Digital audio players | IPod | Multi-touch | Portable media players | Quad Band GSM phones | Smartphones | Touchscreen mobile phones | Wi-Fi devices | Personal digital assistants | Cloud clients

You could also look at something like Freebase, although its dataset won't be as rich as Wikipedia.

sanity
That would be very useful. I like how detailed it is. Thank you for sharing.
Boolean
A: 

You can try with scrapping query results at Google Directory

Use this URL as example:

http://www.google.com/search?cat=gwd%2FTop&q=iphone

http://www.google.com/search?cat=gwd%2FTop&q=<your_query_term>

Then, you can parse the html of the google directory result and get a very good approximation of categories. For the example above, it yields (considering the first ranked result, results may vary with other terms):

**Category**: Computers > Systems > Handhelds > Smartphones > iPhone

Similarly, it can work with other moderately popular terms.

With Python or Java is very easy the parsing of the html. For example, look at this:

Alex. S.