Menu

GeoDB Cities API

Comments

There are currently no blog comments.

GraphQL Is Here!

GeoDB now supports GraphQL queries. GraphQL is a relatively new technology, originally developed by Facebook as an efficient way of querying the complex relationships inherent in their social domain model.

GraphQL's primary advantage over REST is the ability to get back exactly what you want - and only what you want - in a single request.

For example, this query gets back the US flag image URI, its region names, and the names and populations of the cities in each region, with the regional cities sorted by larger population first:

{
  country(id:"US") {
    name
    flagImageUri
    regions(first:3) {
      totalCount
      pageInfo {
        startCursor
        endCursor
        hasNextPage
      }
      edges {
        node {
          wikiDataId
          name
          populatedPlaces(types:["CITY"], sort:"-population", first:3) {
            totalCount
            pageInfo {
              startCursor
              endCursor
              hasNextPage
            }
            edges {
              node {
                id
                wikiDataId
                name
                population
              }
            }
          }
        }
      }
    }
  }
}

The REST version of this would require one request to get the country details, one to get the regions, one for each region to get its cities (3), then one for each city to get its population details (9) - for a total of 14 requests! The REST version will also give you back a lot of fields you don't care about.

Please have a look at the updated portal docs illustrating the difference between REST and GraphQL calls and give the new API a spin.

To see what's possible with the new GeoDB GraphQL API, check out the full schema docs.

Feedback is welcome!

 

Go Back

Comment