12 minlesson

Address Verification Concepts

Address Verification Concepts

Verification goes beyond validation - it confirms an address is real and deliverable.

Validation vs Verification

AspectValidationVerification
ChecksFormat correctnessReal-world existence
SpeedInstant (local)Requires API call
ExampleZIP is 5 digitsZIP 10001 exists in NYC
CostFreeMay have API costs

Verification Levels

Level 1: Format Valid

  • Postal code matches country pattern
  • Required fields present

Level 2: Components Valid

  • Postal code exists in database
  • State matches postal code region

Level 3: Address Verified

  • Full address geocodes successfully
  • High confidence match

Level 4: Deliverable

  • Carrier confirms delivery possible
  • No PO Box restrictions violated

Using Nominatim for Verification

Nominatim (OpenStreetMap) provides free geocoding:

javascript
1async function verifyAddress(address) {
2 const query = encodeURIComponent(
3 `${address.street}, ${address.city}, ${address.state} ${address.zip}`
4 );
5
6 const response = await fetch(
7 `https://nominatim.openstreetmap.org/search?q=${query}&format=json&addressdetails=1`
8 );
9
10 const results = await response.json();
11
12 if (results.length === 0) {
13 return { verified: false, error: 'ADDRESS_NOT_FOUND' };
14 }
15
16 return {
17 verified: true,
18 confidence: parseFloat(results[0].importance),
19 coordinates: {
20 lat: parseFloat(results[0].lat),
21 lng: parseFloat(results[0].lon)
22 }
23 };
24}

Confidence Scores

Geocoding APIs return confidence or importance scores:

Score RangeMeaning
0.9 - 1.0Exact match
0.7 - 0.9Good match
0.5 - 0.7Partial match
< 0.5Poor match, verify manually

Best Practices

  1. Validate format first - Don't waste API calls on invalid formats
  2. Cache results - Addresses don't change often
  3. Use multiple providers - Fallback if primary fails
  4. Set confidence thresholds - Reject low-confidence matches
  5. Log verification failures - Track patterns for improvement