Last active
September 14, 2021 21:29
-
-
Save ibuilder/606dea2452005a4b547181d224b166b2 to your computer and use it in GitHub Desktop.
API call for Attom demographics Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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