Menu

GeoDB City API - Find Cities For Your Criteria | Wirefree Thought

header photo

handling deleted cities

Part of the benefit of using GeoDB is it will periodically refresh its city database with the latest GeoNames.org data. As part of this refresh, some cities will be marked deleted. (Usually because they were determined to be duplicates.)

Now never fear: You will ALWAYS be able to retrieve a city by id obtained through some prior call to get cities. GeoDB will never actually physically delete the record, only mark it as deleted.

However, when requesting city collections, GeoDB will by default exclude cities marked deleted. This means that in the unlikely event that GeoDB marks one or more cities as deleted as your user is paging through a set of city results, your app paging widget may end up in an inconsistent state.

To guard against this, when paging city results, set the includeDeleted param to one of the following self-explanatory options:

  • ALL
  • SINCE_YESTERDAY
  • SINCE_LAST_WEEK

For example, to return all cities, including those that may have been deleted in the last 24 hours:

curl --get --include 'https://wft-geo-db.p.mashape.com/v1/geo/cities?includeDeleted=SINCE_YESTERDAY&offset=0&limit=10' \
    -H 'X-Mashape-Key: YOUR_API_KEY' \
    -H 'X-Mashape-Host: wft-geo-db.p.mashape.com'