How to use categoryId in Foursquare Venues search API

istan picture istan · Dec 15, 2011 · Viewed 8.2k times · Source

I am getting unexpected results from API queries when including a categoryId parameter.

For instance, when using the following parameters to search for 'The Citizen Public House' in Boston, MA

ll: 42.3489027315987, -71.096134185791
query: citizen 
categoryId: 4bf58dd8d48988d116941735    <== 'bars' 

The results wind up including venues from other categories, like 'banks'. Is there something wrong with the categoryId parameter? In the API documentation it is labeled 'experimental.' Am I using it improperly?

FYI: I am using the quimby gem to interface with the foursquare API via a rails app.

Thanks!!

Answer

Jonathan Levison picture Jonathan Levison · Dec 15, 2011

If the place you were looking for is

Citizen Public House & Oyster Bar

Then you were using the wrong categoryId :(
The categories have an hierarchy, and search is done by it.

Specifically, 4bf58dd8d48988d116941735 is the bars category
That place is a Whisky Bar, category ID: 4bf58dd8d48988d122941735

Why banks returned, not sure :) I am almost sure that when searching with a query, the foursquare engine forces results to match the query, regardless of other filters.

You should download all categories and see the categories tree to better understand which ID to use.
Note, you can look for the Nightlife category 4d4b7105d754a06376d81259 which have all bars included in it, since you are looking with a query you should find what you are looking for (you can also try experimenting with intent=match or browse and a radius as well).