Getting The User's Current Place
First, you will need to determine the user's current GPS location. For this, we recommend you use the GeoLocation API. Most modern browsers now provide an implementation of it. (But if you're worried, check here for browser compatibility status.)
Below we find the largest (most relevant) place within a radius of 20 miles of location {25.761681,-80.191788}.
GraphQL
curl --request POST \ --url https://geodb-cities-graphql.p.rapidapi.com/ \ --header 'content-type: application/json' \ --header 'x-rapidapi-host: geodb-cities-graphql.p.rapidapi.com' \ --header 'x-rapidapi-key: YOUR_API_KEY' \ --data '{"query":"QUERY"}'
Where QUERY:
{ populatedPlaces( location:{latitude:25.761681, longitude:-80.191788} radius:20 distanceUnit:MI sort:"-population" first:1 ) { edges { node { id name } } } }
REST
curl --get --include 'https://wft-geo-db.p.rapidapi.com/v1/geo/locations/25.761681-80.191788/nearbyPlaces?radius=20&distanceUnit=MI&sort=-population&offset=0&limit=1' \ -H 'x-rapidapi-key: YOUR_API_KEY' \ -H 'x-rapidapi-host: wft-geo-db.p.rapidapi.com'