Cities Data
Get All Cities
This gives you an array of all cities.
ES6 Module
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.
ES6 Module
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.
ES6 Module
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.
ES6 Module
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.
ES6 Module
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