Question

In the category list in the documentation, there are overall categories (Food, Restaurants, Health), and many sub categories within them. However, when I make a request and parse the JSON, the only categories that are returned are the sub-categories.

Even the example json in the documentation doesn't have the overall categories "categories": [ [ "Local Flavor", "localflavor" ], [ "Mass Media", "massmedia" ] ],

If I search for restaurants, the categories will return things like "italian, french, american", but not "restaurants". Is there a way to get the overall category in the json so I can use it?

Thanks

Was it helpful?

Solution

Use the search API instead, and set a category_filter according to this list.
This should give you all the "objects" in the given category.

Something like this http://api.yelp.com/v2/search?category_filter=restaurants.


Update

It seems like I misunderstood a little... so you want to get the root category.
(eg. for "italian"–>"restaurants", "french"->restaurants, "car dealers"->automotive etc.)

I think you have two options:

  1. Hardcode the dictionary of all restaurant subcategories (french,italian...) into a file (plist, json, whatever) and after getting the "object" you could check if the subcategory is included in the hard-coded subcategories dictionary.
  2. Use the search API and provide the bussiness id and category_filter set to restaurants and check if it returns any result - if not, then the object is not in the right category.

The reason why I am suggesting to hard code it is, because Yelp doesn't provide an API to get complete list of categories.

In my opinion I would try the approach #1, because it is less intensive on the network side and a dictionary is blazing fast.

But to answer your initial question, no it is not possible to have the root category in the JSON file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top