# Batch Geocoder: Address to Lat/Lng (US Census + OpenStreetMap) (`latamdatatools/batch-geocoder`) Actor

Geocode address lists in bulk: US addresses with the free US Census Geocoder (with census tract and block) and worldwide addresses with OpenStreetMap Nominatim; reverse geocoding too. Lat/lng, normalized address, components and precision. CSV, dataset or list.

- **URL**: https://apify.com/latamdatatools/batch-geocoder.md
- **Developed by:** [Julian Genuario](https://apify.com/latamdatatools) (community)
- **Categories:** Developer tools, Real estate
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 geocoded locations

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?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Batch Geocoder: Address to Lat/Lng (US Census + OpenStreetMap)

Turn **lists of addresses into coordinates** (and coordinates into addresses) without a Google Maps API key:

- **US addresses** go to the free **US Census Bureau Geocoder** in batches of 1,000: latitude/longitude, the standardized address, match type and, optionally, **state/county FIPS, census tract and block** (great for demographics and territory work).
- **Addresses in any other country** go to **OpenStreetMap Nominatim**: coordinates, normalized address, house number, street, neighbourhood, city, county, state, postcode, country and a **precision** level (address, street, city...).
- **Reverse geocoding**: `lat,lon` → nearest address.

Read addresses from a list, an **Apify dataset** or a **CSV / Google Sheet**; join split columns (street, city, zip...) and copy your own IDs to the output to merge the results back.

### What does Batch Geocoder do?

Batch Geocoder converts address lists to latitude / longitude in bulk: US addresses with the free US Census Geocoder (including census tract and block) and worldwide addresses with OpenStreetMap Nominatim, plus reverse geocoding (coordinates to address). You get a normalized address, components and precision.

### How to use Batch Geocoder

1. Click **Try for free** on this page (a free Apify account is enough to start).
2. Fill in the input (see the examples below) or keep the prefilled example.
3. Click **Start** and wait for the run to finish.
4. Download the results from the **Output** tab as JSON, CSV, Excel or HTML, or read them with the Apify API.
5. Optional: create a **Schedule** to run it daily or weekly, and connect a webhook or an integration (Make, Zapier, n8n, Slack).

### Who uses it

- **CRM and RevOps**: add coordinates and clean addresses to accounts and leads, then map or territory them.
- **Logistics and delivery**: geocode customer and stop lists for routing.
- **Real estate and insurance**: geocode property lists; get census tract/block for US properties.
- **Data teams**: one cheap step in a pipeline instead of a paid geocoding API.

### Input example

```json
{
  "addresses": [
    "1600 Pennsylvania Ave NW, Washington, DC 20500",
    "350 5th Ave, New York, NY 10118",
    "Av. Santa Fe 3253, Buenos Aires, Argentina",
    "10 Downing Street, London"
  ],
  "coordinates": ["-34.5875,-58.4108"],
  "provider": "auto",
  "censusGeographies": true
}
```

From a CSV with split columns:

```json
{
  "csvUrl": "https://docs.google.com/spreadsheets/d/.../edit#gid=0",
  "addressFields": ["street", "city", "state", "zip"],
  "keepFields": ["customer_id"]
}
```

### Output

US address (Census):

```json
{
  "inputIndex": 1,
  "input": "1600 Pennsylvania Ave NW, Washington, DC 20500",
  "status": "matched",
  "provider": "census",
  "matchType": "Exact",
  "latitude": 38.898702605246,
  "longitude": -77.035189204737,
  "formattedAddress": "1600 PENNSYLVANIA AVE NW, WASHINGTON, DC, 20500",
  "street": "1600 PENNSYLVANIA AVE NW",
  "city": "WASHINGTON",
  "state": "DC",
  "postcode": "20500",
  "countryCode": "us",
  "stateFips": "11",
  "countyFips": "001",
  "censusTract": "980000",
  "censusBlock": "1034",
  "precision": "address-range",
  "fromCache": false,
  "attribution": "U.S. Census Bureau Geocoder (public domain)"
}
```

Worldwide address (Nominatim):

```json
{
  "inputIndex": 4,
  "input": "Av. Santa Fe 3253, Buenos Aires, Argentina",
  "status": "matched",
  "provider": "nominatim",
  "latitude": -34.587948,
  "longitude": -58.4102021,
  "formattedAddress": "Alto Palermo, 3253, Avenida Santa Fe, Alto Palermo, Palermo, Buenos Aires, ...",
  "houseNumber": "3253",
  "street": "Avenida Santa Fe",
  "neighbourhood": "Alto Palermo",
  "city": "Buenos Aires",
  "postcode": "C1425BGH",
  "country": "Argentina",
  "countryCode": "ar",
  "precision": "address",
  "osmType": "way",
  "attribution": "Data © OpenStreetMap contributors, ODbL 1.0 (https://www.openstreetmap.org/copyright), geocoded with Nominatim"
}
```

`status` is `matched`, `no_match`, `skipped` (per-run Nominatim limit), `error`, `invalid` or `empty`. Duplicated input rows get `duplicate: true` and the same result.

### Pricing

Pay per event: **USD 2 per 1,000 addresses geocoded** (USD 0.002 each, matches only) + a tiny start fee. **Not charged:** addresses not found, errors, skipped rows, duplicates of an address already geocoded in the run. Your "max charge per run" is respected.

### Fair use of the free services (please read)

- **US Census Geocoder**: public, free and built for batches. No per-run limit here.
- **Nominatim (OpenStreetMap)**: a free community server whose [usage policy](https://operations.osmfoundation.org/policies/nominatim/) allows at most **1 request per second** and forbids heavy bulk geocoding. This Actor therefore sends one request at a time, at most 1 per second, **caps each run at 300 lookups by default (1,000 max)**, identifies itself, and **caches** every result in your own account (90 days; not-found addresses 7 days) so the same address is never asked twice. For large non-US lists, split them across days or set `nominatimUrl` to your **own Nominatim instance** (no cap).
- Results from Nominatim are © OpenStreetMap contributors (ODbL): keep the attribution when you publish them.

### Accuracy

- Census matches use address ranges along the street (`precision: address-range`): very good for routing and maps, not rooftop-exact. P.O. boxes and new streets may not match.
- Nominatim precision depends on OpenStreetMap coverage (house numbers are complete in many cities, sparse in others). Check `precision`: `address`, `street`, `neighbourhood`, `city`...
- Write addresses as complete as possible (house number, street, city, country).

Not affiliated with or endorsed by the U.S. Census Bureau or the OpenStreetMap Foundation.

### Cost examples

Prices at the current pay-per-event rate: USD 0.002 per run and USD 2.00 per 1,000 addresses geocoded (addresses not found, errors, skipped rows and duplicates are free). You can set a maximum charge per run in the run options.

| Job | Approximate cost |
|---|---|
| Test run: 1 US address (Census) + 1 UK address (Nominatim) (measured: 2 matches, 3 s) | about $0.006 |
| 1,000 US addresses from a CRM export | about $2.00 |
| 10,000 US addresses (Census batch, no cap) | about $20 |
| 300 non-US addresses (default Nominatim cap per run) | about $0.60 |

### Use it from your code, an integration or an AI agent

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("latamdatatools/batch-geocoder").call(run_input={
  "addresses": [
    "1600 Pennsylvania Ave NW, Washington, DC 20500",
    "10 Downing Street, London, United Kingdom"
  ],
  "provider": "auto",
  "useCache": True
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["input"], item["status"], item.get("latitude"), item.get("longitude"))
```

**JavaScript / Node.js** (`npm install apify-client`):

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });
const run = await client.actor('latamdatatools/batch-geocoder').call({
  addresses: [
    '1600 Pennsylvania Ave NW, Washington, DC 20500',
    '10 Downing Street, London, United Kingdom'
  ],
  provider: 'auto',
  useCache: true
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((i) => [i.input, i.latitude, i.longitude]));
```

**No code:**

- **Schedules:** save your input as a Task and run it daily or weekly for new records from Apify Console (Schedules).
- **Integrations:** send the results to Google Sheets, Slack, email, Make, Zapier, n8n or Airbyte from the Integrations tab, or call your own webhook when a run finishes.
- **AI agents:** add it as a tool in Claude, Cursor, VS Code and other MCP clients through the Apify MCP server (`https://mcp.apify.com`), so the agent can turn addresses into coordinates (and coordinates into addresses).

### FAQ

**Can I call it from my own code or from an AI agent?** Yes. Start runs and fetch results with the Apify API or the JavaScript / Python clients, or use it as a tool from Claude, Cursor and other MCP clients through the Apify MCP server (`mcp.apify.com`).

**Can I run it automatically?** Yes. Create a Schedule in Apify Console (for example every morning) and add a webhook or an integration to get the results where you need them.

**Which export formats are available?** JSON, JSONL, CSV, Excel (XLSX), XML, RSS and HTML table, from the Output tab or the API.

**What does it cost?** See the Pricing section above. You only pay for the events listed there.

# Actor input Schema

## `addresses` (type: `array`):

One full address per line, e.g. "350 5th Ave, New York, NY 10118" or "Av. Santa Fe 3253, Buenos Aires, Argentina". Duplicates are geocoded (and charged) once.

## `coordinates` (type: `array`):

"lat,lon" per line, e.g. -34.5875,-58.4108 -> nearest address (Nominatim).

## `datasetId` (type: `string`):

ID of an Apify dataset (for example from another Actor).

## `csvUrl` (type: `string`):

Public CSV link or Google Sheets link shared as "Anyone with the link" (max 50 MB).

## `addressField` (type: `string`):

Field with the full address.

## `addressFields` (type: `array`):

Use when the address is split in columns, e.g. street, city, state, zip, country. They are joined with commas.

## `latField` (type: `string`):

With the longitude field: reverse-geocode every record of the dataset/CSV.

## `lonField` (type: `string`):

See above.

## `keepFields` (type: `array`):

Copy these fields of each input record into the output (e.g. id, name) to join the results back.

## `provider` (type: `string`):

Auto = US addresses with the US Census Geocoder (fast batch, no per-run limit) and everything else with Nominatim; Census addresses that do not match are retried with Nominatim.

## `countryCodes` (type: `string`):

Optional ISO codes for Nominatim, comma separated (e.g. ar,uy,cl). "us" sends everything to the Census Geocoder in auto mode.

## `censusGeographies` (type: `boolean`):

Adds state/county FIPS, census tract and block to US results.

## `maxNominatimRequests` (type: `integer`):

The public Nominatim server allows at most 1 request per second and no heavy bulk use, so each run is capped (max 1,000, about 17 minutes). Census (US) lookups have no cap. For bigger non-US jobs, run again later or use your own Nominatim instance.

## `nominatimUrl` (type: `string`):

Base URL of your own Nominatim server (e.g. https://nominatim.example.com). Removes the per-run cap.

## `useCache` (type: `boolean`):

Keeps results for 90 days (not-found addresses for 7 days) in a key-value store of your account, so repeated addresses are answered without asking the free services again, as their policies require.

## `maxRows` (type: `integer`):

Cap of input rows read.

## Actor input object example

```json
{
  "addresses": [
    "1600 Pennsylvania Ave NW, Washington, DC 20500",
    "10 Downing Street, London, United Kingdom"
  ],
  "addressField": "address",
  "provider": "auto",
  "censusGeographies": true,
  "maxNominatimRequests": 300,
  "useCache": true,
  "maxRows": 100000
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `runSummary` (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 = {
    "addresses": [
        "1600 Pennsylvania Ave NW, Washington, DC 20500",
        "10 Downing Street, London, United Kingdom"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("latamdatatools/batch-geocoder").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 = { "addresses": [
        "1600 Pennsylvania Ave NW, Washington, DC 20500",
        "10 Downing Street, London, United Kingdom",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("latamdatatools/batch-geocoder").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 '{
  "addresses": [
    "1600 Pennsylvania Ave NW, Washington, DC 20500",
    "10 Downing Street, London, United Kingdom"
  ]
}' |
apify call latamdatatools/batch-geocoder --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,latamdatatools/batch-geocoder"
        }
    }
}
```

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/WAohfnLn9cmwtjtNT/builds/XtvhYJl7VyUGGkwLD/openapi.json
