JavaScript/Node.js Package
Package Name: address-service-js
What You Get:
- An autocomplete function providing a list of addresses with various fields.
- Fields include coordinates, street number, city, street, district, postcode, region, and a unique identifier (hs_guid).
- Customize your own user form with the retrieved address data.ith a seamless experience to obtain addresses.
Integration Steps:
-
Install the address-service-js package in your JavaScript/Node.js project:
- cmd
npm i address-service-js
-
Depending on your project's syntax, import the addressService function accordingly.
-
For ES syntax:
- Javascript
import addressService from 'address-service-js';
// Ensure "type": "module" in package.json -
For CommonJS syntax:
- Javascript
const addressService = require('address-service-js');
// Ensure "type": "commonjs" or skip "type" in package.json
-
-
Use the function to retrieve addresses:
- Javascript
async function getAddress(address) {
const result = await addressService(address);
console.log(result);
} -
Call the function with the desired address:
- Javascript
getAddress("20 A");
-
Upon calling the getAddress function with valid parameters, you will receive a JSON response containing a list of addresses. Here's an example output:
- JSON
{
"totalHits": { "value": 27, "relation": "GREATER_THAN_OR_EQUAL_TO" },
"processingTime": "462ms",
"documents": [
{
"coordinates_0": -70.5612909,
"number": "20",
"coordinates_1": 41.9318039,
"unit": "",
"city": "PLYMOUTH",
"street": "AVENUE A",
"district": "PLYMOUTH",
"postcode": "02360",
"region": "MA",
"hs_guid": "7e1f48df-b929-4c12-a779-10158bc9370d"
},
{
"coordinates_0": -71.7178363,
"number": "20",
"coordinates_1": 42.0750203,
"unit": "",
"city": "DOUGLAS",
"street": "A STREET",
"district": "WORCESTER",
"postcode": "01516",
"region": "MA",
"hs_guid": "64853dc7-bba1-4cb5-aa88-3311b90e914b"
},
// ... (Additional address entries)
]
}