{"library":"smartystreets-javascript-sdk-utils","title":"SmartyStreets JavaScript SDK Utilities","description":"This library provides utility functions to perform additional analysis on responses from the SmartyStreets US Street API, specifically for lookups validated through the `smartystreets-javascript-sdk`. It offers functions like `isValid()`, `isInvalid()`, `isAmbiguous()`, and `isMissingSecondary()` to interpret the deliverability and clarity of address lookups based on USPS standards. The current stable version is 1.2.9. As per Smarty's disclaimer, this software is provided 'as is' and 'as a gift,' implying an infrequent or demand-driven release cadence and limited official support, differentiating it from commercially maintained libraries. It serves as an auxiliary package to enhance the core SmartyStreets JavaScript SDK functionality rather than a standalone solution.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install smartystreets-javascript-sdk-utils"],"cli":null},"imports":["import * as utils from 'smartystreets-javascript-sdk-utils';","import { isValid } from 'smartystreets-javascript-sdk-utils';","import { isAmbiguous } from 'smartystreets-javascript-sdk-utils';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as SmartySDK from 'smartystreets-javascript-sdk';\nimport * as SmartyUtils from 'smartystreets-javascript-sdk-utils';\n\nconst SmartyCore = SmartySDK.core;\nconst Lookup = SmartySDK.usStreet.Lookup;\n\n// Use environment variables for credentials\nconst authId = process.env.SMARTY_AUTH_ID ?? 'YOUR_SMARTY_AUTH_ID';\nconst authToken = process.env.SMARTY_AUTH_TOKEN ?? 'YOUR_SMARTY_AUTH_TOKEN';\n\nif (authId === 'YOUR_SMARTY_AUTH_ID' || authToken === 'YOUR_SMARTY_AUTH_TOKEN') {\n  console.warn('Please set SMARTY_AUTH_ID and SMARTY_AUTH_TOKEN environment variables or replace placeholders.');\n}\n\nlet clientBuilder = new SmartyCore.ClientBuilder(new SmartyCore.StaticCredentials(authId, authToken));\nlet client = clientBuilder.buildUsStreetApiClient();\n\nlet lookup1 = new Lookup();\nlookup1.street = \"1600 Pennsylvania Ave NW\";\nlookup1.city = \"Washington\";\nlookup1.state = \"DC\";\n\nclient.send(lookup1)\n    .then(handleSuccess)\n    .catch(handleError);\n\nfunction handleSuccess(response) {\n    response.lookups.map(lookup => console.log('Result for ' + lookup.inputString + ':', lookup.result));\n\n    // Demonstrate utility functions for the first lookup in the response\n    if (response.lookups.length > 0) {\n        const firstLookupResult = response.lookups[0];\n        console.log(`Is '${firstLookupResult.inputString}' valid (mail deliverable)?`, SmartyUtils.isValid(firstLookupResult));\n        console.log(`Is '${firstLookupResult.inputString}' invalid (not mail deliverable)?`, SmartyUtils.isInvalid(firstLookupResult));\n        console.log(`Is '${firstLookupResult.inputString}' ambiguous (multiple candidates)?`, SmartyUtils.isAmbiguous(firstLookupResult));\n        console.log(`Is '${firstLookupResult.inputString}' missing a secondary address?`, SmartyUtils.isMissingSecondary(firstLookupResult));\n    }\n}\n\nfunction handleError(error) {\n    console.error(\"Error sending lookup:\", error);\n}","lang":"javascript","description":"This example demonstrates how to integrate `smartystreets-javascript-sdk-utils` with the main SmartyStreets SDK to perform address validation and then analyze the response using the utility functions like `isValid`, `isInvalid`, `isAmbiguous`, and `isMissingSecondary`. It covers authentication setup, creating a lookup, sending it via the client, and then interpreting the results programmatically using the utility library.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}