Skip to main content

Overview

Geo services provide tools for parsing addresses into structured components and obtaining geographic coordinates.

Available Services

Parse Address

Parse addresses into structured components with geocoding

Common Use Cases

Parse Address

const result = await services.geo.parseAddress({
  address: "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA"
});

console.log(result);
// {
//   streetNumber: "1600",
//   route: "Amphitheatre Parkway",
//   city: "Mountain View",
//   state: "CA",
//   postalCode: "94043",
//   country: "USA",
//   lat: 37.4224764,
//   lng: -122.0842499
// }

Validate Address

async function validateAddress(address: string) {
  try {
    const parsed = await services.geo.parseAddress({ address });
    return {
      valid: true,
      parsed
    };
  } catch (error) {
    return {
      valid: false,
      error: "Invalid address"
    };
  }
}