How to accurately find a place by latitude and longitude using Foursquare/any other free API?

364 Views Asked by At

I'm trying to find user's location using Foursquare API.

The thing is, its database is quite limited, so sometimes it returns the nearest place which might be 100 meters away. It might be correct if a user is at the park or any other place with huge area. But it will be completely incorrect if a user is 100 meters away from a small cafe for exapmle.

Is there any way to check if a user is really withing the territory of a place using only Foursquare? What other free geolocation API I can use to get accurate results?

I tried to play around and sort the list of the results by distance - it didn't help much. Also I checked all information about a certain place Foursquare provides. I hoped to find some information about the area of a location which would be really helpful - didn't find anything.

1

There are 1 best solutions below

0
jnv On

I assume Foursquare's limitation comes from the fact they are more focused on places of interest rather than generic reverse geocoding. So if you are primarily aiming at accuracy, I recommend looking into geocoding / reverse geocoding APIs.

Most geocoding providers have a free tier, so depending on how many requests you make, you can stay within the free usage. Check for example: Here.com, OpenCage, or TomTom. Nominatim by OpenStreetMap is even free for non-commercial use.

[Disclaimer: self-promo, I work for Superface] We wrote a comparison of these providers, and if you are using Node.js, we have also an SDK which provides a unified interface for all of them (and other APIs). The usage for reverse geocoding looks like this:

const { SuperfaceClient } = require('@superfaceai/one-sdk');
const sdk = new SuperfaceClient();

async function run() {
  const profile = await sdk.getProfile('address/geocoding');
  const result = await profile
    .getUseCase('ReverseGeocode')
    .perform({
      latitude: 37.423199,
      longitude: -122.084068
    });

  return result.unwrap();
}

There are other generic (reverse) geocoding libraries, like node-geocoder and geopy for Python.