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
Related
I'm new to all this, but I was wanting to know how I can view popular Foursquare venues by using a longitude and latitude but also narrowing the search by specifying the exact amount of checkins at a place and also providing the radius.
I've figured out how to do some of the URL but don't know what to type exactly to specify the minimum amount of checkins.
"https://api.foursquare.com/v2/venues/search/?ll= 42.973423,-83.738894&radius=200"
That is what my URL is looking like, now I need help figuring out the last bit of information.
It's not possible to define a minimum number of checkins as a search parameter for the /v2/venues/search endpoint.
The response of /v2/venues/search request contains a stats field with a checkinsCount property. This would allow you to filter the results based on a checkinsCount threshold.
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
I'm noticing something odd with foursquare search API. When I specify a latitude and longitude of a location in my city, I'm not getting venues that are closest to me.
For search parameters I'm using:
ll = 47.620918,-122.318455 (a neighborhood in Seattle, WA)
intent = browse
radius = 48 280 (approx 30 miles)
categoryId = 4d4b7105d754a06374d81259 (food), 4d4b7105d754a06376d81259 (nightlife)
venues/search?ll=47.620918,-122.318455&intent=browse&radius=42820&categoryId=4d4b7105d754a06374d81259,4d4b7105d754a06376d81259
I would expect this query to return me venues that are closest to the specified lat+long location and in the food or nightlife categories. This isn't what I'm seeing. Instead, the first venue in the array is a venue that is 768 meters away, the second is 2162 meters, the third is 722 meters.
There are food and nightlife venues that are much closer than 700 meters to that latitude and longitude.
One could argue that I should take the results and sort them myself based on the distance attribute but this seems flawed for 2 reasons:
If the venue list being returned isn't closest to my location, I'm missing out on a lot of venues since they couldn't all fit within the max limit of the query results. So even if I sorted based on distance attribute, I'm only sorting venues that shouldn't be considered nearby.
The reason I specify a lat+long to the search API is to have foursquare do the heavy lifting for me on what is "nearby". If I need to sort then what's the point? There's an argument to be made that foursquare shouldn't return venues that are more relevant to you, but this is why I'm using intent=browse instead of intent=checkin'
For intent=browse, the docs say:
Find venues within a given area. Unlike the checkin intent, browse searches an entire region instead of only finding Venues closest to a point.
what am I doing wrong such that I'm not getting the closest venues return to the specified lat+long?
Just like the docs say, when you use intent=browse, Foursquare doesn't "only [find] Venues closest to a point." When you use intent=browse with a ll/radius, imagine this as setting up a region and asking Foursquare for the "best" results from this region. It is not saying "find me the results starting at this ll growing until the radius."
In general, Foursquare search does not guarantee results in any particular order unless it's specified under the description for the intent, and unfortunately none of these specify that the results will be returned sorted by increasing radius.
I know this is a old thread, just wanted to let people know that you can use sortByDistance=1 as parameter to sort venues the closest to the location.
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
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.