Skip to main content

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:

  1. Install the address-service-js package in your JavaScript/Node.js project:

    npm i address-service-js
  2. Depending on your project's syntax, import the addressService function accordingly.

    1. For ES syntax:

      import addressService from 'address-service-js';
      // Ensure "type": "module" in package.json
    2. For CommonJS syntax:

      const addressService = require('address-service-js');
      // Ensure "type": "commonjs" or skip "type" in package.json
  3. Use the function to retrieve addresses:

    async function getAddress(address) {
    const result = await addressService(address);
    console.log(result);
    }
  4. Call the function with the desired address:

    getAddress("20 A");
  5. Upon calling the getAddress function with valid parameters, you will receive a JSON response containing a list of addresses. Here's an example output:

    {
    "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)
    ]
    }