# Zip Code Scraper - Postal Code Lookup by City, State & Country (`ninhothedev/zip-code-scraper`) Actor

$0.25/1K 🔥 Fast zip/postal code scraper! Place, state, lat/lon for 60+ countries — forward & reverse. No key. JSON, CSV, Excel or API in seconds. Paste zips or cities & enrich thousands for address validation & logistics ⚡

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

## Pricing

from $0.25 / 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

## Zip / Postal Code Scraper 🌍📮

**Look up any postal / zip code and get the place name, state, latitude and longitude — for 60+ countries. Or reverse it: give a city and get every postcode inside it.** Fast, free data source, no API key, works on datacenter proxies (or none at all).

Perfect for **address validation, geocoding, logistics & routing, shipping-form autofill, and enriching customer records** — at a fraction of the cost of paid geocoding APIs.

***

### ✨ What it does

Two modes, one Actor:

| Mode | You give | You get |
|------|----------|---------|
| **`postcodes`** | Country + list of zip/postal codes | One row per place: `place_name`, `state`, `state_code`, `latitude`, `longitude` |
| **`cities`** (reverse) | Country + state code + list of city names | One row per postcode inside that city, with coordinates |

Coverage spans **60+ countries** — US, DE, GB, FR, ES, IT, NL, CA, AU, BR, IN, MX, and many more. Country codes are the usual 2-letter ISO codes (`us`, `de`, `gb`, ...).

***

### 🚀 Quick start

#### Postcodes → places

```json
{
  "mode": "postcodes",
  "country": "us",
  "postcodes": ["90210", "10001"],
  "maxItems": 100
}
```

Sample output row:

```json
{
  "country": "United States",
  "country_code": "US",
  "post_code": "90210",
  "place_name": "Beverly Hills",
  "state": "California",
  "state_code": "CA",
  "latitude": 34.0901,
  "longitude": -118.4065,
  "scraped_at": "2026-07-03T00:00:00+00:00"
}
```

#### City → postcodes (reverse)

```json
{
  "mode": "cities",
  "country": "us",
  "state": "CA",
  "cities": ["Los Angeles"],
  "maxItems": 500
}
```

Sample output row:

```json
{
  "country": "United States",
  "country_code": "US",
  "state": "California",
  "city": "Los Angeles",
  "post_code": "90001",
  "place_name": "Los Angeles",
  "latitude": 33.9731,
  "longitude": -118.2479,
  "scraped_at": "2026-07-03T00:00:00+00:00"
}
```

***

### ⚙️ Input reference

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `mode` | select | `postcodes` | `postcodes` (codes → places) or `cities` (city → codes, reverse). |
| `country` | string | `us` | 2-letter lowercase ISO country code. |
| `postcodes` | array | `["90210","10001"]` | Zip/postal codes to look up (used in `postcodes` mode). |
| `state` | string | — | State / region code, e.g. `CA` (required in `cities` mode). |
| `cities` | array | `["Los Angeles"]` | City names to reverse-look-up (used in `cities` mode). |
| `maxItems` | integer | `100` | Max output rows. Hard-capped at 1000. |

***

### 📦 Output

Clean, flat **JSON** — one item per place/postcode, ready to export to **JSON, CSV, Excel, HTML, or via API**. Every field is nullable, so downstream schemas never break on missing data.

***

### 💸 Pricing

Roughly **~$0.50 per 1,000 input lookups** in platform usage — dramatically cheaper than commercial geocoding APIs that charge per request with monthly minimums. You only pay for the compute you use; there are no data-source fees or API keys.

***

### 🆚 Why this vs. a paid geocoding API?

| | This Actor | Typical paid geocoder |
|---|---|---|
| API key | ❌ none | ✅ required |
| Monthly minimum | ❌ none | 💰 often |
| Reverse city → postcodes | ✅ built-in | ⚠️ rarely |
| Cost per 1k | ~$0.50 | $$$ |
| Export CSV/Excel/JSON/API | ✅ | varies |

Great when you need **bulk, batch postal-code enrichment** rather than real-time single lookups.

***

### 🎯 Use cases

- **Address validation** — confirm a zip belongs to the claimed city/state.
- **Geocoding** — turn postal codes into latitude/longitude for maps and distance math.
- **Logistics & routing** — build coverage areas, assign delivery zones, plan routes.
- **Signup & checkout forms** — autofill city/state from a zip; reverse-suggest zips for a city.
- **CRM / data enrichment** — append coordinates and region names to customer records.

***

### 🔗 Related Actors by this author

- 🧭 [Geocoding Scraper](https://apify.com/ninhothedev/geocoding-scraper) — addresses ⇄ coordinates.
- 🌐 [Countries Data Scraper](https://apify.com/ninhothedev/countries-data-scraper) — country facts, currencies, languages.
- 📍 [IP Geolocation Scraper](https://apify.com/ninhothedev/ip-geolocation-scraper) — locate IP addresses.
- ☀️ [Weather Scraper](https://apify.com/ninhothedev/weather-scraper) — forecasts by location.

***

### 🛟 Support

Questions, a country that misbehaves, or a feature request? Open an issue on the Actor page or contact the author through Apify. Response is usually within one business day.

***

### 🔎 Keywords

`zip code scraper` · `postal code lookup` · `postcode api` · `zip to lat long` · `city to zip code` · `geocoding` · `address validation` · `reverse postal lookup` · `zippopotam` · `postal code database` · `zip code coordinates` · `logistics data`

# Actor input Schema

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

Choose the lookup direction. 'postcodes' resolves a list of postal/zip codes to their place name, state and coordinates. 'cities' reverse-looks-up every postcode inside a city (requires a state code).

## `country` (type: `string`):

2-letter lowercase ISO country code (e.g. 'us', 'de', 'gb', 'fr'). Applies to both modes.

## `postcodes` (type: `array`):

List of postal/zip codes to look up. Used only in 'postcodes' mode. One item is produced per matched place.

## `state` (type: `string`):

State or region code used for the reverse 'cities' lookup (e.g. 'CA' for California). Required in 'cities' mode.

## `cities` (type: `array`):

List of city names to reverse-look-up into postcodes. Used only in 'cities' mode (e.g. 'Los Angeles'). City names are URL-encoded automatically.

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

Maximum number of output items (places / postcodes) to store. Hard-capped at 1000.

## Actor input object example

```json
{
  "mode": "postcodes",
  "country": "us",
  "postcodes": [
    "90210",
    "10001"
  ],
  "cities": [
    "Los Angeles"
  ],
  "maxItems": 100
}
```

# 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 = {
    "postcodes": [
        "90210",
        "10001"
    ],
    "cities": [
        "Los Angeles"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ninhothedev/zip-code-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 = {
    "postcodes": [
        "90210",
        "10001",
    ],
    "cities": ["Los Angeles"],
}

# Run the Actor and wait for it to finish
run = client.actor("ninhothedev/zip-code-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 '{
  "postcodes": [
    "90210",
    "10001"
  ],
  "cities": [
    "Los Angeles"
  ]
}' |
apify call ninhothedev/zip-code-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ninhothedev/zip-code-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/XEEs35rnzaiLQcDTv/builds/bxeKRdZ6DcH6KxMAm/openapi.json
