Getting a List of Locations

Learn how to get a list of top cities worldwide and countries within a given region.

The Locations API allows us to get detailed information about places around the globe. Among other information, it provides the unique key for each location as well. This key is important since we'll use it in the coming lessons to invoke other APIs to get various kinds of weather data.

In this lesson, we'll learn how to get a specified number of top cities around the globe with detailed information. Moreover, we'll also learn how to get a list of all countries from a given region, along with their basic information.

List the top cities in the world

The Top Cities List endpoint allows us to retrieve a list of the top cities in the world. The ranking of the cities is based on a number of factors including, but not limited to, the population of the city, its political importance, and its geographic size. This endpoint provides detailed information for each city, including its geographical position, timezone, and population. Using this endpoint, we can retrieve information for the top 50, 100, or 150 cities worldwide.

Let's make a GET request to the following URL to get a list of a certain number of top cities around the world:

Get hands-on with 1200+ tech skills courses.