How does foursquare's nearby friends functionality work? - foursquare

I'm working on a location rating functionality that uses the foursquare API, and would like my result to be based on the user's current region. The same way Foursquare divides users in the nearby friends. Does Foursquare use a certain radius based on your location? And if they are, what radius is it?

Foursquare considers a friend to be in the "same city" as you if the friend is within 40 kilometers.

Related

Similar venues with location foursquare API

I am playing with Foursquare API and I was wondering if theres an endpoint for getting a similar venue in a location given another venue?
All I found is this endpoint:
https://api.foursquare.com/v2/venues/VENUE_ID/similar
Which returns a list of venues similar to a given venue. What I want is, exactly this but I want the returned venues be close to a given location.
For example:
I love a mexican restaurant in London.
I want to find a similar restaurant but in Barcelona.
Is that possible?
Thanks!
The venues/similar endpoint will only show similar venues near the desired venue. Your best bet is probably using the query parameter with venues/explore. The query parameter is pretty smart about determining your intent if you know what you're looking for and you can specify any location.
i.e.
https://api.foursquare.com/v2/venues/explore?
query=Mexican food outdoor seating
near=Barcelona

Cannot find restaurant using /venue/search end-point

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.

How to increase Foursquare Venue limit for getting all restaurants from Foursquare Venue API?

I am calling Foursquare Venue API for getting all food venues of London.
Used API is: https://api.foursquare.com/v2/venues/explore?ll=51.51121389999999,-0.11982439999997041&section=xxxx&**limit=11000**&oauth_token=xxxx
It returns always random 100 venues. If I call it next time then it returns same venues instead of unique 100 venues.
How to get unique records for getting all venues? How to get all venues by increasing the limit?
The maximum number of venues returned in an explore query can be found in our documentation: https://developer.foursquare.com/docs/venues/explore
Getting all the food venues in any geographic region isn't really something the Foursquare API is designed to do, but you can get different results if you modify your ll and/or radius params. Please keep in mind our developer policies against scraping though if you choose to do a sweeping approach.

Foursquare API: Search venues in whole city

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.

Getting locations of user's friends with Foursquare API

Is it possible to get the nearby locations of a user's friends, or, when searching for nearby venues, determine how many friends are present at each of the venues?
In other words, I would like to list all nearby venues along with a count of friends here now. Can this be done without making venue detail calls on all of the venues?
Friend information is not currently accessible via the /venues/search endpoint -- only the total number of users at the venue.
As you mentioned, you can call the /venues/VENUE_ID/herenow endpoint to get more information (including friend vs. non-friend) breakdowns for the returned venues.
You can, alternatively, make a single call to /checkins/recent and combine the data about current friend location with /venues/search results.

Resources