# World Cities Scraper - GeoDB Cities, Regions & Population (`ninhothedev/world-cities-scraper`) Actor

$0.35/1K 🔥 World Cities Scraper! Get city names, countries, coordinates, population & regions worldwide. No key. JSON, CSV, Excel or API in seconds. Feed a geo-autocomplete, map or location dataset ⚡

- **URL**: https://apify.com/ninhothedev/world-cities-scraper.md
- **Developed by:** [ninhothedev](https://apify.com/ninhothedev) (community)
- **Categories:** Developer tools, Travel, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.35 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## World Cities & Regions Scraper (GeoDB)

Search a database of **world cities** and get clean, structured records with
**population, coordinates, region, country code and timezone** — plus a full
**country list**. Powered by the keyless [GeoDB free service], so there is **no
API key** to manage. Great for **location autocomplete, market sizing,
logistics routing and travel apps**.

Pricing is pay-as-you-go and typically lands around **~$0.50 per 1,000 records**.

[GeoDB free service]: http://geodb-free-service.wirefreethought.com/

### What you get

Every city record:

| Field | Example |
|-------|---------|
| `name` | `Santiago` |
| `country` / `country_code` | `Chile` / `CL` |
| `region` / `region_code` | `Santiago Metropolitan` / `RM` |
| `population` | `6257516` |
| `latitude` / `longitude` | `-33.44` / `-70.65` |
| `timezone` | `America__Santiago` *(with `enrichDetail`)* |
| `elevation_m` | `520` *(with `enrichDetail`)* |
| `wikidata_id` / `url` | `Q2887` / `https://www.wikidata.org/wiki/Q2887` |

### Modes

- **cities** — searchable city list. Filter by `namePrefix`, `countryCode`
  and `minPopulation`. Sorted by population (largest first).
- **countries** — the GeoDB country list with `currency_codes`.

### Input

| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `mode` | select | `cities` | `cities` or `countries`. |
| `namePrefix` | string | — | Cities only. Name starts-with filter, e.g. `San`. |
| `countryCode` | string | — | Cities only. 2-letter ISO code, e.g. `DE`. |
| `minPopulation` | integer | `0` | Cities only. Minimum inhabitants, e.g. `500000`. |
| `enrichDetail` | boolean | `false` | Cities only. One extra call per city for `timezone` + `elevation_m`. |
| `maxItems` | integer | `200` | Max records (hard cap `2000`). |

#### Example input

```json
{
  "mode": "cities",
  "namePrefix": "San",
  "minPopulation": 500000,
  "maxItems": 100
}
```

### Example output

```json
{
  "type": "city",
  "city_id": 7118,
  "wikidata_id": "Q64",
  "name": "Berlin",
  "country": "Germany",
  "country_code": "DE",
  "region": "Berlin",
  "region_code": "BE",
  "latitude": 52.51,
  "longitude": 13.38,
  "population": 3913644,
  "elevation_m": null,
  "timezone": null,
  "url": "https://www.wikidata.org/wiki/Q64",
  "source": "geodb",
  "scraped_at": "2026-08-11T00:00:00+00:00"
}
```

### Free-host rate limit

This actor uses the **keyless GeoDB free service host**, which rate-limits to
roughly **1 request per second**. The actor paces requests (~1.1s) and handles
HTTP `429` responses gracefully. Because of this, keep `enrichDetail` off for
large pulls — it adds one request per city. For very high volumes, consider the
paid GeoDB RapidAPI tier.

### How this differs from our other location actors

This is a **searchable world CITIES database** — you query by name / country /
population and get city-level facts (population, coordinates, region, timezone).
It answers *"which cities match X, and how big are they?"*. Our related actors
solve different problems:

- **[zip-code-scraper]** — postal/ZIP code lookups (ZIP → place, or place → ZIPs).
- **[geocoding-scraper]** — address ↔ coordinates geocoding & reverse geocoding.
- **[country-profiles-scraper]** — one rich profile per country (flags, capital,
  languages, currencies, borders), not city-level data.
- **[postal-code-scraper]** — bulk postal-code datasets.

Use **this** actor when you need **cities with population and coordinates**, not
per-address geocoding or per-country profiles.

### Use cases

- **Location autocomplete** — power a city picker with `namePrefix`.
- **Market sizing** — pull all cities above a population threshold per country.
- **Logistics & routing** — city coordinates and regions for coverage planning.
- **Travel apps** — timezones, coordinates and Wikidata links for destinations.

### Related actors

- [geocoding-scraper](https://apify.com/ninhothedev/geocoding-scraper)
- [zip-code-scraper](https://apify.com/ninhothedev/zip-code-scraper)
- [country-profiles-scraper](https://apify.com/ninhothedev/country-profiles-scraper)
- [postal-code-scraper](https://apify.com/ninhothedev/postal-code-scraper)

[zip-code-scraper]: https://apify.com/ninhothedev/zip-code-scraper

[geocoding-scraper]: https://apify.com/ninhothedev/geocoding-scraper

[country-profiles-scraper]: https://apify.com/ninhothedev/country-profiles-scraper

[postal-code-scraper]: https://apify.com/ninhothedev/postal-code-scraper

# Actor input Schema

## `mode` (type: `string`):

What to scrape. 'cities' returns a searchable list of world cities (population, coordinates, region, country, timezone). 'countries' returns the GeoDB country list with currency codes.

## `namePrefix` (type: `string`):

Cities mode only. Return only cities whose name starts with this prefix, e.g. 'San' or 'Ber'. Leave empty to match all cities. Great for location autocomplete.

## `countryCode` (type: `string`):

Cities mode only. Restrict results to one country by its 2-letter ISO code, e.g. 'DE' for Germany or 'US' for the United States. Leave empty for worldwide results.

## `minPopulation` (type: `integer`):

Cities mode only. Only return cities with at least this many inhabitants. Use a value like 500000 to get only major cities. Default 0 (no minimum).

## `enrichDetail` (type: `boolean`):

Cities mode only. When enabled, makes one extra request per city to fetch timezone and elevation. Slower (the free host is rate-limited to ~1 request/second), so keep maxItems modest when using this.

## `maxItems` (type: `integer`):

Maximum number of records to return. Results are paginated automatically. Default 200, hard cap 2000.

## Actor input object example

```json
{
  "mode": "cities",
  "namePrefix": "San",
  "countryCode": "DE",
  "minPopulation": 0,
  "enrichDetail": false,
  "maxItems": 200
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("ninhothedev/world-cities-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("ninhothedev/world-cities-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call ninhothedev/world-cities-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ninhothedev/world-cities-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/c3PZbaPhXCYhPPwWb/builds/t151uoexlCg8gkGMh/openapi.json
