How to use categoryId in Foursquare Venues search API
Asked Answered
A

3

6

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

Alrick answered 15/12, 2011 at 15:8 Comment(0)
G
6

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

Guggle answered 15/12, 2011 at 16:2 Comment(6)
Category restricts and queries should work at the same time. We'll investigate to see if there's a bug in that behavior.Atbara
sorry, i picked the wrong categoryId for my example. I also ran the query with the nightlife categoryId and also the one above that in the tree, which I believe is food. In all cases my query returned banks and other spurious results.Alrick
I'm seeing the same behavior. I use the top level food categoryID: 4d4b7105d754a06374d81259, but I see results for venues in other categories.Pueblo
I just experienced the same behavior today. I also used the top level food categoryId but there are non-food results. When I tried it with Foursquare's API Explorer, the query returned the expected results under the "Food" category. I also set the "intent" parameter to "browse" but there are no problems before. But after removing the "intent" parameter, it is back to normal again. And I also found a problem which is same with mine: https://mcmap.net/q/1774462/-categoryid-ignored-for-intent-browse-searches-in-foursquare-venues-search/204575Superiority
Same here, a year+ later... seems the categoryId doesn't do much.Confront
Same problem, in 2016... If you have no choice but using foursquare, it is better to use /venues/explore and a section filter.Tedford
A
3

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

Alfonsoalfonzo answered 29/8, 2014 at 5:2 Comment(0)
S
0

It seems that all the categoryIDs at foursquare are the same. I just polled for an airport and let it give me its categoryID and then did the same for bars. They both had the same categoryID.

I found one different categoryID (4eb1bc533b7b2c5b1d4306cb Airport Lounge) and when using it as a filter it returned only results with this ID.

Seriema answered 3/7, 2013 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.