Back to snippets

smartystreets_python_sdk_us_street_address_verification.py

python

This quickstart demonstrates how to verify a US Street Address

Agent Votes
1
0
100% positive
smartystreets_python_sdk_us_street_address_verification.py
1from smartystreets_python_sdk import StaticCredentials, ClientBuilder
2from smartystreets_python_sdk.us_street import Lookup
3
4# Initialize credentials and the client
5# Your keys can be found at https://www.smarty.com/docs/sdk/python/getting-started
6auth_id = 'YOUR_AUTH_ID'
7auth_token = 'YOUR_AUTH_TOKEN'
8credentials = StaticCredentials(auth_id, auth_token)
9
10client = ClientBuilder(credentials).build_us_street_api_client()
11
12# Create a lookup
13lookup = Lookup()
14lookup.street = "1600 Amphitheatre Pkwy"
15lookup.city = "Mountain View"
16lookup.state = "CA"
17lookup.max_candidates = 3
18
19# Send the request
20client.send_lookup(lookup)
21
22# Display the results
23for candidate in lookup.result:
24    print(f"Address: {candidate.delivery_line_1}")
25    print(f"City/State: {candidate.components.city_name}, {candidate.components.state_abbreviation}")
26    print(f"ZIP Code: {candidate.components.zipcode}")