> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Osm Nominatim

> Client-mode REST API connectors for OpenStreetMap with no API key: Nominatim geocoding, reverse geocoding and OSM lookup, and OSRM routing, nearest road, duration matrix, GPS map matching and trip ordering, on the public servers or self-hosted

Technical Preview

## Overview

Client-mode REST API connectors for OpenStreetMap with no API key: Nominatim geocoding, reverse geocoding and OSM lookup, and OSRM routing, nearest road, duration matrix, GPS map matching and trip ordering, on the public servers or self-hosted.

This is one of the templates in the OpenStreetMap: Nominatim and OSRM (self-hostable) REST API app (`openstreetmap-nominatim-and-osrm`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

## Auth

* **schemes**: \["none"]
* **secrets**: \[]
* **note**: Nominatim usage policy: max 1 req/s, identifying User-Agent, no bulk geocoding, ODbL attribution

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Osm Nominatim connector | no |
| `BaseUrl` | string | Osm Nominatim base URL without trailing slash (e.g. [https://nominatim.openstreetmap.org](https://nominatim.openstreetmap.org)) | yes |

`BASE_ADDRESS` default: `https://nominatim.openstreetmap.org`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `NominatimSearch` | GET | `/search?format=jsonv2&q={value.json.q}{value.json.params}` | `fleet/osm/nominatim/search/get` | `fleet/osm/nominatim/search/get/response` | `params`, `q` |
| `NominatimStructured` | GET | `/search?format=jsonv2&street={value.json.street}&city={value.json.city}&postalcode={value.json.postalcode}&country={value.json.country}{value.json.params}` | `fleet/osm/nominatim/structured/get` | `fleet/osm/nominatim/structured/get/response` | `city`, `country`, `params`, `postalcode`, `street` |
| `NominatimReverse` | GET | `/reverse?format=jsonv2&lat={value.json.lat}&lon={value.json.lon}{value.json.params}` | `fleet/osm/nominatim/reverse/get` | `fleet/osm/nominatim/reverse/get/response` | `lat`, `lon`, `params` |
| `NominatimLookup` | GET | `/lookup?format=jsonv2&osm_ids={value.json.osm_ids}{value.json.params}` | `fleet/osm/nominatim/lookup/get` | `fleet/osm/nominatim/lookup/get/response` | `osm_ids`, `params` |
| `NominatimStatus` | GET | `/status?format=json` | `fleet/osm/nominatim/status/get` | `fleet/osm/nominatim/status/get/response` | none |

## Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode OSM_NOMINATIM"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE OsmNominatim WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://nominatim.openstreetmap.org"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT NominatimSearch
        WITH SOURCE_TOPIC "fleet/osm/nominatim/search/get"
        WITH DESTINATION_TOPIC "fleet/osm/nominatim/search/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/search?format=jsonv2&q={value.json.q}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT NominatimStructured
        WITH SOURCE_TOPIC "fleet/osm/nominatim/structured/get"
        WITH DESTINATION_TOPIC "fleet/osm/nominatim/structured/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/search?format=jsonv2&street={value.json.street}&city={value.json.city}&postalcode={value.json.postalcode}&country={value.json.country}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT NominatimReverse
        WITH SOURCE_TOPIC "fleet/osm/nominatim/reverse/get"
        WITH DESTINATION_TOPIC "fleet/osm/nominatim/reverse/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/reverse?format=jsonv2&lat={value.json.lat}&lon={value.json.lon}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT NominatimLookup
        WITH SOURCE_TOPIC "fleet/osm/nominatim/lookup/get"
        WITH DESTINATION_TOPIC "fleet/osm/nominatim/lookup/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/lookup?format=jsonv2&osm_ids={value.json.osm_ids}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT NominatimStatus
        WITH SOURCE_TOPIC "fleet/osm/nominatim/status/get"
        WITH DESTINATION_TOPIC "fleet/osm/nominatim/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/status?format=json"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

## Usage example

Call `NominatimSearch` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'fleet/osm/nominatim/search/get/response' &
mosquitto_pub -t 'fleet/osm/nominatim/search/get' -m '{"params": "<params>", "q": "<q>"}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.