diff --git a/testdata/rent_zestimate.xml b/testdata/rent_zestimate.xml new file mode 100644 index 0000000..58a2402 --- /dev/null +++ b/testdata/rent_zestimate.xml @@ -0,0 +1,75 @@ + + + +
2114 Bigelow Ave
+ Seattle, WA +
+ + Request successfully processed + 0 + + + + + 48749425 + + http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/ + http://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/#charts-and-data + http://www.zillow.com/homes/48749425_zpid/ + http://www.zillow.com/homes/comps/48749425_zpid/ + +
+ 2114 Bigelow Ave N + 98109 + Seattle + WA + 47.637933 + -122.347938 +
+ 53033 + SingleFamily + 2014 + 1060000.0 + 1924 + 4680 + 3470 + 3.0 + 4 + 11/26/2008 + 1025000 + + 1399263 + 02/23/2016 + + -11305 + + 1301315 + 1511204 + + 0 + + + 5495 + 02/24/2016 + + 17 + + 4011 + 6209 + + + + + 727,500 + + http://www.zillow.com/local-info/WA-Seattle/East-Queen-Anne/r_271856/ + http://www.zillow.com/east-queen-anne-seattle-wa/fsbo/ + http://www.zillow.com/east-queen-anne-seattle-wa/ + + + +
+
+
+
+ diff --git a/tests/test_valuation.py b/tests/test_valuation.py index b0ab144..2ba0be9 100644 --- a/tests/test_valuation.py +++ b/tests/test_valuation.py @@ -57,6 +57,22 @@ def test_zestiamte(self): place.zestiamte assert issubclass(warning[0].category, DeprecationWarning) + def test_rent_zestimate(self): + RAW_XML = "" + with open('./testdata/rent_zestimate.xml', 'r') as f: + RAW_XML = ''.join(f.readlines()) + + data = xmltodict.parse(RAW_XML) + + place = Place() + place.set_data(data.get('SearchResults:searchresults', None)['response']['results']['result']) + + self.assertEqual("48749425", place.zpid) + self.assertEqual(5495, place.rentzestimate.amount) + self.assertEqual(4011, place.rentzestimate.valuation_range_low) + self.assertEqual(6209, place.rentzestimate.valuation_range_high) + self.assertEqual(17, place.rentzestimate.amount_change_30days) + def test_getcomps_principal(self): RAW_XML = "" with open('./testdata/get_comps.xml', 'r') as f: diff --git a/zillow/api.py b/zillow/api.py index 56dca5b..c04d821 100644 --- a/zillow/api.py +++ b/zillow/api.py @@ -32,7 +32,7 @@ def __init__(self): self.__auth = None self._timeout = None - def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): + def GetSearchResults(self, zws_id, address, citystatezip, rentzestimate=False): """ The GetSearchResults API finds a property for a specified address. The content returned contains the address for the property or properties as well as the Zillow Property ID (ZPID) and current Zestimate. @@ -41,7 +41,7 @@ def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): :param zws_id: The Zillow Web Service Identifier. Each subscriber to Zillow Web Services is uniquely identified by an ID sequence and every request to Web services requires this ID. :param address: The address of the property to search. This string should be URL encoded. :param citystatezip: The city+state combination and/or ZIP code for which to search. This string should be URL encoded. Note that giving both city and state is required. Using just one will not work. - :param retnzestimat: Return Rent Zestimate information if available (boolean true/false, default: false) + :param rentzestimat: Return Rent Zestimate information if available (boolean true/false, default: false) :return: """ url = '%s/GetSearchResults.htm' % (self.base_url) @@ -51,8 +51,8 @@ def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): parameters['citystatezip'] = citystatezip else: raise ZillowError({'message': "Specify address and citystatezip."}) - if retnzestimate: - parameters['retnzestimate'] = 'true' + if rentzestimate: + parameters['rentzestimate'] = 'true' resp = self._RequestUrl(url, 'GET', data=parameters) data = resp.content.decode('utf-8') @@ -67,7 +67,7 @@ def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): return place - def GetZEstimate(self, zws_id, zpid, retnzestimate=False): + def GetZEstimate(self, zws_id, zpid, rentzestimate=False): """ The GetZestimate API will only surface properties for which a Zestimate exists. If a request is made for a property that has no Zestimate, an error code is returned. @@ -76,14 +76,14 @@ def GetZEstimate(self, zws_id, zpid, retnzestimate=False): For more information, see our Zestimate coverage. :zws_id: The Zillow Web Service Identifier. :param zpid: The address of the property to search. This string should be URL encoded. - :param retnzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) + :param rentzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) :return: """ url = '%s/GetZestimate.htm' % (self.base_url) parameters = {'zws-id': zws_id, 'zpid': zpid} - if retnzestimate: - parameters['retnzestimate'] = 'true' + if rentzestimate: + parameters['rentzestimate'] = 'true' resp = self._RequestUrl(url, 'GET', data=parameters) data = resp.content.decode('utf-8') @@ -98,7 +98,7 @@ def GetZEstimate(self, zws_id, zpid, retnzestimate=False): return place - def GetDeepSearchResults(self, zws_id, address, citystatezip, retnzestimate=False): + def GetDeepSearchResults(self, zws_id, address, citystatezip, rentzestimate=False): """ The GetDeepSearchResults API finds a property for a specified address. The result set returned contains the full address(s), zpid and Zestimate data that is provided by the GetSearchResults API. @@ -106,7 +106,7 @@ def GetDeepSearchResults(self, zws_id, address, citystatezip, retnzestimate=Fals :zws_id: The Zillow Web Service Identifier. :param address: The address of the property to search. This string should be URL encoded. :param citystatezip: The city+state combination and/or ZIP code for which to search. - :param retnzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) + :param rentzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) :return: Example: @@ -117,8 +117,8 @@ def GetDeepSearchResults(self, zws_id, address, citystatezip, retnzestimate=Fals 'citystatezip': citystatezip } - if retnzestimate: - parameters['retnzestimate'] = 'true' + if rentzestimate: + parameters['rentzestimate'] = 'true' resp = self._RequestUrl(url, 'GET', data=parameters) data = resp.content.decode('utf-8') @@ -195,7 +195,7 @@ def GetComps(self, zws_id, zpid, count=25, rentzestimate=False): and Zestimate for the comparable properties and the principal property for which the comparables are being retrieved. :param zpid: The address of the property to search. This string should be URL encoded. :param count: The number of comparable recent sales to obtain (integer between 1 and 25) - :param retnzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) + :param rentzestimate: Return Rent Zestimate information if available (boolean true/false, default: false) :return: """ url = '%s/GetComps.htm' % (self.base_url) diff --git a/zillow/place.py b/zillow/place.py index 8141d62..0df6eb1 100644 --- a/zillow/place.py +++ b/zillow/place.py @@ -171,6 +171,7 @@ def __init__(self, has_extended_data=False): self.links = Links() self.full_address = FullAddress() self.zestimate = ZEstimateData() + self.rentzestimate = ZEstimateData() self.local_realestate = LocalRealEstate() self.similarity_score = None self.extended_data = ExtendedData() @@ -199,6 +200,8 @@ def set_data(self, source_data): self.links.set_data(source_data['links']) self.full_address.set_data(source_data['address']) self.zestimate.set_data(source_data['zestimate']) + if 'rentzestimate' in source_data.keys(): + self.rentzestimate.set_data(source_data['rentzestimate']) self.local_realestate.set_data(source_data['localRealEstate']) if self.has_extended_data: self.extended_data.set_data(source_data) @@ -210,6 +213,7 @@ def get_dict(self): 'links': self.links.get_dict(), 'full_address': self.full_address.get_dict(), 'zestimate': self.zestimate.get_dict(), + 'rentzestimate': self.rentzestimate.get_dict(), 'local_realestate': self.local_realestate.get_dict(), 'extended_data': self.extended_data.get_dict() }