First, grab your test API key and secret. If you don't already have a test API key and secret, generate them on your API Settings page.
Next, we'll make a GET request to the test_addresses
endpoint to retrieve a list of test addresses we can use with our test credentials. Keep in the mind, these test addresses can change periodically, so be sure to retrieve the latest ones before trying to use them.
In [1]:
import requests
import pprint
import getpass
test_key = 'test_SX599E3XL0N8P1D30512'
test_secret = getpass.getpass(prompt='Enter your API secret: ')
url = 'https://api.housecanary.com/v2/property/test_addresses'
response = requests.get(url, auth=(test_key, test_secret))
test_addresses = response.json()
pprint.pprint(test_addresses)
# NOTE: The test addresses change periodically,
# so the ones shown below may no longer be valid.
# Call this endpoint yourself to retrieve valid test addresses.
In [2]:
# Now that we've retrieved some test addresses, we can use one of them
# to test out the HouseCanary API endpoints.
# Let's try one of the Analytics API endpoints.
# we'll just take the first address from the list.
sample_address = test_addresses[0]
url = 'https://api.housecanary.com/v2/property/details'
params = {'address': sample_address['address'],
'zipcode': sample_address['zipcode']}
response = requests.get(url, params=params, auth=(test_key, test_secret))
# We can see what the url looks like
print(response.url)
In [3]:
# print the output
pprint.pprint(response.json())
In [4]:
# Let's try the Value Report API.
url = 'https://api.housecanary.com/v2/property/value_report'
params = {'address': sample_address['address'],
'zipcode': sample_address['zipcode'],
'format': 'json'}
response = requests.get(url, params=params, auth=(test_key, test_secret))
print(response.url)
# use response.json() to get the Value Report json. The content is too long to display here.
In [5]:
# Finally, let's try the Rental Report API.
url = 'https://api.housecanary.com/v2/property/rental_report'
params = {'address': sample_address['address'],
'zipcode': sample_address['zipcode'],
'format': 'json'}
response = requests.get(url, params=params, auth=(test_key, test_secret))
print(response.url)
# use response.json() to get the Rental Report json. The content is too long to display here.