Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use categoryId in Foursquare Venues search API

Tags:

foursquare

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!!

like image 225
istan Avatar asked Dec 15 '11 15:12

istan


2 Answers

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).

like image 130
Jonathan Levison Avatar answered Sep 28 '22 04:09

Jonathan Levison


Super late, but i found that if you put the categoryId parameter directly after ...search? and before your authentication and version parameters, it works.

eg. search?categoryId=123&client_id=456&client_secret=789&v=20140828

like image 38
NickFujita Avatar answered Sep 28 '22 04:09

NickFujita