Using the Zillow Property API to extract Property Listings

Zestimate

Zillow Zestimate

Hey guys, it’s been more than a week since I last posted anything. Today, I am going to show you how to set up the Zillow API to parse details for property and real estate listings. It classifies as a mini Web development project and in general if you wished to extract all the info from Zillow’s Property Listings in one page, well, there you have it!

Alright, so let’s get started.

Step 1: Go to Zillow.com and create a new account by following the steps on the screen. (It is pretty straightforward to sign up here).

Note: You must SELECT the checkbox that says “I am an Industry Professional”. (Unless otherwise specified, normal users are not granted the permission to use the Zillow Web Search APIs).

Just fill your first name and last name, and the website you are using for hosting your web-page for parsing/extracting details from the API. Also, make sure to select the check-boxes labelled Mortgage API, Valuation API and Property Details API. For now, we will mostly be using only the Property Details API.

Step 2: After verifying your e-mail and creating your account successfully, you should have recieved a ZWSID (unique). If not, go to your My Zillow (top right) -> Settings -> Resend my ZWSID.

Note: The ZWSID is pretty much the only authentication you will need/have.

Step 3: Once you have your ZWSID ready, create a new PHP file and insert the following lines into your code:

$zwsid = "insertyourzwsidhere";
$prefixurl = "http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=";
$addr = urlencode("879 W 23rd street");
$cit = urlencode("Los Angeles");
$stat = urlencode("CA");
$csz = $cit."%2C+".$stat;
$query = $prefixurl.$zwsid."&address=".$addr."&citystatezip=".$csz."&rentzestimate=true";
$s = simplexml_load_file(trim($query));
echo json_encode($s);
if($s)
echo "Success" else echo "Failure"

If all goes well, you should have a JSON formatted output as shown :

JSON

JSON Sample Output

Step 4: Now, we need to parse each and every detail of the JSON output, doing this is pretty simple as it turns out, but pretty tedious.

First of all, simply do :
echo $query;, this should give you the following link http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=X1-ZWz1dxir1f12bv_6bk45&address=879+W+23rd+Street&citystatezip=Los+Angeles%2C+CA&rentzestimate=true Now you can download the subsequent XML file on that page (pointed to by the link, it will come in handy for parsing).

I will show an example parsed data. The rest can be done in pretty much the same way, for e.g., to extract the Zestimate of the property listing one can simply, traverse through the links of XML name tags upto the leaf element which contains the value for the Zestimate. This is because in the corresponding XML file, the zestimate amount is present inside the zestimate tag which is inside the result tag inside the results tag and which is inside the response tag, here “$s” is made to point to the root XML tag. Also, I have used “money_format()”, a PHP function that displays any number in currency format (by default, in US $).

$zestimate = money_format('%n',floatval($s->response->results->result->zestimate->amount));

Pretty simple stuff, really. You can explore the API’s other functions and calls further on Zillow’s pages for those API’s which I have listed here, and here.

Here is a link  to a working demo version (Keep in mind, this is just a working version and you can beautify the CSS, extract more information, put viewports and make the site into a complete stand-alone App by itself, but that isn’t the purpose of this post). That’s all folks, pretty short and simple post, I will update this blog with better stuff as and when I find time (or learn them (or both)).

Disclaimer: All content is copyright to Zillow (R) and I do not own, market anything on this site. It is simply from an educational and academic perspective.

© Zillow, Inc., 2006-2014. Use is subject to Terms of Use
What’s a Zestimate?