Cities

Retrieve information about world cities, including coordinates, population, and administrative hierarchy. Cities are identified by GeoNames IDs—the closest thing to a global standard for city identification. We do not guarantee ID stability; GeoNames may reassign or merge IDs over time.

Standards Used

  • ISO 3166-1
  • ISO 3166-2
  • IANA TZDB
  • GeoNames

Ambiguous Names#

Name lookups return null when ambiguous. "Springfield", for example, matches 35+ US cities. Use the list endpoint with country or region filters for common names.

The City object#

FieldTypeRequiredDescription
countrystringYesCountry (alpha-2 code).
Example: JP
idinteger (int32)YesGeoNames ID.
Example: 1850147
is_capitalbooleanYesWhether this is a national capital.
Example: true
latitudenumber (double)YesLatitude in decimal degrees.
Example: 35.6762
longitudenumber (double)YesLongitude in decimal degrees.
Example: 139.6503
namestringYesCity name.
Example: Tokyo
populationinteger (int32)YesPopulation estimate.
Example: 13960000
regionstringNoRegion (ISO 3166-2 code).
Example: JP-13
timezonestringYesIANA timezone.
Example: Asia/Tokyo

Endpoints#

Query Parameters

ParameterTypeRequiredDescription
countryquerystringNoFilter by country (alpha-2 code).
Example: US
regionquerystringNoFilter by region (ISO 3166-2 code).
Example: US-CA
pagequeryintegerNoPage number (1-indexed).
Example: 1
per_pagequeryintegerNoNumber of results per page.
Example: 20

Response

FieldTypeRequiredDescription
dataobject[]YesThe data items for this page.
paginationobjectYes Pagination metadata in response.
pageintegerYesCurrent page number.
Example: 1
per_pageintegerYesItems per page.
Example: 20
total_itemsintegerYesTotal number of items.
Example: 100
total_pagesintegerYesTotal number of pages.
Example: 5

Example Request

const response = await fetch(
  'https://worlddataapi.com/v1/cities?country=US&region=US-CA',
  {
    headers: {
      'X-API-Key': 'YOUR_API_KEY'
    }
  }
);

const data = await response.json();

Error Responses

StatusDescription
400Missing country or region parameter
404Country or region not found
429Rate limit exceeded

Path Parameters

ParameterTypeRequiredDescription
identifierpathstringYesGeoNames ID (numeric) or city name

Response

FieldTypeRequiredDescription
countrystringYesCountry (alpha-2 code).
Example: JP
idinteger (int32)YesGeoNames ID.
Example: 1850147
is_capitalbooleanYesWhether this is a national capital.
Example: true
latitudenumber (double)YesLatitude in decimal degrees.
Example: 35.6762
longitudenumber (double)YesLongitude in decimal degrees.
Example: 139.6503
namestringYesCity name.
Example: Tokyo
populationinteger (int32)YesPopulation estimate.
Example: 13960000
regionstringNoRegion (ISO 3166-2 code).
Example: JP-13
timezonestringYesIANA timezone.
Example: Asia/Tokyo

Example Request

const response = await fetch(
  'https://worlddataapi.com/v1/cities/example',
  {
    headers: {
      'X-API-Key': 'YOUR_API_KEY'
    }
  }
);

const data = await response.json();

Error Responses

StatusDescription
400Ambiguous city name
404City not found