1. Addresses
  2. Parse

Addresses

Parse

The PackageX address parser validates, normalizes, and standardizes addresses. It processes various input formats and returns a consistent PackageX address model.

POST
`/v1/address/parse`

Address Input Methods

Address String Format

Usually this string is from the autocomplete endpoint. The address_line2 value can be passed in as a separate field or can be included in the string.

js
        const data = {
  address: "500 7th Ave, New York, NY",
  address_line2: "Floor 10",         // Optional
  verify: true,                      // Optional
  use_address_cache: false,          // Optional
};

fetch(`https://api.packagex.io/v1/address/parse`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

      

Address Object Format

For structured address data:

js
        const data = {
  address: {
    line1: "500 7th Ave",
    line2: "Floor 10",
    city: "New York",
    state: "NY",
    postal_code: "10018",
    country: "US",
  },
  verify: true,                 // Optional
  use_address_cache: false,     // Optional
};

fetch(`https://api.packagex.io/v1/address/parse`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

      

CASS (USPS Coding Accuracy Support System) Validation

For US addresses, you can request USPS CASS (Coding Accuracy Support System) validation by including the cass: true option in your request. CASS validation standardizes and verifies addresses according to USPS rules, providing additional metadata and delivery point validation (DPV) results. This is especially useful for mail delivery, compliance, and address quality.

When CASS validation is requested and available, the response will include a usps_cass field with detailed USPS metadata. If CASS is not available or not requested, this field will be null.

js
        const data = {
  address: "500 7th Ave, New York, NY",
  cass: true, // Request CASS validation (US addresses only)
};

const response = await fetch("https://api.packagex.io/v1/address/parse", {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

const address = response.data;
console.log(address.usps_cass); // Contains CASS/DPV metadata if available

      

Note: CASS validation is only available for US addresses. The usps_cass field contains standardized address lines, delivery point codes, DPV results, and other USPS-specific metadata. See the Address Model) for a full field reference.

Parse Location

There could be times when you're using a PackageX Location object which already includes your address in it. You can pass the id of the location into the address field of the parser and it will return the address of your location. This can be done anytime we ask for an address property. A common example is when creating a shipment. You can pass the location ID into the address property to the sender and/or recipient objects.

POST
`/v1/address/parse`
js
        const data = {
  address: "loc_jZ1fYiQobeWthjbhme3vDX",
};

const response = await fetch("https://api.packagex.io/v1/address/parse", {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

const address = response.data;

      

Parse Address ID

Like the location ID, you can also provide a PackageX address id to the parser and it will respond with the address.

POST
`/v1/address/parse`
js
        const data = {
  address: "addr_11fkZ8wQzscUj9SZaX1By1",
};

const response = await fetch("https://api.packagex.io/v1/address/parse", {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

const address = response.data;