Skip to content

Instantly share code, notes, and snippets.

@ibuilder
Last active September 14, 2021 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibuilder/606dea2452005a4b547181d224b166b2 to your computer and use it in GitHub Desktop.
Save ibuilder/606dea2452005a4b547181d224b166b2 to your computer and use it in GitHub Desktop.
API call for Attom demographics Python
import http.client
import json
conn = http.client.HTTPSConnection("api.gateway.attomdata.com")
headers = {
'accept': "application/json",
'apikey': "xxx",
}
address = str.replace("4529 Winona Court", ' ', '%20')
city = str.replace("Denver", ' ', '%20')
state = "CO"
print(address)
print(city)
url = "/propertyapi/v1.0.0/property/detail?address1=" + \
address + "&address2=" + city + "%2C%20" + state
print(url)
conn.request("GET", url, headers=headers)
res = conn.getresponse()
data = res.read()
output = data.decode("utf-8")
print(output)
with open('output.json', 'w') as outfile:
json.dump(output, outfile, ensure_ascii=False, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment