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

@aashari/nodejs-geocoding

v2.7.2

Published

A lightweight TypeScript/Node.js library for geocoding and reverse geocoding operations with multilingual support

Readme

@aashari/nodejs-geocoding

npm version TypeScript Node.js semantic-release: angular GitHub Workflow Status

Overview

A lightweight TypeScript/Node.js library for geocoding and reverse geocoding operations with multilingual support. This library provides a simple, dependency-free solution for converting between addresses and geographic coordinates.

⚠️ Disclaimer: This library is intended for non-commercial, low-volume applications. For production or commercial use, please use the official Google Maps API.

Features

  • Zero External Dependencies: Lightweight implementation with no third-party dependencies
  • TypeScript Support: Full TypeScript definitions included for type safety
  • Promise-based API: Modern async/await compatible interface
  • Multilingual Support: Get results in different languages (e.g., English, Indonesian, French, etc.)
  • Forward Geocoding: Convert addresses to coordinates (latitude/longitude)
  • Reverse Geocoding: Convert coordinates to formatted addresses
  • Google Plus Codes: Get Google Plus Codes for locations
  • Simple Integration: Easy to integrate with any Node.js project

Installation

npm install @aashari/nodejs-geocoding

Quick Start

Geocoding (Address to Coordinates)

const geocoding = require('@aashari/nodejs-geocoding');

// Convert address to coordinates
geocoding
	.encode('Empire State Building, New York')
	.then((locations) => console.log(locations))
	.catch((error) => console.error(error));

Reverse Geocoding (Coordinates to Address)

const geocoding = require('@aashari/nodejs-geocoding');

// Convert coordinates to address
geocoding
	.decode(40.7484, -73.9857)
	.then((location) => console.log(location))
	.catch((error) => console.error(error));

API Reference

encode(address, language?)

Converts an address string to geographic coordinates.

function encode(
	formattedAddress: string,
	language?: string = 'en',
): Promise<Location[]>;

Returns: Array of location objects with coordinates and formatted address.

decode(latitude, longitude, language?)

Converts geographic coordinates to an address.

function decode(
	latitude: number,
	longitude: number,
	language?: string = 'en',
): Promise<Location | null>;

Returns: Location object with formatted address and Google Plus Code, or null if not found.

Location Interface

interface Location {
	latitude?: number;
	longitude?: number;
	google_plus_code?: string;
	formatted_address?: string;
}

Language Support

Specify a language code as the last parameter to get results in different languages:

// Get results in French
geocoding
	.encode('Tour Eiffel, Paris', 'fr')
	.then((locations) => console.log(locations));

// Get results in Japanese
geocoding
	.decode(35.6895, 139.6917, 'ja')
	.then((location) => console.log(location));

Supports all language codes that Google Maps supports (e.g., en, fr, de, ja, zh-CN, es, etc.)

Example Output

Geocoding Result

[
	{
		formatted_address:
			'Empire State Building, 20 W 34th St, New York, NY 10001, United States',
		latitude: 40.7484405,
		longitude: -73.9856644,
	},
];

Reverse Geocoding Result

{
	latitude: 40.7484,
	longitude: -73.9857,
	formatted_address: 'Empire State Building, 20 W 34th St, New York, NY 10001, United States',
	google_plus_code: '87G8Q2M4+96'
}

Using with TypeScript

import { encode, decode, Location } from '@aashari/nodejs-geocoding';

async function getLocationData(): Promise<void> {
	try {
		// Forward geocoding
		const locations: Location[] = await encode('Tokyo Tower, Japan');

		// Reverse geocoding
		if (locations.length > 0) {
			const { latitude, longitude } = locations[0];
			const address: Location | null = await decode(latitude, longitude);
			console.log(address);
		}
	} catch (error) {
		console.error('Error:', error);
	}
}

Advanced Usage Examples

With Async/Await

async function getLocationInfo() {
	try {
		// Geocoding
		const coordinates = await geocoding.encode('Colosseum, Rome');
		console.log('Coordinates:', coordinates);

		// Reverse Geocoding using the first result
		if (coordinates && coordinates.length > 0) {
			const { latitude, longitude } = coordinates[0];
			const address = await geocoding.decode(latitude, longitude);
			console.log('Address:', address);
		}
	} catch (error) {
		console.error('Error:', error);
	}
}

Error Handling

async function safeGeocode(address) {
	try {
		const results = await geocoding.encode(address);
		if (!results || results.length === 0) {
			console.log(`No results found for address: ${address}`);
			return null;
		}
		return results;
	} catch (error) {
		console.error(`Error geocoding address "${address}":`, error);
		return null;
	}
}

License

This project is licensed under the MIT License.


Made with ❤️ by aashari