npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nestjs-nominatim

v2.0.1

Published

A powerful NestJS module for OpenStreetMap Nominatim API integration — geocoding, reverse geocoding, place lookup, and built-in caching with full TypeScript support

Readme

NestJS Nominatim

npm version License: MIT

NestJS module for the Nominatim geocoding API (OpenStreetMap). Forward/reverse geocoding, place lookup, address formatting, and built-in caching — fully typed.

Installation

npm install nestjs-nominatim

Peer dependencies (install the ones you don't already have):

npm install @nestjs/common @nestjs/core @nestjs/axios axios
# Optional — only needed if you want caching:
npm install @nestjs/cache-manager cache-manager

Quick Start

Basic Setup

import { Module } from "@nestjs/common";
import { NominatimModule } from "nestjs-nominatim";

@Module({
  imports: [
    NominatimModule.forRoot({
      userAgent: "YourApp/1.0",
      language: "en",
      addressdetails: true,
    }),
  ],
})
export class AppModule {}

Async Configuration

Use forRootAsync() to resolve config at runtime (e.g. from ConfigService):

NominatimModule.forRootAsync({
  inject: [ConfigService],
  useFactory: (config: ConfigService) => ({
    baseUrl: config.get<string>("GEOLOCATION_API"),
    userAgent: `${config.get<string>("APP_NAME")}/${config.get<string>("API_VERSION")}`,
    language: "en",
    addressdetails: true,
  }),
});

Also supports useClass and useExisting — implement the NominatimOptionsFactory interface:

@Injectable()
export class NominatimConfigService implements NominatimOptionsFactory {
  createNominatimOptions(): NominatimModuleOptions {
    return {
      userAgent: "MyApp/1.0",
      language: "en",
      addressdetails: true,
    };
  }
}

// useClass — module creates and manages the instance
NominatimModule.forRootAsync({ useClass: NominatimConfigService });

// useExisting — reuse a provider already registered elsewhere
NominatimModule.forRootAsync({
  imports: [ConfigurationModule],
  useExisting: NominatimConfigService,
});

Using the Service

import { Injectable } from "@nestjs/common";
import { NominatimService } from "nestjs-nominatim";

@Injectable()
export class LocationService {
  constructor(private readonly nominatim: NominatimService) {}

  async searchPlace(query: string) {
    return this.nominatim.search(query);
  }

  async reverseGeocode(lat: number, lon: number) {
    return this.nominatim.reverse({ lat, lon });
  }

  async lookupByOsmIds(ids: string[]) {
    return this.nominatim.lookup(ids);
  }
}

API Reference

Configuration Options

| Option | Type | Default | Description | | ---------------- | -------------------- | ------------------------------------- | --------------------------------- | | baseUrl | string | https://nominatim.openstreetmap.org | Nominatim API base URL | | language | string | en | Preferred language (ISO 639-1) | | addressdetails | boolean | true | Include address breakdown | | timeout | number | 5000 | Request timeout (ms) | | userAgent | string | nestjs-nominatim/1.0 | User agent string | | extratags | boolean | false | Include extra OSM tags | | namedetails | boolean | false | Include multilingual name details | | cache | CacheModuleOptions | 1 day TTL, in-memory | Cache configuration |

Service Methods

search(query: string): Promise<NominatimSearchResults>

Search for places by name or address.

const results = await nominatim.search("Paris, France");

reverse(coordinates: Coordinates): Promise<NominatimPlace>

Get location info from coordinates.

const place = await nominatim.reverse({ lat: 48.8566, lon: 2.3522 });

lookup(osmIds: string[]): Promise<NominatimSearchResults>

Look up places by OSM IDs.

const places = await nominatim.lookup(["R146656", "W104393803"]);

healthCheck(): Promise<HealthCheck>

Check API availability.

const health = await nominatim.healthCheck();
// health.status === 0 means OK

formatLocation(place: NominatimPlace): FormattedAddress

Extract structured address components from a place result.

const place = await nominatim.reverse({ lat: 48.8566, lon: 2.3522 });
const formatted = nominatim.formatLocation(place);
// { country, countryCode, postcode, region, commune, district, street, placeType, fullAddress }

Caching

Caching is built-in and applied automatically to search, reverse, and lookup calls. Pass a cache option to configure:

NominatimModule.forRoot({
  userAgent: "YourApp/1.0",
  cache: {
    ttl: 3600000, // 1 hour
    max: 1000,
  },
});

For Redis or other stores:

import { redisStore } from "cache-manager-redis-store";

NominatimModule.forRoot({
  userAgent: "YourApp/1.0",
  cache: {
    store: redisStore,
    host: "localhost",
    port: 6379,
    ttl: 3600000,
  },
});

Default cache config (when no cache option is provided): 1 day TTL, in-memory store.

Cache keys follow the pattern: search:{query}, reverse:{lat}:{lon}, lookup:{id1},{id2}.

Type Exports

All types are exported from the package root:

import {
  NominatimPlace,
  NominatimSearchResults,
  Coordinates,
  FormattedAddress,
  HealthCheck,
  NominatimAddress,
  NominatimExtraTags,
  NominatimNameDetails,
  NominatimModuleOptions,
  NominatimModuleAsyncOptions,
  NominatimOptionsFactory,
  NOMINATIM_MODULE_OPTIONS,
  OSMType,
} from "nestjs-nominatim";

License

MIT — see LICENSE.

Contributing

  1. Fork the repo
  2. Create a feature branch
  3. Submit a Pull Request

Issues and feature requests: GitHub Issues

Author

Yassine Zeraibi ([email protected])