# Cities Lookup API

> Cities Lookup is a city search API that searches about 135,000 cities worldwide by name to find country codes, population counts and city size classifications, with an optional country filter. Paid plans add region codes, capital status, GeoJSON coordinates and up to 20 matches per search.

**Endpoint:** `GET https://api.apiverve.com/v1/citieslookup`  
**Category:** Geography  
**Cost:** 2 credits per call  
**Canonical page:** https://apiverve.com/marketplace/citieslookup

## Overview

A cities API built on GeoNames: every place in the world with at least 1,000 residents, about 135,000 cities. Pass a city name, optionally narrowed to a two-letter country code, and it matches every city whose name contains your text, ranks them by population and drops repeats of the same name in the same country. Each match has its name, alternative name, country code and name, GeoNames feature code, population and a size category from village to major. The Free plan returns the most populous match; paid plans return up to 20 and add the region (admin1) code, a capital-city flag and longitude-latitude coordinates.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl "https://api.apiverve.com/v1/citieslookup?city=San%20Francisco&country=US&limit=5" \
  -H "x-api-key: YOUR_API_KEY"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `city` | string | Yes | The city name to look up (e.g., New York). Accents are optional (Zurich finds Zürich), common former and informal names work (Bombay, Saigon, NYC), and a trailing ", ST" or ", Country" narrows the match (Dallas, TX or London, Canada) |
| `country` | string | No | Two-letter ISO country code to restrict matches to one country (e.g., US). length 2-2 |
| `limit` | integer | No | Limit number of cities that match your search criteria. default 1. range 1-20. Premium field |

## Response fields

- `search` — string · The search query used to find cities
  - `foundCities.0.name` — string · Official city name
  - `foundCities.0.altName` — string · Alternative city name or alias if available
  - `foundCities.0.country` — string · Two-letter ISO country code (e.g., US)
  - `foundCities.0.featureCode` — string · Geonames feature code for city classification type
  - `foundCities.0.population` — number · City population as published by GeoNames
  - `foundCities.0.loc` — object
    - `foundCities.0.loc.type` — string · GeoJSON geometry type (always Point)
    - `foundCities.0.loc.coordinates` — array · GeoJSON coordinates as [longitude, latitude] pair · (premium)
  - `foundCities.0.regionCode` — string · GeoNames first-level administrative (admin1) code: the state abbreviation in the US (e.g., CA), a numeric or letter code elsewhere; null when unknown · (premium)
  - `foundCities.0.countryName` — string · Full country name (e.g., United States)
  - `foundCities.0.populationCategory` — string · City size classification based on population ranges
  - `foundCities.0.isCapital` — boolean · Whether the city is its country's capital (GeoNames feature code PPLC) · (premium)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "search": "San Francisco",
    "foundCities": [
      {
        "name": "San Francisco",
        "altName": "",
        "country": "US",
        "featureCode": "PPLA2",
        "population": 864816,
        "loc": {
          "type": "Point",
          "coordinates": [
            -122.41942,
            37.77493
          ]
        },
        "regionCode": "CA",
        "countryName": "United States",
        "populationCategory": "large",
        "isCapital": false
      }
    ]
  }
}
```

## Use cases

- **Checkout Address Validation** — When customers enter a city name during checkout, match official country codes and alternative names to standardize shipping records.
- **Retail Expansion Sizing** — Retail analysts evaluate new store candidates by querying population figures and city size categories across international regions.
- **Fleet Dispatch Routing** — For regional delivery scheduling, dispatchers convert destination city names into exact longitude and latitude coordinates on paid tiers.
- **Travel Destination Filtering** — To help users discover vacation spots, travel search engines group destinations by population tier and resolve local alias spellings.

## SDKs

- **npm** — `npm install @apiverve/citieslookup` (https://www.npmjs.com/package/@apiverve/citieslookup)
- **PyPI** — `pip install apiverve-citieslookup` (https://pypi.org/project/apiverve-citieslookup/)
- **NuGet** — `dotnet add package APIVerve.API.CitiesLookup` (https://www.nuget.org/packages/APIVerve.API.CitiesLookup)
- **Source** — https://github.com/apiverve/citieslookup-api

## More

- Full reference: https://docs.apiverve.com/ref/citieslookup
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
