Menu

GeoDB Cities API

handling deleted cities

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

But 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

Below we return all cities, including those that may have been marked deleted in the last 24 hours.

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(includeDeleted:SINCE_YESTERDAY, first:10) {
    totalCount
    pageInfo{
      startCursor
      endCursor
      hasNextPage
    }
    edges {
      node {
        id
        name
      }   
    }
  }
}

REST

curl --get --include 'https://wft-geo-db.p.rapidapi.com/v1/geo/cities?includeDeleted=SINCE_YESTERDAY&offset=0&limit=10' \
    -H 'x-rapidapi-key: YOUR_API_KEY' \
    -H 'x-rapidapi-host: wft-geo-db.p.rapidapi.com'