Skip to main content

Address Standardization

Project description

Pigeonly Address

For standardizing addresses.

For more information on USPS API keys and terms, see here

Installation

pip install pigeonly-address

Example Usage

from pigeonly_address import AddressService, StandardizeAddressError

# Example usage
try:
    address = {
        "name": "aj patel",
        "line_one": "5 reynolds",
        "line_two": "#3",
        "city": "New bedford",
        "governing_district": "MA",
        "postal_code": "02744",
        "country": "USA"
    }
    standardized_addr = AddressService("USPS_API_KEY").standardize_address(**address)
    print(standardized_addr)
    # Example success
    # {   
    #     "name": "AJ PATEL",
    #     "line_one": "5 REYNOLDS ST",
    #     "line_two": "APT 3",
    #     "city": "NEW BEDFORD",
    #     "governing_district": "MA",
    #     "postal_code": "02740",
    #     "country": "US",
    #     "meta": None
    # }
    # ------------------------------------------
    # A `meta` field is also returned.
    # Usually meta is None.
    # But sometimes, like if an address is correct,
    # but the address apt # is not verified,
    # a message returns => meta["message"]
    meta = standardized_addr.pop("meta")
    if meta and meta.get("message"):
        print(meta["message"])
    

except StandardizeAddressError as e:
    # Example str(e) == "Address Not Found"
    print(e)

USPS Docs

For US Addresses, it uses the USPS API when possible.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pigeonly-address-0.0.1.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

pigeonly_address-0.0.1-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page