npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

truaddress

v1.0.0

Published

Official TruAddress SDK for JavaScript/TypeScript - Address validation, autocomplete, and geocoding

Downloads

295

Readme

TruAddress JavaScript/TypeScript SDK

Official JavaScript/TypeScript SDK for TruAddress - Address validation, autocomplete, and geocoding API.

Installation

npm install truaddress
# or
yarn add truaddress
# or
pnpm add truaddress

Quick Start

import TruAddress from 'truaddress';

const client = new TruAddress({
  apiKey: 'YOUR_API_KEY'
});

// Validate a US address
const results = await client.usStreet({
  street: '1600 Pennsylvania Ave NW',
  city: 'Washington',
  state: 'DC',
  zipcode: '20500'
});

if (results.length > 0 && TruAddress.isDeliverable(results[0])) {
  console.log('Valid address:', results[0].delivery_line_1);
}

Available Methods

US Endpoints

usStreet(params) - US Street Address Validation

Validate and standardize US addresses with USPS data.

const results = await client.usStreet({
  street: '350 5th Avenue',
  city: 'New York',
  state: 'NY',
  zipcode: '10118'
});

console.log(results[0].analysis.dpv_match_code); // 'Y' = Deliverable
console.log(results[0].metadata.latitude);       // 40.748535

DPV Match Codes:

  • Y - Confirmed deliverable
  • S - Secondary (apt/suite) missing
  • D - Secondary invalid
  • N - Not deliverable

usZipCode(params) - ZIP Code Lookup

Look up city/state by ZIP or find ZIP codes by city/state.

// By ZIP code
const byZip = await client.usZipCode({ zipcode: '90210' });
console.log(byZip[0].city_states[0].city); // 'Beverly Hills'

// By city/state
const byCity = await client.usZipCode({ city: 'Austin', state: 'TX' });

usAutocomplete(params) - Address Autocomplete

Real-time address suggestions as users type.

const suggestions = await client.usAutocomplete({
  search: '350 5th Ave',
  max_results: 5,
  state_filter: ['NY']
});

suggestions.suggestions.forEach(s => {
  console.log(`${s.street_line}, ${s.city}, ${s.state} ${s.zipcode}`);
});

usExtract(text, options?) - Extract Addresses from Text

Find and validate addresses in unstructured text.

const result = await client.usExtract(
  'Ship to: 350 5th Avenue, New York, NY 10118. Thanks!'
);

console.log(result.meta.address_count);      // 1
console.log(result.addresses[0].verified);   // true

usReverseGeo(params) - Reverse Geocoding

Get addresses from GPS coordinates.

const nearby = await client.usReverseGeo({
  latitude: 40.748535,
  longitude: -73.9856571
});

nearby.results.forEach(r => {
  console.log(`${r.address.street} (${r.distance.toFixed(0)}m away)`);
});

International Endpoints

intlStreet(params) - International Address Validation

Validate addresses in 200+ countries.

const results = await client.intlStreet({
  country: 'GBR',
  freeform: '10 Downing Street, London'
});

console.log(results[0].components.postal_code); // 'SW1A 2AB'
console.log(TruAddress.isVerified(results[0])); // true

intlAutocomplete(params) - International Autocomplete

Address suggestions for international addresses.

const suggestions = await client.intlAutocomplete({
  search: 'Champs Elysees',
  country: 'FRA',
  max_results: 5
});

Core Endpoints

validate(params) - Global Address Validation

Unified validation for any country.

const results = await client.validate({
  country: 'US',
  address1: '350 5th Avenue',
  locality: 'New York',
  administrative_area: 'NY',
  postal_code: '10118'
});

correct(params) - Address Correction

Parse and correct freeform addresses.

const results = await client.correct({
  freeform: '1600 pennsylvania ave washington dc 20500'
});

console.log(results[0].address1); // 'Pennsylvania Avenue Northwest 1600'

autocomplete(params) - Global Autocomplete

Worldwide address suggestions.

const suggestions = await client.autocomplete({
  q: 'Buckingham Palace London',
  limit: 5
});

Helper Methods

// Check if US address is deliverable
TruAddress.isDeliverable(result)  // DPV code = 'Y'

// Check if US address is a mail drop (CMRA)
TruAddress.isCMRA(result)

// Check if US address is vacant
TruAddress.isVacant(result)

// Check if international address is verified
TruAddress.isVerified(result)

// Format addresses as strings
TruAddress.formatUSAddress(result)   // "350 5th Ave, New York NY 10118"
TruAddress.formatIntlAddress(result) // "10 Downing Street, London, SW1A 2AB"

Configuration

const client = new TruAddress({
  apiKey: 'YOUR_API_KEY',
  baseUrl: 'https://truaddress.net'  // Optional: custom base URL
});

TypeScript Support

Full TypeScript support with exported types:

import TruAddress, { 
  USStreetResult, 
  USStreetRequest,
  IntlStreetResult,
  ValidateRequest 
} from 'truaddress';

Error Handling

try {
  const results = await client.usStreet({ street: '123 Main St' });
} catch (error) {
  console.error('Validation failed:', error.message);
}

Browser & Node.js

Works in both environments. Uses native fetch (Node.js 18+ or browser).

License

MIT