예제 #1
0
    def GetZEstimate(self, zws_id, zpid, retnzestimate=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.
        Zillow doesn't have Zestimates for all the homes in its database.
        For such properties, we do have tax assessment data, but that is not provided through the API.
        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)
        :return:
        """
        url = '%s/GetZestimate.htm' % (self.base_url)
        parameters = {'zws-id': zws_id,
                      'zpid': zpid}
        if retnzestimate:
            parameters['retnzestimate'] = 'true'

        resp = self._RequestUrl(url, 'GET', data=parameters)
        data = resp.content.decode('utf-8')

        xmltodict_data = xmltodict.parse(data)

        place = Place()
        try:
            place.set_data(xmltodict_data.get('Zestimate:zestimate', None)['response'])
        except:
            raise ZillowError({'message': "Zillow did not return a valid response: %s" % data})

        return place
예제 #2
0
    def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=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.
        It also includes the date the Zestimate was computed, a valuation range and the Zestimate ranking for the property within its ZIP code.
        The GetSearchResults API Web Service is located at: http://www.zillow.com/webservice/GetSearchResults.htm
        :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)
        :return:
        """
        url = '%s/GetSearchResults.htm' % (self.base_url)
        parameters = {'zws-id': zws_id}
        if address and citystatezip:
            parameters['address'] = address
            parameters['citystatezip'] = citystatezip
        else:
            raise ZillowError({'message': "Specify address and citystatezip."})
        if retnzestimate:
            parameters['retnzestimate'] = 'true'

        resp = self._RequestUrl(url, 'GET', data=parameters)
        data = resp.content.decode('utf-8')

        xmltodict_data = xmltodict.parse(data)

        place = Place()
        try:
            place.set_data(xmltodict_data.get('SearchResults:searchresults', None)['response']['results']['result'])
        except:
            raise ZillowError({'message': "Zillow did not return a valid response: %s" % data})

        return place
예제 #3
0
    def GetZEstimate(self, zws_id, zpid, retnzestimate=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.
        Zillow doesn't have Zestimates for all the homes in its database.
        For such properties, we do have tax assessment data, but that is not provided through the API.
        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)
        :return:
        """
        url = '%s/GetZestimate.htm' % (self.base_url)
        parameters = {'zws-id': zws_id, 'zpid': zpid}
        if retnzestimate:
            parameters['retnzestimate'] = 'true'

        resp = self._RequestUrl(url, 'GET', data=parameters)
        data = resp.content.decode('utf-8')

        xmltodict_data = xmltodict.parse(data)

        place = Place()
        try:
            place.set_data(
                xmltodict_data.get('Zestimate:zestimate', None)['response'])
        except:
            raise ZillowError({
                'message':
                "Zillow did not return a valid response: %s" % data
            })

        return place
예제 #4
0
    def GetDeepSearchResults(self, zws_id, address, citystatezip, retnzestimate=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.
        Moreover, this API call also gives rich property data like lot size, year built, bath/beds, last sale details etc.
        :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)
        :return:

        Example:
        """
        url = '%s/GetDeepSearchResults.htm' % (self.base_url)
        parameters = {'zws-id': zws_id,
                      'address': address,
                      'citystatezip': citystatezip
                      }

        if retnzestimate:
            parameters['retnzestimate'] = 'true'

        resp = self._RequestUrl(url, 'GET', data=parameters)
        data = resp.content.decode('utf-8')

        xmltodict_data = xmltodict.parse(data)

        place = Place(has_extended_data=True)
        try:
            place.set_data(xmltodict_data.get('SearchResults:searchresults', None)['response']['results']['result'])
        except:
            raise ZillowError({'message': "Zillow did not return a valid response: %s" % data})

        return place
예제 #5
0
    def GetSearchResults(self, zws_id, address, citystatezip, retnzestimate=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.
        It also includes the date the Zestimate was computed, a valuation range and the Zestimate ranking for the property within its ZIP code.
        The GetSearchResults API Web Service is located at: http://www.zillow.com/webservice/GetSearchResults.htm
        :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)
        :return:
        """
        url = '%s/GetSearchResults.htm' % (self.base_url)
        parameters = {'zws-id': zws_id}
        if address and citystatezip:
            parameters['address'] = address
            parameters['citystatezip'] = citystatezip
        else:
            raise ZillowError({'message': "Specify address and citystatezip."})
        if retnzestimate:
            parameters['retnzestimate'] = 'true'

        resp = self._RequestUrl(url, 'GET', data=parameters)
        data = resp.content.decode('utf-8')

        xmltodict_data = xmltodict.parse(data)

        place = Place()
        try:
            place.set_data(xmltodict_data.get('SearchResults:searchresults', None)['response']['results']['result'])
        except:
            raise ZillowError({'message': "Zillow did not return a valid response: %s" % data})

        return place
예제 #6
0
    def test_getcomps_principal(self):
        RAW_XML = ""
        with open('./testdata/get_comps.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        data = xmltodict.parse(RAW_XML)

        place = Place()
        place.set_data(data.get('Comps:comps')['response']['properties']['principal'])

        self.assertEqual("2100641621", place.zpid)
예제 #7
0
    def test_getcomps_principal(self):
        RAW_XML = ""
        with open('./testdata/get_comps.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        data = xmltodict.parse(RAW_XML)

        place = Place()
        place.set_data(data.get('Comps:comps')['response']['properties']['principal'])

        self.assertEqual("2100641621", place.zpid)
예제 #8
0
    def test_extended_data(self):
        RAW_XML = ""
        with open('./testdata/get_deep_search_results.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        data = xmltodict.parse(RAW_XML)

        place = Place(has_extended_data=True)
        place.set_data(data.get('SearchResults:searchresults', None)['response']['results']['result'])

        assert place.get_dict() is not None
예제 #9
0
    def test_extended_data(self):
        RAW_XML = ""
        with open('./testdata/get_deep_search_results.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        data = xmltodict.parse(RAW_XML)

        place = Place(has_extended_data=True)
        place.set_data(data.get('SearchResults:searchresults', None)['response']['results']['result'])

        assert place.get_dict() is not None
예제 #10
0
    def test_zestimate(self):
        RAW_XML = ""
        with open('./testdata/get_zestimate.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        data = xmltodict.parse(RAW_XML)

        place = Place()
        place.set_data(data.get('Zestimate:zestimate', None)['response'])

        self.assertEqual("2100641621", place.zpid)
        self.assertEqual(1723665, place.zestiamte.amount)
예제 #11
0
    def test_search_results(self):
        RAW_XML = ""
        with open('./testdata/place.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("2100641621", place.zpid)
        self.assertEqual(1723665, place.zestiamte.amount)
예제 #12
0
    def test_zestimate(self):
        RAW_XML = ""
        with open('./testdata/get_zestimate.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        data = xmltodict.parse(RAW_XML)

        place = Place()
        place.set_data(data.get('Zestimate:zestimate', None)['response'])

        self.assertEqual("2100641621", place.zpid)
        self.assertEqual(1723665, place.zestimate.amount)
예제 #13
0
    def test_search_results(self):
        RAW_XML = ""
        with open('./testdata/place.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("2100641621", place.zpid)
        self.assertEqual(1723665, place.zestiamte.amount)
예제 #14
0
    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)
예제 #15
0
    def test_getcomps_comps(self):
        RAW_XML = ""
        with open('./testdata/get_comps.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        data = xmltodict.parse(RAW_XML)
        comps = data.get('Comps:comps')['response']['properties']['comparables']['comp']

        comp_places = []

        for datum in comps:
            place = Place()
            place.set_data(datum)
            comp_places.append(place)

        self.assertEqual(10, len(comp_places))
예제 #16
0
    def test_getcomps_comps(self):
        RAW_XML = ""
        with open('./testdata/get_comps.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        data = xmltodict.parse(RAW_XML)
        comps = data.get('Comps:comps')['response']['properties']['comparables']['comp']

        comp_places = []

        for datum in comps:
            place = Place()
            place.set_data(datum)
            comp_places.append(place)

        self.assertEqual(10, len(comp_places))
예제 #17
0
    def GetDeepComps(self, zws_id, zpid, count=10, rentzestimate=False):
        """
        The GetDeepComps API returns a list of comparable recent sales for a specified property.
        The result set returned contains the address, Zillow property identifier, and Zestimate for the comparable
        properties and the principal property for which the comparables are being retrieved.
        This API call also returns rich property data for the comparables.
        :param zws_id: The Zillow Web Service Identifier.
        :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 rentzestimate: Return Rent Zestimate information if available (boolean true/false, default: false)
        :return:
        Example
            >>> data = api.GetDeepComps("<your key here>", 2100641621, 10)
        """
        url = '%s/GetDeepComps.htm' % (self.base_url)
        parameters = {'zws-id': zws_id,
                      'zpid': zpid,
                      'count': count}
        if rentzestimate:
            parameters['rentzestimate'] = 'true'

        resp = self._RequestUrl(url, 'GET', data=parameters)
        data = resp.content.decode('utf-8')

        # transform the data to an dict-like object
        xmltodict_data = xmltodict.parse(data)

        # get the principal property data
        principal_place = Place()
        principal_data = xmltodict_data.get('Comps:comps')['response']['properties']['principal']

        try:
            principal_place.set_data(principal_data)
        except:
            raise ZillowError({'message': 'No principal data found: %s' % data})

        # get the comps property_data
        comps = xmltodict_data.get('Comps:comps')['response']['properties']['comparables']['comp']

        comp_places = []
        for datum in comps:
            place = Place()
            try:
                place.set_data(datum)
                comp_places.append(place)
            except:
                output = "Zillow did not return a valid response"
                return output

        output = {
            'principal': principal_place,
            'comps': comp_places
        }

        return output
예제 #18
0
    def GetDeepSearchResults(self,
                             zws_id,
                             address,
                             citystatezip,
                             retnzestimate=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.
        Moreover, this API call also gives rich property data like lot size, year built, bath/beds, last sale details etc.
        :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)
        :return:
        """
        url = '%s/GetDeepSearchResults.htm' % (self.base_url)
        parameters = {
            'zws-id': zws_id,
            'address': address,
            'citystatezip': citystatezip
        }

        if retnzestimate:
            parameters['rentzestimate'] = 'true'

        resp = self._RequestUrl(url, 'GET', data=parameters)
        data = resp.content.decode('utf-8')

        xmltodict_data = xmltodict.parse(data)

        place = Place(has_extended_data=True)
        try:
            xmlresults = xmltodict_data.get(
                'SearchResults:searchresults',
                None)['response']['results']['result']
            if isinstance(xmlresults, list):
                xmlresults = xmlresults[0]
            place.set_data(xmlresults)
        except:
            raise ZillowError({
                'message':
                "Zillow did not return a valid response: %s" % data
            })

        return place
예제 #19
0
    def test_get_deep_comps(self):
        RAW_XML = ""
        with open('./testdata/get_deep_comps.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        xmltodict_data = xmltodict.parse(RAW_XML)

        # get the principal property data
        principal_place = Place()
        principal_data = xmltodict_data.get('Comps:comps')['response']['properties']['principal']

        assert principal_data is not None
예제 #20
0
    def test_zestiamte(self):
        """Test that the backward-compatible ``zestiamte`` works.

        This property should correctly return the ``zestimate``
        attribute and raise a DeprecationWarning about the changing
        name.

        """
        warnings.simplefilter('always', DeprecationWarning)

        with open('./testdata/get_zestimate.xml', 'r') as f:
            RAW_XML = ''.join(f.readlines())

        data = xmltodict.parse(RAW_XML)

        place = Place()
        place.set_data(data.get('Zestimate:zestimate', None)['response'])

        self.assertEqual(place.zestiamte, place.zestimate)

        with warnings.catch_warnings(record=True) as warning:
            place.zestiamte
            assert issubclass(warning[0].category, DeprecationWarning)
예제 #21
0
    def GetDeepComps(self, zws_id, zpid, count=10, rentzestimate=False):
        """
        The GetDeepComps API returns a list of comparable recent sales for a specified property.
        The result set returned contains the address, Zillow property identifier, and Zestimate for the comparable
        properties and the principal property for which the comparables are being retrieved.
        This API call also returns rich property data for the comparables.
        :param zws_id: The Zillow Web Service Identifier.
        :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 rentzestimate: Return Rent Zestimate information if available (boolean true/false, default: false)
        :return:
        Example
            >>> data = api.GetDeepComps("<your key here>", 2100641621, 10)
        """
        url = '%s/GetDeepComps.htm' % (self.base_url)
        parameters = {'zws-id': zws_id,
                      'zpid': zpid,
                      'count': count}
        if rentzestimate:
            parameters['rentzestimate'] = 'true'

        resp = self._RequestUrl(url, 'GET', data=parameters)
        data = resp.content.decode('utf-8')

        # transform the data to an dict-like object
        xmltodict_data = xmltodict.parse(data)

        # get the principal property data
        principal_place = Place()
        principal_data = xmltodict_data.get('Comps:comps')['response']['properties']['principal']

        try:
            principal_place.set_data(principal_data)
        except:
            raise ZillowError({'message': 'No principal data found: %s' % data})

        # get the comps property_data
        comps = xmltodict_data.get('Comps:comps')['response']['properties']['comparables']['comp']

        comp_places = []
        for datum in comps:
            place = Place()
            try:
                place.set_data(datum)
                comp_places.append(place)
            except:
                raise ZillowError({'message': 'No valid comp data found %s' % datum})

        output = {
            'principal': principal_place,
            'comps': comp_places
        }

        return output