Lightweight, TypeScript-based reverse geocoder using OpenStreetMap's Nominatim API.
Convert latitude and longitude into a human-readable address — with minimal setup, zero dependencies on Google Maps, and full open-source freedom.
- 🌐 Uses free OpenStreetMap Nominatim
- 📦 Lightweight and dependency-free (except
node-fetch
) - 🔒 Type-safe (written in TypeScript)
- ✅ Tested with Jest
- 💥 ESM-compatible
npm install reverse-geocode-lite
or with yarn:
yarn add reverse-geocode-lite
import { reverseGeocode } from 'reverse-geocode-lite';
const getAddress = async () => {
const address = await reverseGeocode(48.8584, 2.2945); // Eiffel Tower
console.log(address);
};
getAddress();
const { reverseGeocode } = require('reverse-geocode-lite');
reverseGeocode(40.7128, -74.006).then(console.log); // New York
Param | Type | Description |
---|---|---|
lat | number |
Latitude |
lng | number |
Longitude |
Returns a human-readable address (string
), or null
if not found or if an error occurred.
Run unit tests using:
npm test
Includes mocked responses for:
- Successful address lookup
- No address found
- Network failure
- Server errors
- This package uses the public OpenStreetMap Nominatim API, which has strict usage policies.
- You must include a valid
User-Agent
header in production requests, or risk getting blocked.
MIT © Jonathan Mwebaze
- Fork this repo
- Create your feature branch:
git checkout -b feature/your-feature
- Commit your changes:
git commit -am 'Add feature'
- Push to the branch:
git push origin feature/your-feature
- Submit a pull request
- Built on OpenStreetMap
- Powered by Nominatim