With Everbase, you can access a dataset of the world's cities over a GraphQL API. We provide the
world's top 10.000 citities by population, which includes even very small cities. There are many
ways to access them. The most direct way is to use the cities
field on the query root. It can take
various parameters to narrow down the results.
Here's a query that returns the largest cities of the world, with a population of 20 million or more.
{
cities(where: {population: {gt: 20000000}}) {
name
population
country {
name
}
}
}
gt
in this query stands for greater than
. Other options include lt
and eq
, can you guess
what they stand for?
When you run this query, you get:
{
"data": {
"cities": [
{
"name": "Lagos",
"population": 21324000,
"country": {
"name": "Nigeria"
}
},
{
"name": "Beijing",
"population": 21710000,
"country": {
"name": "People's Republic of China"
}
},
{
"name": "Shanghai",
"population": 23390000,
"country": {
"name": "People's Republic of China"
}
}
]
}
}
Impressive, right? We can't even imagine what it is like to live in a city that big.
There are other ways to access cities. We can get all cities of a country by accessing the country first:
{
countries(where: {name: {eq: "Denmark"}}) {
cities {
name
}
}
}
To try these queries, click on editor in the top bar. But you'll probably trust us when we say the above returns all cities in Denmark.
Another way to access a city is to use our IP geolocation. Like this:
{
client {
ipAddress {
city {
name
timeZone
}
}
}
}
This relies on the GeoIP2 database, which isn't perfect. But it should work most of the time.
Want to know more about cities and the fields you can access on them? Check the City reference. To try your own queries, use the editor.