Is it possible to search venues (via venues/search) in whole city without passing "radius" parameter? Because I don't know radius of each city :) Documentation says "Searches can be done near a point or through a whole city", but how can I provide this in venues/search?
Thanks.
I do not think there is a way to tell it 'search the entire city', but I also think it might be a wrong use case.
You need to remember a few things when searching:
Foursquare will return up to 50 results (the limit parameter)
The 50 results are ordered by the most popular places around the center of your search
So if you are searching a city which have more than 50 venues in Foursquare database, 'searching the entire city' will usually get the same (up to) 50 results - always.
This where the filters comes in handy, in our case, to get you better results for our needs, we use the categoryId combined with the radius to get things we want to show our users. Sometimes we get information from other cities because of a big radius, but for our application its okay, we actually give our customers more options :) . I can also guess that a lot of apps also use the query filter as they know the name of the place they are looking for.
You just need to experiment with it and discover how to get the data which is right to your application.
In theory, to search an entire city I would use the city lat/lng from Google or Open Street Maps or geonames and do a 10Km search around that point (intent=browse, radius=10000), the following is a guess, but it will get 50 places for over 99% of the cities people who own smartphones live in :)
You can do obtain results within in a city as follows:
https://api.foursquare.com/v2/venues/search?near=Singapore,Singapore&client_id=YOUR_CLIENT_ID
&client_secret=YOUR_CLIENT_SECRET3&v=YYYYMMDD
For more details check the documentation:
https://developer.foursquare.com/docs/venues/explore
Assuming you're talking about requests with a query, I would just set a reasonable value for radius and use the city's default city center. If you want to avoid showing results from neighboring cities, you can post-request filter by the returned venue's "city" string in the location stanza.
Related
Question to Foursquare engineers :) Could you please explain to me why I cannot find restaurant using /venue/search end-point ?
Restaurant in question is Aqua in San Francisco. According to /venue/ID request restaurant location is 37.793489,-122.399905. So I'm calling /venue/search request with intent=checkin with exactly these coordinates.
https://api.foursquare.com/v2/venues/search?v=20130712&ll=37.793489,-122.399905&categoryId=4d4b7105d754a06374d81259,4d4b7105d754a06376d81259&intent=checkin&radius=100&oauth_token=QEJ4AQPTMMNB413HGNZ5YDMJSHTOHZHMLZCAQCCLXIX41OMP
API returns me 30 items with no Aqua in it. Where as in documentation it says:
Unlike the checkin intent, browse searches an entire region instead of only finding Venues closest to a point.
So then why doesn't it return items sorted by the distance from the point I provided?
If I change intent to browse I'll get "Aqua" in results.
Basically behavior looks inconsistent. How can I make it more reliable ?
It looks like this is happening because this isn't a venue that Foursquare thinks you're likely to check in at. Given your lat/lon and radius, Foursquare thinks that you're more likely to check in to the 30 results you see than the restaurant you have in mind.
However, if you either reduce the radius or increase the number of results, you'll find the restaurant in question.
I see that the foursquare api has a 50 result limit and this sort of concerns me a bit. My problem is this
"A user would scan a item and it would find all stores that have that item within x kms from them".
Now in some categories like groceries I don't think the 50 result limit will be too bad as I can't really think of an area that 50 grocery stores even if I up the search area to the max(50kms).
However what if that item is a piece of clothing and you in say a big mall. I would think in this situation that the 50 limit can be hit.
I would get 50 results back and then scan my database to see if that store contains that clothing. Yet nothing comes back but in reality if I could have had 51 stores returned that 51th store would have had it.
Anyone have any ideas to prevent this?
Yes, there is a way around this that involves running multiple searches that specify slightly different locations within the same general area.
This has been answered before here: How do I get more locations?
I'm getting some erratic results from Foursquare's venue search API and I'm wondering if anyone has any tips on how to process my input parameters for the most "intuitive" results.
For example, suppose I am searching for a venue called "Ise Sushi", around "New York, NY", which is equivalent to (lat: 40.7143528, lon: -74.00597309999999) using Google Maps API. Plugging into the Foursquare Venue API, we get:
https://api.foursquare.com/v2/venues/search?query=ise%20sushi&ll=40.7143528%2C-74.00597309999999
This yields pretty underwhelming results: the venue I'm looking for ends up rather far down the list, at 11th place. What's interesting is that reducing the precision of the coordinates appears to produce much better results. For example, suppose we were to round the coordinates to 3 significant digits:
https://api.foursquare.com/v2/venues/search?query=ise%20sushi&ll=40.7%2C-74.0
This time, the venue I'm looking for ends up in 2nd place, even though it is actually farther from the center of the search (1072 meters, vs. 833 meters using the first query).
Another modification that appears to help improve the quality of search is substituting underscores for spaces to separate our search terms. For example, here's the original query with underscores:
https://api.foursquare.com/v2/venues/search?query=ise_sushi&ll=40.7143528%2C-74.00597309999999
This produces the most intuitive-seeming results: the venue I'm looking for appears first, and is accompanied by just one other result, "Ise Restaurant" (which is tagged as a "sushi restaurant"). For what it's worth, this actually seems to be the result set of the same search conducted on Foursquare's own website.
I'm curious what lessons I should be learning from this. Should I be reducing the precision of my coordinates? Should I be connecting my search terms with underscores, and if so, does that limit how a user can order their search terms?
Although there are ranking improvements we can make on our end to find this distant exact match, it generally also helps to specify intent=browse (although it looks like in this case, for now, it may give you worse results). By default, /venues/search uses intent=checkin, which tries really hard to find close-by matches for checking in to, at the expense of other ways a venue might match your search. Learn more at https://developer.foursquare.com/docs/venues/search
I'm trying to match existing data to Foursquare Venues. I've tried matching about 100,000 records using intent=match and 30% of them don't return results. Now, sometimes these venues are actually missing, but sometimes the search just isn't finding results that would be obvious to a human. For example:
https://api.foursquare.com/v2/venues/search?intent=match&ll=40.075800000000001,-80.698800000000006&query=19%20TH%20HOLE
That returns no results. However, if I search for "19TH HOLE" I do get a result.
I could just add all these non-matches to Foursquare, but it seems that I'd end up creating a whole lot of duplicates... and I don't want to abuse the system. We're trying to make Foursquare our Venues database, and we can't go and process 300,000 records without matches by hand, either.
I'm open to suggestions on what else I can do.
You can "relax" the search strictness by specifying intent=checkin or intent=browse and using your own criteria to determine if the top result is the one you're looking for.
The company I work for is in the business of sending press releases. We want to make it possible for interested parties to search for press releases based on a number of criteria, the most important being location. For example, someone might search for all news sent to New York City, Massachusetts, or ZIP code 89134, sent from a governmental institution, under the topic of "traffic". Or whatever.
The problem is, we've sent, literally, hundreds of thousands of press releases. Searching is slow and complex. For example, a press release sent to Queens, NY should show up in the search I mentioned above even though it wasn't specifically sent to New York City, because Queens is a subset of New York City. We may also want to implement "and" and "or" and negation and text search to the query to create complex searches. These searches also have to be fast enough to function as dynamic RSS feeds.
I really don't know anything about search theory, or how it's properly done. The way we are getting by right now is using a data mart to store the locations the releases were sent to in a single table. However, because of the subset thing mentioned above, the data mart is gigantic with millions of rows. And we haven't even implemented cities yet, and there are about 50,000 cities in the United States, which will exponentially increase the size of the data mart by so much I'm afraid it just won't work anymore.
Anyway, I realize this is not a simple question and there won't be a "do this" answer. However, I'm hoping one of you can point me in the right direction where I can learn about how massive searches are done? Because I really know nothing about it. And such a search engine is turning out to be incredibly difficult to make. Thanks! I know there must be a way because if Google can search the entire internet we must be able to search our own database :-)
Google can search the entire internet, and your data via a Google Appliance!