New Jango Tester
New Jango Tester

Reputation: 559

How to sort result from foursquare place api according to distance?

I am fetching nearby restaurants from foursquare API, i am getting json which contains details of restaurants.it has the "distance=XX".How can I get the result as least distance on first index of array ?

I found something - "intent=match".But dont know how to give that in the below url Please help me.Thanks in advance

https://api.foursquare.com/v2/venues/search?radius=500&ll=10.00915,76.318738&limit=50&client_id=CLIENT_ID&v=YYYYMMDD&client_secret=CLIENT_SECRET&categoryId=4d4b7105d754a06374d81259

Upvotes: 1

Views: 1845

Answers (1)

octopi
octopi

Reputation: 2004

intent=match is very sensitive to the location and query you pass in, and it's generally used to find exact matches of what you're looking for (e.g., Joe's Coffeeshop right at this precise lat/lon). This may or may not be what you're looking for, but you use it just by adding it as another parameter to your API call, much like how you added categoryId.

In general, using intent=checkin (which is what the call defaults to) should be sufficient depending on your exact requirements. It returns results sorted by distance but also takes into account how likely someone is to check in there so sometimes the first result is not strictly the closest.

Upvotes: 1

Related Questions