A JavaScript library for address lookup and validation, for use in the DOM.
- Import the Library
Include the integrator.min.js
file from the build folder in your HTML:
<script src="integrator.min.js"></script>
Or via CDN:
<script src="https://cdn.jsdelivr.net/gh/postcoder-api/integrator-js@v2/build/integrator.min.js"></script>
- Activate the Library
Create a new instance using the constructor:
const postcoder = new PostcoderAddressAutocomplete(options);
- Replace
options
with your configuration object.
<script>
document.addEventListener("DOMContentLoaded", function () {
const postcoder = new PostcoderAddressAutocomplete({
apikey: "YOUR_API_KEY",
country: "#country",
searchinput: "#search_input",
outputfields: {
addressline1: "#address_line_1",
addressline2: "#address_line_2",
posttown: "#post_town",
county: "#county",
postcode: "#postcode",
},
});
});
</script>
If you wish to fork this repository and edit it for your own needs, please feel free.
Install the required packages with npm ci
, and run Rollup and a local development server with npm start
.
index.ts
initiates the library, with handlers.ts
attaching functions from actions.ts
to HTML elements in the DOM. Data to be shared between functions in the library is stored in objects imported from data.ts
.
- See index.html for a usage example.
- Find more documentation for the API at https://postcoder.com/docs
- Feel free to get in touch with us with any questions.