HouseCanary API - Using Test API Credentials

This tutorial will show you how to use the HouseCanary API with test API keys and addresses. First we'll make a GET request using our test API key and secret to retrieve test addresses. Then we'll use those addresses to call the various HouseCanary API endpoints such as the Analytics API, the Value Report API and the Rental Report API.

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.


Enter your API secret: ········
[{u'address': u'7904 Verde Springs Dr', u'zipcode': u'89128'},
 {u'address': u'8691 Flowersong Cv', u'zipcode': u'33473'},
 {u'address': u'22905 Cielo Vis', u'zipcode': u'78255'},
 {u'address': u'16 Thomas Ave', u'zipcode': u'03076'},
 {u'address': u'1111 Oronoco St Unit 441', u'zipcode': u'22314'},
 {u'address': u'2718 16th Ave S', u'zipcode': u'55407'},
 {u'address': u'590 Foothill Rd', u'zipcode': u'95023'},
 {u'address': u'30737 County Road 356-6', u'zipcode': u'81211'},
 {u'address': u'333 N Canal St Apt 2901', u'zipcode': u'60606'},
 {u'address': u'3466 Erie Shore Dr', u'zipcode': u'48162'}]

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)


https://api.housecanary.com/v2/property/details?zipcode=89128&address=7904+Verde+Springs+Dr

In [3]:
# print the output
pprint.pprint(response.json())


[{u'address_info': {u'address': u'7904 Verde Springs Dr',
                    u'address_full': u'7904 Verde Springs Dr Las Vegas NV 89128',
                    u'city': u'Las Vegas',
                    u'county_fips': u'32003',
                    u'geo_precision': u'rooftop',
                    u'lat': 36.19194,
                    u'lng': -115.26735,
                    u'state': u'NV',
                    u'unit': None,
                    u'zipcode': u'89128',
                    u'zipcode_plus4': u'7333'},
  u'property/details': {u'api_code': 0,
                        u'api_code_description': u'ok',
                        u'result': {u'assessment': {u'assessment_year': 2016,
                                                    u'tax_amount': 1270.51,
                                                    u'tax_year': 2015,
                                                    u'total_assessed_value': 45636.0},
                                    u'property': {u'air_conditioning': u'central',
                                                  u'attic': None,
                                                  u'basement': None,
                                                  u'building_area_sq_ft': 1190,
                                                  u'exterior_walls': u'stucco',
                                                  u'fireplace': True,
                                                  u'full_bath_count': None,
                                                  u'garage_parking_of_cars': 2,
                                                  u'garage_type_parking': u'attached_garage',
                                                  u'heating': u'forced_air_unit',
                                                  u'heating_fuel_type': None,
                                                  u'no_of_buildings': 0,
                                                  u'no_of_stories': None,
                                                  u'number_of_bedrooms': 3,
                                                  u'number_of_units': 0,
                                                  u'partial_bath_count': None,
                                                  u'pool': None,
                                                  u'property_type': u'Single Family Residential',
                                                  u'sewer': None,
                                                  u'site_area_acres': 0.09,
                                                  u'style': None,
                                                  u'subdivision': u'SANTA FE-PHASE 1',
                                                  u'total_bath_count': 2.0,
                                                  u'total_number_of_rooms': 5,
                                                  u'water': None,
                                                  u'year_built': 1993}}}}]

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.


https://api.housecanary.com/v2/property/value_report?format=json&zipcode=89128&address=7904+Verde+Springs+Dr

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.


https://api.housecanary.com/v2/property/rental_report?format=json&zipcode=89128&address=7904+Verde+Springs+Dr