Skip to content

nominatim_fdw

Nominatim Foreign Data Wrapper for PostgreSQL

Overview

PackageVersionCategoryLicenseLanguage
nominatim_fdw2.3FDWMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
8680nominatim_fdwNoYesNoYesNoYes-

SQL/control and tagged release version 2.3; PGXN distribution 2.3.0. Maintained in the local RPM and DEB recipes.

Version

TypeRepoVersionPG VerPackageDeps
EXTMIXED2.31817161514nominatim_fdw-
RPMPGDG2.31817161514nominatim_fdw_$v-
DEBPIGSTY2.31817161514postgresql-$v-nominatim-fdw-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
d12.aarch64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
d13.x86_64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
d13.aarch64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
u22.x86_64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
u22.aarch64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
u24.x86_64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
u24.aarch64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
u26.x86_64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
u26.aarch64
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3
PIGSTY 2.3

Build

You can build the RPM / DEB packages for nominatim_fdw using pig build:

pig build pkg nominatim_fdw         # build RPM / DEB packages

Install

You can install nominatim_fdw directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

Install
pig install nominatim_fdw;          # Install for current active PG version
pig
pig ext install -y nominatim_fdw -v 18  # PG 18
pig ext install -y nominatim_fdw -v 17  # PG 17
pig ext install -y nominatim_fdw -v 16  # PG 16
pig ext install -y nominatim_fdw -v 15  # PG 15
pig ext install -y nominatim_fdw -v 14  # PG 14
dnf
dnf install -y nominatim_fdw_18       # PG 18
dnf install -y nominatim_fdw_17       # PG 17
dnf install -y nominatim_fdw_16       # PG 16
dnf install -y nominatim_fdw_15       # PG 15
dnf install -y nominatim_fdw_14       # PG 14
apt
apt install -y postgresql-18-nominatim-fdw   # PG 18
apt install -y postgresql-17-nominatim-fdw   # PG 17
apt install -y postgresql-16-nominatim-fdw   # PG 16
apt install -y postgresql-15-nominatim-fdw   # PG 15
apt install -y postgresql-14-nominatim-fdw   # PG 14

Create Extension:

CREATE EXTENSION nominatim_fdw;

Usage

Sources:

nominatim_fdw calls a Nominatim geocoding service from PostgreSQL. Unlike a conventional FDW, it exposes functions for search, reverse geocoding, and OSM-object lookup; it does not create queryable foreign tables.

Configure a Server

CREATE EXTENSION nominatim_fdw;

CREATE SERVER osm
  FOREIGN DATA WRAPPER nominatim_fdw
  OPTIONS (
    url 'https://nominatim.openstreetmap.org',
    connect_timeout '10',
    max_connect_retry '2',
    max_connect_redirect '1',
    accept_language 'en'
  );

The public OpenStreetMap endpoint has an official usage policy. For sustained or bulk workloads, use an authorized provider or operate your own Nominatim service, identify the application as required, and respect rate limits.

Version 2.1 supports HTTP Basic authentication through a per-user mapping:

CREATE USER MAPPING FOR app_user
SERVER osm
OPTIONS (user 'remote_user', password 'secret');

Keep endpoint and proxy credentials in USER MAPPING, where PostgreSQL applies its credential-visibility rules, rather than in foreign-server options.

Core Workflow

Free-form search:

SELECT osm_id, display_name, lon, lat
FROM nominatim_search(
  server_name => 'osm',
  q => 'Neubrückenstraße 63, Münster, Germany'
);

Reverse geocoding and object lookup:

SELECT osm_id, display_name, addressdetails
FROM nominatim_reverse(
  server_name => 'osm',
  lon => 7.6293,
  lat => 51.9648,
  addressdetails => true
);

SELECT osm_id, display_name
FROM nominatim_lookup(
  server_name => 'osm',
  osm_ids => 'W121736959'
);

Important Objects

  • nominatim_search(...) implements free-form or structured forward search.
  • nominatim_reverse(...) resolves longitude and latitude to the nearest suitable OSM address.
  • nominatim_lookup(...) fetches node, way, or relation identifiers such as N123, W456, or R789.
  • nominatim_fdw_version() reports the extension and principal library versions.
  • nominatim_fdw_settings exposes dependency and build versions as rows.
  • Server options include url, proxy configuration, timeouts, retry and redirect limits, and default accept_language.

All endpoint functions are STRICT: an explicit SQL NULL argument returns no rows without sending a request. In 2.0 they are correctly declared VOLATILE, because responses are remote and can change.

Version 2.3 Changes and Caveats

Version 2.0 validates reverse coordinates, adds email, polygon_threshold, and entrances, exposes dependency settings, and fixes JSON escaping for returned detail fields. It also has user-visible compatibility changes: reverse output uses display_name; addressparts becomes addressdetails; address details default to true for reverse and lookup; and version output is shorter.

After installing the 2.3 extension files, upgrade existing databases:

ALTER EXTENSION nominatim_fdw UPDATE TO '2.3';

Version 2.1 adds Basic-auth mapping and initializes libcurl once per PostgreSQL backend instead of relying on implicit per-request initialization. The libcurl fix requires no new SQL or preload setting.

Each call performs network I/O in the database statement. Use finite timeouts, constrain who can create or alter servers, and avoid invoking a public service once per row in a large query. The upstream build requires PostgreSQL 10 or newer, libxml2 2.6.0 or newer, and libcurl 7.74 or newer.

2.3 Privileges and Request Limits

The SQL/control version is 2.3; the PGXN distribution version is 2.3.0. Query functions now enforce foreign-server USAGE; grant it to roles that need access:

GRANT USAGE ON FOREIGN SERVER osm TO app_user;
ALTER SERVER osm OPTIONS (ADD max_response_size '10485760');

max_response_size is in bytes, defaults to 0 for no additional limit, and accepts a maximum of 1 GiB. 2.3 allows only HTTP/HTTPS and rejects CR/LF in request headers; polygon_threshold must be finite and nonnegative. zoom preserves -1 as the default and clamps other values to 0–18. It also fixes response encoding, XML root validation and cleanup after cancellation. The catalog version does not imply that existing 2.2.0 packages contain these fixes.

Was this page helpful?