GeoDB Cities API

Getting the user's current city

1. 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.)

2. Now find the largest (most relevant) city within a radius of say 20 miles of the location you determined:

curl --get --include '{locationId}/nearbyCities?radius=20&distanceUnit=MI&sort=-population=offset=0&limit=1' \
    -H 'X-Mashape-Key: YOUR_API_KEY' \
    -H 'X-Mashape-Host:'


locationIdLatitude/longitude in ISO-6709 format: ±DD.DDDD±DDD.DDDD


Some things to note:

  • We set sort=-population to get the largest cities first.
  • We set limit=1 since we're only interested in the top-most result.