Package: smartystreets.py
A wrapper for the SmartyStreets address validation and geolocation API.Other Python libraries exist but skip out on multiple address submission
and make opinionated decisions about how to transform the return data.NoteThis project is not affiliated with the SmartyStreets service or company in any
way.Free software: BSD licenseDocumentation:https://smartystreetspy.readthedocs.org.FeaturesSmartyStreets.py aims to provide a sane, tested, and feature complete wrapper
to the SmartyStreets LiveAddress API, including address lookup for validation
and geolocation, as well as zipcode lookup and validation.InstallationSmartyStreets.py requires therequests libraryand will install it if it is
found missing.Installed versions < 2.0 will be upgraded.:pip install smartystreets.pyBasic usageAPI clientCreate a client instance with your key:from smartystreets import Client
client = Client(AUTH_ID, AUTH_TOKEN)Create a client instance with SmartyStreets configuration options:client = Client(AUTH_ID, AUTH_TOKEN, standardize=True, invalid=False,
            logging=False)These options correspond to thex-standardize-only,x-include-invalid, andx-suppress-loggingheaders for opening up results to standardized but not
necessarily deliverable addresses, including invalid delivery addresses, and
toggling SmartyStreets API logging, respectively.Since the SmartyStreets API only permits up to 100 addresses to be looked up at
once the client will raise an exception if more than 100 are provided. You can
turn off this functionality using thetruncate_addressesoption, which will
silently truncate the list to the first 100 addresses:client = Client(AUTH_ID, AUTH_TOKEN, truncate_addresses=True)Address lookupSimple address lookup:client.street_address("100 Main St Richmond, VA")Multiple simple street addresses:client.street_addresses(["100 Main St Richmond, VA", "100 Main St Richmond, VA"])Note that these are different function names.You can also use dictionaries including detailed data:client.street_address({
    'input_id': 'k1d8j',
    'street': '100 Main st',
    'city': 'Richmond',
    'state': 'VA',
    'candidates': 2,
})And multiple detailed lookups:client.street_addresses([
    {
        'input_id': 'k1d8j',
        'street': '100 Main st',
        'city': 'Richmond',
        'state': 'VA',
        'candidates': 2,
    }, {
        'input_id': 'z29ir',
        'street': '400 Main st',
        'city': 'Richmond',
        'state': 'VA',
        'candidates': 2,
    }
])NoteYou cannot mix the simple street lookup style and the detailed dictionary
lookup style in the same API call. This is a library restriction.Return dataJust as important as a clean interface for working with the API is a helpful
way of working with the returned data.Returned data is presented as either a singleSmartyAddressor aSmartyAddressescollection. Each is based on builtin types so that you always
have access to the underlying data exactly as it was returned, but with
added convenience methods.Address geolocationWhere is it?:>>> address = client.street_address("100 Main St Richmond, VA")
>>> address.location
(37.5436,-77.4453)Accuracy is subject to address inputs and available data.Address verificationIs this a deliverable address?:>>> address.confirmed
TrueThe value here does not necessarily mean this is an exact mail address
(e.g. with apartment number). The SmartyStreets API will return a code
indicating the complete DPV status.Multiple addresses: input ID lookupYou can look up an address by theinput_idparameter (provided you include
one in the request):>>> addresses = client.street_address([{'input_id': '123', 'street': ...}])
>>> addresses.get('123')
{'input_id': '123', 'street': ... }Thegetmethod is used because theSmartyAddressesobject’s default lookup
is against the list index.Zipcode lookupTODOResponse errorsThe following documented response codes raise specific exceptions based on aSmaryStreetsErrorclass.400 Bad input. Required fields missing from input or are malformed.401 Unauthorized. Addressuthentication failure; invalid credentials.402 Payment required. No Addressuthenticationctive subscription found.500 Internal server error. General service foundailure; retry request.History1.1.0 (2021-09-26)Replace requests with httpx for transport1.0.0 (2021-09-24)BREAKING!!! Remove Python 2 support and remove grequests based AsyncClientSmartyStreets.py is now tested against Python 3.7, 3.8, and 3.90.4.0 (2016-03-25)Add optional timeout value for client (pmkane!)0.3.0 (2016-03-10)Ensure keep-alive is used for client connections (pmkane!)Testing updates (pmkane!)0.2.4 (2015-03-15)Adds strict JSON serialization to async client as well0.2.3 (2015-03-15)Bugfix in logging suppression header0.2.2 (2015-01-29)Adds strict JSON serialization to ensure all-but-specified fields are
serialized into strings.0.2.1 (2014-11-17)Bugfix in plain string address input handling0.2.0 (2014-10-23)Added experimental async client0.1.0 (2014-10-21)First release on PyPI.