# SiteVerdict — OpenStreetMap Geocoder (address ↔ lat/lon, bulk) (`siteverdict/siteverdict-geocoder-osm`) Actor

Bulk forward and reverse geocoding on OpenStreetMap data: addresses or postcodes to lat/lon and back, with parsed address parts, bounding box, confidence, cache and CSV/GeoJSON export. Use your own OpenCage, LocationIQ, Geoapify key or Photon/Nominatim server.

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

## Pricing

Pay per event

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

## OpenStreetMap Geocoder: addresses to coordinates and back, in bulk

**Turn addresses, postcodes and place names into latitude/longitude, and coordinates back into addresses.** Every result has parsed address parts, a bounding box, a confidence score and OSM identifiers. All data is OpenStreetMap (ODbL) and is delivered with the attribution the licence requires.

The Actor is built to stay within each data provider's rules. You plug in **your own** OpenCage, LocationIQ or Geoapify key, or **your own** Photon/Nominatim server. A small free trial on the public Photon server lets you test before you sign up for anything.

> **Important: the free trial is 25 lookups per run.** Beyond that you need **your own provider**: an OpenCage, LocationIQ or Geoapify API key, or the URL of a Photon or Nominatim server you host yourself. The public OSMF server (nominatim.openstreetmap.org) is refused. In a trial run, queries after the first 25 are not looked up, and the run's status message says how many were not processed. Results are OpenStreetMap data: keep the "© OpenStreetMap contributors, ODbL" attribution when you publish them.

### Who it is for

- **Ops and analytics teams:** add coordinates to a customer, store or property list, then map it, measure distances or join it to regions.
- **Developers:** run batch geocoding with a persistent cache and CSV/GeoJSON output, without writing rate-limit, retry and cache code.
- **Agents (MCP):** `geocode_addresses` returns clean, structured JSON.

### Use cases

1. **Store locator data:** 5,000 branch addresses → lat/lon + GeoJSON for your web map.
2. **Reverse geocoding:** GPS points from a fleet or field app → nearest address and postcode, plus the distance between the point and the match.
3. **Data cleaning:** messy address strings → standard address parts (road, city, postcode, country code).

### Providers

| Provider | What you need | Default rate | Notes |
|---|---|---|---|
| `photon-public` | nothing | 1 req/s, **max 25 per run** | Free trial on photon.komoot.io under its fair-use terms. **Never charged.** |
| `opencage` | your OpenCage key | 1 req/s (raise for paid plans) | OSM-based; results may be stored |
| `locationiq` | your LocationIQ key (US or EU endpoint) | 2 req/s | Nominatim-compatible |
| `geoapify` | your Geoapify key | 5 req/s | OSM-based |
| `photon-custom` | URL of your Photon server | 5 req/s | self-hosted |
| `nominatim-custom` | URL of your Nominatim server | 1 req/s | self-hosted |

> **Why not the public nominatim.openstreetmap.org?** The OSMF Nominatim usage policy forbids "API resellers like Postman or Apify" and bulk use. We block that host. Please don't point `nominatim-custom` at it.

### Output (per query)

`query`, `label`, `queryType` (forward/reverse), `status` (found / not_found / error / invalid_input / skipped_limit), `lat`, `lon`, `displayName`, `houseNumber`, `road`, `suburb`, `city`, `county`, `state`, `postcode`, `country`, `countryCode`, `placeType`, `osmType`, `osmId`, `confidence` (0–1 where the provider gives one), `bbox` \[minLon, minLat, maxLon, maxLat], `distanceKm` (reverse only), `alternatives` (other matches when results per query is above 1), `fromCache`, `attribution` and `licence`.

Files in the key-value store: `RESULTS.csv` (ends with an attribution line), `RESULTS.geojson` (FeatureCollection) and the `OUTPUT` summary.

#### Example (live run, 11 Oct 2026, public Photon trial)

| query | status | lat | lon | displayName |
|---|---|---|---|---|
| Plymouth Guildhall, Plymouth | found | 50.36960 | -4.14091 | Guildhall, Catherine Street, Barbican, Plymouth, England, PL… |
| Eiffel Tower, Paris | found | 48.85826 | 2.29450 | Eiffel Tower, 5 Avenue Anatole France, Paris, Île-de-France… |
| 50.3714,-4.1422 (reverse) | found | 50.37143 | -4.14224 | Armada Way, Barbican, Plymouth, England, PL1 1LA (0.004 km) |
| 999,1 | invalid_input | | | Not a valid "lat,lon" pair |

The second run was served entirely from the cache: no HTTP requests were made.

### Cache

**Cache results across runs** is on by default. Results are stored in a named key-value store in *your* Apify account (`siteverdict-geocoder-cache`, 30-day lifetime). Repeat lookups are cheaper for you and kinder to the providers. Identical queries in the same run share a single request.

### Pricing

Pay per event:

- **`address-geocoded`: $0.0008** per query that returned a match from your provider
- **`cached-result`: $0.0002** per match served from the cache

`not_found`, errors, invalid input and **all public-Photon trial results** are free. Your provider bills its own usage on your key.

**Maximum total charge:** the Actor never charges more than the maximum you set for the run. Before each lookup it reserves the price of one `address-geocoded` event. When the budget is used up, the remaining queries are not looked up and not charged. Each one gets a `skipped_limit` row, and the status message says "N not processed (max total charge reached)". A budget that runs out exactly on the last query is a normal, complete run.

Examples: 1,000 addresses ≈ $0.80; re-running the same 1,000 from the cache ≈ $0.20; 10,000 ≈ $8.

### FAQ

**How accurate is it?** As accurate as OSM coverage in the area. Street-level matches are excellent in Europe and good in most cities. House numbers are patchier in some countries. Check `placeType` and `confidence`, and use `countryCodes` to avoid matches with the same name abroad.

**Can I geocode 1 million rows?** Yes, with your own server or a paid plan. Set `requestsPerSecond` to your plan's limit and use `maxQueries` (up to 50,000 per run) to split the work across runs.

**Is autocomplete supported?** No. The tool is built for batch geocoding.

### Limits

- Up to 50,000 queries per run, 500 characters per address and 5 results per query.
- The public Photon trial is limited to 25 lookups per run at 1 req/s and stops at the first sign of throttling.
- Photon has no server-side country filter, so we filter matches after they come back.

### Sources & compliance

- **Data:** © OpenStreetMap contributors, [ODbL 1.0](https://opendatacommons.org/licenses/odbl/1-0/). If you publish the results or a database built from them, keep the attribution and share-alike obligations.
- **Photon public API** (photon.komoot.io): "You can use the API for your project, but please be fair - extensive usage will be throttled." Read 11 Oct 2026. We cap the trial at 25 lookups/run at 1 req/s, stop on HTTP 429, never charge for these results, and send a contactable User-Agent.
- **Nominatim usage policy** (operations.osmfoundation.org/policies/nominatim/, read 11 Oct 2026): the public server is excluded, because the policy forbids resellers such as Apify, no-code platforms and bulk use. Self-hosted Nominatim (GPL-licensed software you run yourself) is fine; our code contains none of it.
- **OpenCage, LocationIQ and Geoapify:** your account and your terms. Each provider's attribution is added to every record. Keys are secret inputs. They are sent only to the provider's API host and are scrubbed from logs, errors and output.
- **Security:** custom server URLs are checked against private, link-local and metadata IP ranges on every request (SSRF guard).
- **Personal data (UK GDPR):** home addresses can be personal data. Geocode only data you have a lawful basis to process, and avoid sending free-text notes about people. Not legal advice.

Built by SiteVerdict (BharatFare Travel and Technologies Ltd, UK). Contact: hello@webrevenuescan.com.

# Changelog

This Actor's version history is a separate document: https://apify.com/siteverdict/siteverdict-geocoder-osm/changelog.md

# Actor input Schema

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

Free-text addresses, postcodes or place names, one per line.

## `structuredAddresses` (type: `array`):

Optional objects with street, city, county, state, postcode, country and an optional label echoed back, e.g. {"street": "1 Royal Parade", "city": "Plymouth", "postcode": "PL1 1DS", "country": "GB", "label": "store-12"}.

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

"lat,lon" pairs such as 50.3714,-4.1422 to turn into addresses.

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

photon-public = free trial on komoot's public Photon server, max 25 lookups per run at 1 req/s, never charged. For real volumes use your own key (OpenCage, LocationIQ, Geoapify) or your own Photon/Nominatim server. The public OSMF Nominatim server is NOT offered because its policy forbids resellers such as Apify Actors.

## `apiKey` (type: `string`):

Your own OpenCage / LocationIQ / Geoapify key. Sent only to that provider, never logged or output.

## `instanceUrl` (type: `string`):

Base URL of your own Photon (e.g. https://photon.example.com) or Nominatim server. Private/internal addresses are blocked.

## `locationIqRegion` (type: `string`):

Which LocationIQ endpoint to use.

## `requestsPerSecond` (type: `number`):

Your plan's rate limit. Defaults to the provider's free tier (OpenCage 1, LocationIQ 2, Geoapify 5). The public Photon trial is fixed at 1.

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

Comma-separated ISO codes, e.g. gb,ie. Leave empty for worldwide.

## `language` (type: `string`):

Preferred language for place names (e.g. en, de, fr).

## `resultsPerQuery` (type: `integer`):

1 = best match only. Up to 5; extra matches go into 'alternatives' (charged once per query).

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

Store results in a named key-value store in your account and reuse them (cheaper cached-result event; required good practice for OSM services).

## `cacheStoreName` (type: `string`):

Named key-value store used as the cache.

## `cacheTtlDays` (type: `integer`):

Cached answers older than this are fetched again.

## `maxQueries` (type: `integer`):

Safety cap per run (max 50,000; the public Photon trial is always capped at 25).

## `writeCsv` (type: `boolean`):

Save RESULTS.csv (with attribution line) to the key-value store.

## `writeGeoJson` (type: `boolean`):

Save RESULTS.geojson for GIS tools and web maps.

## Actor input object example

```json
{
  "addresses": [
    "10 Downing Street, London",
    "Plymouth PL1 2AA",
    "Eiffel Tower, Paris"
  ],
  "provider": "photon-public",
  "locationIqRegion": "us",
  "language": "en",
  "resultsPerQuery": 1,
  "useCache": true,
  "cacheStoreName": "siteverdict-geocoder-cache",
  "cacheTtlDays": 30,
  "maxQueries": 1000,
  "writeCsv": true,
  "writeGeoJson": true
}
```

# Actor output Schema

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

No description

## `output` (type: `string`):

No description

## `files` (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": [
        "10 Downing Street, London",
        "Plymouth PL1 2AA",
        "Eiffel Tower, Paris"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("siteverdict/siteverdict-geocoder-osm").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": [
        "10 Downing Street, London",
        "Plymouth PL1 2AA",
        "Eiffel Tower, Paris",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("siteverdict/siteverdict-geocoder-osm").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": [
    "10 Downing Street, London",
    "Plymouth PL1 2AA",
    "Eiffel Tower, Paris"
  ]
}' |
apify call siteverdict/siteverdict-geocoder-osm --silent --output-dataset

```

## MCP server setup

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

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/x0wEcop29Uwoo7GFs/builds/Zv99VOWcNTJVLT4nE/openapi.json
