# Geocoding API - Official Registers, No Key (`martin10291/official-geocoding-api`) Actor

No API key, no login. Address to coordinates and back from 10 official government address registers: US Census, Canada NRCan, UK ONS postcodes, France BAN, Spain CartoCiudad, Netherlands BAG, Switzerland, Norway, Estonia, Poland. Up to 100 per call, open licences: you may store the results.

- **URL**: https://apify.com/martin10291/official-geocoding-api.md
- **Developed by:** [Martin Petrov](https://apify.com/martin10291) (community)
- **Categories:** Agents, Developer tools, Automation
- **Features:** Limited permissions
- **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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Geocoding API - Official Registers

**Problem:** you need latitude/longitude for a list of addresses (or the address for a point), but Google and HERE forbid storing their results, OpenStreetMap's public Nominatim forbids bulk use, and cheap geocoders guess. For the US, Europe's best address registers and Canada, governments already publish exact, free, open-licence geocoders. They are just 10 different APIs.

**This API:** one call, up to 100 addresses and/or points, answered from the official register of each country in about 0.1-0.7 s per address. No API key, no login.

| Country | Official source | Precision | Licence |
|---|---|---|---|
| United States | U.S. Census Bureau Geocoder (TIGER) | address range + county / census tract FIPS | public domain |
| Canada | Natural Resources Canada Geolocator | interpolated address | OGL-Canada |
| United Kingdom | ONS Postcode Directory + OS Open Names (postcodes.io) | postcode centroid / place | OGL v3 |
| France | IGN Geoplateforme, Base Adresse Nationale | rooftop / entrance | Licence Ouverte 2.0 |
| Spain | CartoCiudad (IGN + Catastro) | entrance + cadastral reference | CC BY 4.0 |
| Netherlands | PDOK Locatieserver (BAG register) | rooftop + BAG ID | CC0 |
| Switzerland | geo.admin.ch building address directory | rooftop + EGAID | free OGD |
| Norway | Kartverket (Matrikkel) | entrance + cadastral number | CC BY 4.0 |
| Estonia | Maa-amet In-ADS | building + ADS ID | CC BY 4.0 |
| Poland | GUGiK UUG (PRG register) | address point + TERYT | free public data |

### Why it is different

- **Open licences: you may store and reuse the coordinates** (Google Maps Platform terms forbid caching geocodes beyond 30 days).
- **Official IDs in every row** (`official_id`): BAG, Catastro, TIGER, EGAID, Matrikkel, ADS, TERYT. Join your data with government datasets.
- **US census tract in the same call** (`includeCensus: true`): state, county and tract GEOID for demographics, insurance, HMDA/CRA lending work.
- **Country auto-detection** from the postcode format, the city or the country name. Mixed lists work. Force it with `country` or a line prefix `FR: ...`.
- **Honest statuses:** `ok`, `not_found`, `unavailable` (register down, retried 3 times; never a guessed point), `unsupported_country`, `invalid_input`. A match outside the city you wrote gets `score <= 0.4` and a `note`.
- **Reverse geocoding** (`coordinates`): nearest official address in FR, ES, NL, NO, PL; nearest postcode in GB; county + census tract in US.
- **Only changes mode:** `onlyNew: true` + `monitorId` re-checks a stored address list on a schedule and returns only rows whose match changed.

### Example (API)

```bash
curl -X POST "https://api.apify.com/v2/acts/martin10291~official-geocoding-api/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"addresses": ["350 Fifth Avenue, New York, NY 10118", "Damrak 1, 1012 LG Amsterdam", "Calle Gran Via 28, Madrid"], "coordinates": ["52.3759,4.8975"], "includeCensus": true}'
```

Output rows (real output):

```json
{"input": "350 Fifth Avenue, New York, NY 10118", "country_code": "US", "status": "ok",
 "lat": 40.7478508, "lon": -73.9850756, "formatted_address": "350 5TH AVE, NEW YORK, NY, 10118",
 "street": "5TH AVE", "house_number": "350", "postcode": "10118", "city": "NEW YORK", "region": "NY",
 "precision": "interpolated (address range)", "score": 1.0, "official_id": "TIGER:59653473",
 "census": {"state_fips": "36", "state": "New York", "county_fips": "36061", "county": "New York County",
            "tract_geoid": "36061007600", "tract": "76"},
 "source": "U.S. Census Bureau Geocoder", "licence": "Public domain (U.S. Government work)", "response_ms": 645}
{"input": "Damrak 1, 1012 LG Amsterdam", "country_code": "NL", "status": "ok", "lat": 52.3771445, "lon": 4.8980385,
 "formatted_address": "Damrak 1, 1012LG Amsterdam", "street": "Damrak", "house_number": "1", "postcode": "1012LG",
 "city": "Amsterdam", "region": "Noord-Holland", "precision": "rooftop (BAG address)", "score": 1.0,
 "official_id": "BAG:0363200012113669", "source": "PDOK Locatieserver (BAG)", "licence": "CC0 1.0", "response_ms": 274}
```

### Use from AI agents (MCP)

Add the Apify MCP server (`https://mcp.apify.com?tools=martin10291/official-geocoding-api`) to Claude, Cursor or any MCP client and ask: "Geocode these store addresses and give me the census tract for the US ones".

### Schedule and chain

- **Keep an address list clean:** save a task with your list, `onlyNew: true` and a `monitorId`, schedule it weekly. You get only addresses whose official match changed.
- **After a lead or store scraper:** pass its address column as `addresses`; the dataset rows keep your `input` text, so you can join back.

### Input

| Field | What it does |
|---|---|
| `addresses` | Addresses, postcodes or place names, up to 100 per run |
| `coordinates` | Points `lat,lon` for reverse geocoding (optional) |
| `country` | `auto` (default) or one of US, CA, GB, FR, ES, NL, CH, NO, EE, PL |
| `includeCensus` | US: add state, county and census tract FIPS |
| `onlyNew` / `monitorId` | Return only rows whose match changed since the last run |

### FAQ

**Germany, Italy, other countries?** Not yet: they have no free national geocoder without a key. Rows from other countries return `unsupported_country` and are not a guessed point.
**UK street addresses?** The UK address register (AddressBase) is not open, so GB rows are at postcode level (or place level without a postcode).
**Pricing?** $0.50 per 1,000 result rows (one row per address or point).
**Limits?** 100 items per run; the US Census geocoder takes about 0.5-1 s per address, the others 0.1-0.6 s. 6 lookups run in parallel.

# Actor input Schema

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

Addresses, postcodes or place names, up to 100 per run. The country is detected from the text (postcode format, city or country name). To force it, set Country below or prefix one line like 'FR: 8 bd du Port, 80000 Amiens'. Covered: US, CA, GB (postcode/place level), FR, ES, NL, CH, NO, EE, PL.

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

Optional points as 'lat,lon', e.g. 52.3759,4.8975. Returns the nearest official address (FR, ES, NL, NO, PL), the nearest postcode (GB) or the county and census tract (US).

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

Optional: one country for all lines (US, CA, GB, FR, ES, NL, CH, NO, EE, PL). Leave 'auto' to detect it per line.

## `includeCensus` (type: `boolean`):

For US addresses also return state, county and census tract FIPS codes (GEOID) from the Census Bureau. Useful for demographics joins, insurance and lending (HMDA/CRA) work.

## `onlyNew` (type: `boolean`):

Return only addresses whose match (coordinates, official address or ID) changed since the last run with the same Monitor ID. The first run returns all. Use it on a schedule to keep a customer or store address list clean.

## `monitorId` (type: `string`):

Name of the address list for Only changes mode, e.g. stores-eu. Each Monitor ID keeps its own memory.

## Actor input object example

```json
{
  "addresses": [
    "1600 Pennsylvania Ave NW, Washington, DC 20500",
    "Damrak 1, 1012 LG Amsterdam",
    "Calle Gran Via 28, Madrid",
    "10 Downing Street, London SW1A 2AA"
  ],
  "coordinates": [
    "52.3759,4.8975",
    "40.4164,-3.7046"
  ],
  "country": "auto",
  "includeCensus": false,
  "onlyNew": false,
  "monitorId": "default"
}
```

# Actor output Schema

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

One row per address or point: status (ok, not_found, unavailable, unsupported_country, invalid_input), lat, lon, official formatted address, street, house number, postcode, city, region, precision, score, official register ID, source and licence.

# 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",
        "Damrak 1, 1012 LG Amsterdam",
        "Calle Gran Via 28, Madrid",
        "10 Downing Street, London SW1A 2AA"
    ],
    "coordinates": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("martin10291/official-geocoding-api").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",
        "Damrak 1, 1012 LG Amsterdam",
        "Calle Gran Via 28, Madrid",
        "10 Downing Street, London SW1A 2AA",
    ],
    "coordinates": [],
}

# Run the Actor and wait for it to finish
run = client.actor("martin10291/official-geocoding-api").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",
    "Damrak 1, 1012 LG Amsterdam",
    "Calle Gran Via 28, Madrid",
    "10 Downing Street, London SW1A 2AA"
  ],
  "coordinates": []
}' |
apify call martin10291/official-geocoding-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,martin10291/official-geocoding-api"
        }
    }
}
```

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/rwf3xtiYeN8d3tdo5/builds/Cdnqjd5ZsOkGEaQHa/openapi.json
