{"library":"node-geocoder","title":"Node Geocoder","description":"Node Geocoder is a flexible geocoding and reverse geocoding library for Node.js, providing a unified API to various geocoding services. It currently stands at version 4.4.1 and sees a stable release cadence. Key differentiators include its extensive support for over a dozen providers such as Google Maps, MapQuest, OpenStreetMap, HERE, and ArcGIS Online, allowing developers to switch services without major code changes. The library abstracts away provider-specific API quirks, offering consistent input and output formats. It supports both callback and Promise-based usage, making it adaptable to modern asynchronous JavaScript patterns. Developers must supply their own API keys for most commercial providers, as well as handle potential rate limiting and usage quotas.","language":"javascript","status":"active","last_verified":"Thu Apr 23","install":{"commands":["npm install node-geocoder"],"cli":null},"imports":["const NodeGeocoder = require('node-geocoder');","const geocoder = NodeGeocoder(options);","const options = {\n  provider: 'google',\n  apiKey: 'YOUR_API_KEY' // Mandatory for most providers\n};"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const NodeGeocoder = require('node-geocoder');\nconst nodeFetch = require('node-fetch'); // Required for custom fetch example, otherwise global fetch is used in Node 18+\n\nconst API_KEY_GOOGLE = process.env.GOOGLE_GEOCODER_API_KEY ?? '';\nconst API_KEY_HERE = process.env.HERE_GEOCODER_API_KEY ?? '';\n\nconst optionsGoogle = {\n  provider: 'google',\n  apiKey: API_KEY_GOOGLE,\n  formatter: null // Optional: 'gpx', 'string', etc.\n};\n\nconst optionsHere = {\n  provider: 'here',\n  apiKey: API_KEY_HERE,\n  language: 'en' // Optional, specify language for results\n};\n\nconst geocoderGoogle = NodeGeocoder(optionsGoogle);\nconst geocoderHere = NodeGeocoder(optionsHere);\n\nasync function runGeocoding() {\n  try {\n    console.log('--- Google Geocoding ---');\n    const resGoogle = await geocoderGoogle.geocode('29 champs elysée paris');\n    console.log('Geocode (Google):', resGoogle[0].formattedAddress);\n\n    console.log('\\n--- Here Reverse Geocoding ---');\n    const resHere = await geocoderHere.reverse({ lat: 45.767, lon: 4.833 });\n    console.log('Reverse Geocode (HERE):', resHere[0].formattedAddress);\n\n    console.log('\\n--- Google Advanced Geocoding ---');\n    const resAdvanced = await geocoderGoogle.geocode({\n      address: '29 champs elysée',\n      country: 'France',\n      zipcode: '75008'\n    });\n    console.log('Advanced Geocode (Google):', resAdvanced[0].formattedAddress);\n\n    console.log('\\n--- Batch Geocoding (Google) ---');\n    const batchResults = await geocoderGoogle.batchGeocode([\n      '13 rue sainte catherine, bordeaux',\n      'another address, london'\n    ]);\n    console.log('Batch Geocode (Google) Result 1:', batchResults[0][0].formattedAddress);\n    console.log('Batch Geocode (Google) Result 2:', batchResults[1][0].formattedAddress);\n\n  } catch (error) {\n    console.error('Geocoding error:', error);\n  }\n}\n\nrunGeocoding();","lang":"javascript","description":"Demonstrates basic geocoding, reverse geocoding, and advanced options using Google and HERE providers. It includes batch geocoding and uses environment variables for API keys.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}