Skip to Content
Version 0.0.1 is released 🎉

Cities Data

Get All Cities

This gives you an array of all cities.

cities.ts
import { Cities } from 'countries-geo'; console.log(Cities.getAll); // Logs all Cities (e.g., [{ iso: "GH-AA-ACH", name: "Achimota" }, ...])

By default this is sorted by name.

Get All Cities sorted by isoCode

This gives you an array of all cities specifically sorted by isoCode.

cities.ts
import { Cities } from 'countries-geo'; console.log(Cities.sortByIsoCode); // Logs all Cities (e.g., [{ iso: "GH-AA-ACH", name: "Achimota" }, ...])

By default this is sorted by iso.

Get Cities by State

This gives you an array of all cities filtered by a State isoCode.

cities.ts
import { Cities } from 'countries-geo'; console.log(Cities.getByState('GH-AA')); // Logs all Cities (e.g., [{ iso: "GH-AA-ACH", name: "Achimota" }, ...])

By default this is sorted by name.

Get Cities by Country

This gives you an array of all cities filtered by a Country isoCode.

cities.ts
import { Cities } from 'countries-geo'; console.log(Cities.getByCountry('GH')); // Logs all Cities (e.g., [{ iso: "GH-AA-ACH", name: "Achimota" }, ...])

By default this is sorted by name.

Get Cities by Continent

This gives you an array of all cities filtered by a Continent isoCode.

cities.ts
import { Cities } from 'countries-geo'; console.log(Cities.getByContinent('AF')); // Logs all Cities (e.g., [{ iso: "GH-AA-ACH", name: "Achimota" }, ...])

By default this is sorted by name.

Last updated on