foursquare:venues/search?intent=browse returns more places when specifying categoryIds one by one than without categoryId - api

I use the venues/search endpoint of Foursquare to fetch all places around a point, within a given radius.
For example, if I query without specifying any categoryId:
https://api.foursquare.com/v2/venues/search?ll=48.857091635218225,2.341747995157864&radius=200&v=20151023&intent=browse
I get 11 places. If I additionally specify a categoryId (Food):
https://api.foursquare.com/v2/venues/search?ll=48.857091635218225,2.341747995157864&radius=200&v=20151023&intent=browse&categoryId=4d4b7105d754a06374d81259
I get 23 places, all strictly located within the required radius. How can you get more Food places than places of any category?
I've made more general checks, and this seems to be a general behaviour of the API.
Is this an expected behavior? Any way to have an exhaustive list of places without having to query category by category?

Related

Sorting the response from the Foursquare Places API re:two word name?

We are trying to query the Foursquare api to query for a two word name:
Cava Grill in Gaithersburg, MD
We are trying this via:
https://api.foursquare.com/v2/venues/search?intent=checkin&query=cava%20grill&near=gaithersburg,%20md&limit=1&oauth_token=SEB14NBLGO4HMFTOXQX0JZTSVGM41ENNKE0X1RXHCI5XP3P5&v=20150420
(don't worry ... this is the public API key from the FS page)
Two odd behaviors:
Even though we are explicitly searching for the Cava Grill in Gaithersburg, MD ... the Bethesda, MD one comes up first in the results (odd, why??)
Chipotle Mexican Grill shows up in this result set ... we suppose because of the word "Grill"
So ...
a. anyone know why the Bethesda one would show up higher in the result set? (Should we just narrow the radius tighter?)
b. anyone know if we can look for the "entire query" vs. each word in the query?
Results are queried and sorted differently based on your intent. If you're looking for a specific venue, I suggest changing your intent from checkin to match. Browse may also be a good choice depending on future search params
Here's the nutshell on the intents:
intent=checkin returns a list of venues where the user is most likely is located
intent=browse returns a list of most relevant venues for a requested region, not biased by distance from a central point.
intent=match returns a single result that, with high confidence, is the corresponding foursquare venue for the query-based request
I hope this helps

Google Geocode Components two countries

How is it possible to filter the results of the Google Geocode API and the use of the components parameter for two (or more) countries, without issuing another request.
Example:
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&components=country:DE,AT&address=wien
gives zero result, as there is no Wien in Germany and the AT after the comma is ignored
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&components=country:AT,DE&address=wien
is ok, because there is an Wien in Austria
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&components=country:AT|country:DE&address=wien
gives zero results, as the two component filters are outruling each other
Is there something in the documentation that I overread that makes it possible, or can't I make it at all?
Edit
I tried a workaround with setting the merged bounds of Germany and Austria, but that just weighs the results and not filters them, so I got a result which I didn't want with http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&components=bounds:55.058,17.161|46.372,5.866&address=new%20york. In this case I want a ZERO_RESULTS status.
This is not currently possible. Please vote up issue #4233 if you want to see this happen.
For time being I can suggest three possible workarounds, none of them perfect:
Make multiple requests and merge the result sets manually. This will give the best accuracy, but is obviously the slowest.
Use the manually merged bounds trick in HerrSerker's question, then manually filter out results where the short_name of the address_components element with a types of country is not in your list of countries.
Drop the component filter entirely and include "Austria OR Germany" in your search string. Again, you will want to manually filter the results.

CategoryId in venues search not working correctly

In foursquare Api documentation for "Search venues" https://developer.foursquare.com/docs/venues/search it states
"categoryId - A comma separated list of categories to limit results to. This is an experimental feature and subject to change or may be unavailable. If you specify categoryId you may also specify a radius. If specifying a top-level category, all sub-categories will also match the query."
Realise its supposed to be experimental, but when I provide Food category i.e. 4d4b7105d754a06374d81259, it only returns a few local results, the rest are miles away. However if I execute same search on website sing Food category, it returns correctly lots of results, assuming its the last bit "If specifying a top-level category, all sub-categories will also match the query" is not working , i.e. its not searching sub-categories ?
Any fix work around for this ?
Thanks,
Neil Pepper
You're making a /venues/search request with its default intent of intent=checkin. This returns a filter on nearby results, heavily biased by distance since it's trying to guess where the user might be checking in.
Foursquare Explore uses the /venues/explore endpoint and attempts to return recommended results for a query. If you want to get the sorts of results you get in that tool, call /venues/explore?section=food

Foursquare Venue API & Number of Results

Is it possible to get more than 50 results from the Foursquare Venues API? (https://developer.foursquare.com/docs/venues/search.html)
The default limit is 50, but it does not make any mention of pagination or offset to get additional listings.
Please advise.
As answered here
The API docs here can help.
Foursquare searching is very closely linked to the location 'point' (the 'll' param on the query) that you provide. The simple answer is that to find more venues within a given area, you need to simply query again with a different location 'point' within that area.
Two queries, both at points close to one another:
https://api.foursquare.com/v2/venues/search?ll=40.700,-74.000&limit=50
https://api.foursquare.com/v2/venues/search?ll=40.705,-74.005&limit=50
will get you two different sets of venues (that may overlap, depending on how close the points are).
The default intent for the search method is 'checkin', which will return the 50 most popular locations closest to that point. If instead you want to look at all the venues within an area, you can use the 'browse' intent. This takes either a 'radius' parameter, in which case it returns venues inside a circle around the given point with the given radius, or it takes two coordinates representing the 'sw' and 'ne' corners of a rectangle. So, you could do:
https://api.foursquare.com/v2/venues/search?ll=40.705,-74.005&limit=50&intent=browse&radius=50
which will give you 50 venues within the 50m circle around that point. A smaller radius will reduce the number of venues returned. So, by varying the radius and the point at which you search (or the size and position of the rectangle described by the 'sw' and 'ne' parameters), you can get more venues returned.
Hope that helps.
For the record, Foursquare now offers a pagination parameter in their API request:
"offset - Used to page through results."
https://developer.foursquare.com/docs/venues/explore

Flickr Geo queries not returning any data

I cannot get the Flickr API to return any data for lat/lon queries.
view-source:http://api.flickr.com/services/rest/?method=flickr.photos.search&media=photo&api_key=KEY_HERE&has_geo=1&extras=geo&bbox=0,0,180,90
This should return something, anything. Doesn't work if I use lat/lng either. I can get some photos returned if I lookup a place_id first and then use that in the query, except then all the photos returned are from anywhere and not the place id
Eg,
http://api.flickr.com/services/rest/?method=flickr.photos.search&media=photo&api_key=KEY_HERE&placeId=8iTLPoGcB5yNDA19yw
I deleted out my key obviously, replace with yours to test.
Any help appreciated, I am going mad over this.
I believe that the Flickr API won't return any results if you don't put additional search terms in your query. If I recall from the documentation, this is treated as an unbounded search. Here is a quote from the documentation:
Geo queries require some sort of limiting agent in order to prevent the database from crying. This is basically like the check against "parameterless searches" for queries without a geo component.
A tag, for instance, is considered a limiting agent as are user defined min_date_taken and min_date_upload parameters — If no limiting factor is passed we return only photos added in the last 12 hours (though we may extend the limit in the future).
My app uses the same kind of geo searching so what I do is put in an additional search term of the minimum date taken, like so:
http://api.flickr.com/services/rest/?method=flickr.photos.search&media=photo&api_key=KEY_HERE&has_geo=1&extras=geo&bbox=0,0,180,90&min_taken_date=2005-01-01 00:00:00
Oh, and don't forget to sign your request and fill in the api_sig field. My experience is that the geo based searches don't behave consistently unless you attach your api_key and sign your search. For example, I would sometimes get search results and then later with the same search get no images when I didn't sign my query.