Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send data to an API call and get it back, using zillow.com API

Tags:

I am trying to get the API from a website called zillow working for me, but I am way new to web stuff. They try and explain here how to use it, but it had me lost so I looked in their forums. Someone posted an "example" there, but I can not see where their code even calls the API. Basically I need to take a form field that will be an address and send that info to get data back, here is the source code taken from the guys example,

<html xml:lang="en" lang="en">
<head>
  <title></title>
</head>
<body>
<h3><font face="Verdana, Arial, Helvetica, sans-serif">Get Property < # >Zestimates 
  from Zillow</a></font></h3>
<form method="post" action="/Real-Estate/Zestimate.php" name="zip_search">
  <table align="center" width="618">
    <tr> 
      <td colspan="2"><font face="verdana, arial, sans-serif">Please specify the 
        Property address. </font></td>

      <td width="205" align="left"> <div align="left"><font face="Verdana, Arial, Helvetica, sans-serif"><#></a></font></div></td>
    </tr>
    <tr> 
      <td colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif">Street</font>: 
        <input id="street2" type="text" maxlength="50" size="50" value="" name="street"/></td>
      <td>&nbsp;</td>
    </tr>
    <tr> 
      <td colspan="2"><font face="verdana, arial, sans-serif">City, State or ZipCode:</font> 
        <input id="citystatezip3" type="text" maxlength="50" size="20" value="" name="citystatezip"/></td>

      <td>&nbsp; </td>
    </tr>

  </table>
  <div align="center">
    <input name="submit" type="submit" value="Get Zestimate">
  </div>
</form>

You can see it is just a simple form that posts to itself right? But when I hit go it pulls the data from the API and displays it, but I do not see how. I would love any help you can offer, thank you!

like image 383
thatryan Avatar asked Jul 07 '09 06:07

thatryan


People also ask

How do I pull data from Zillow?

Click “Sitemap zillow” in the navigation menu, then hit scrape and let the scraper do its thing. When it's complete (or you think it has looked at enough properties), you can click on “Export data as CSV” and load it into your spreadsheet.

Does the Zillow API still work?

So the main topic today is Zillow's API will be deprecated on September 30th which we assume thousands of businesses are utilizing today and will no longer have access to the real estate information they used to access for free.

Does Zillow allow web scraping?

You may not use the Zillow Data to provide a service for other businesses. You must use commercially reasonable efforts to prevent the Zillow Data from being downloaded in bulk or otherwise scraped.


1 Answers

Based on http://www.zillow.com/howto/api/APIFAQ.htm#devkit, there is no JavaScript API. Because of this (and cross-domain restrictions) you have to use a server-side language. I'll add a simple Java example.

EDIT: Okay, here goes. It just takes the street address and city/state, and returns a formatted value. Error-checking left out:

import java.text.NumberFormat;

import org.w3c.dom.*;
import org.xml.sax.*;

import javax.xml.parsers.*;

import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;

import java.io.*;

import java.util.Currency;

public class Zillow
{
    private static final DocumentBuilderFactory dbFac;
    private static final DocumentBuilder docBuilder;
    static
    {
        try
        {
            dbFac = DocumentBuilderFactory.newInstance();
            docBuilder = dbFac.newDocumentBuilder();
        }
        catch(ParserConfigurationException e)
        {
            throw new RuntimeException(e);
        }
    }
    private static final String DEEP_URL = "http://www.zillow.com/webservice/GetDeepSearchResults.htm";
    private static final String ZESTIMATE_URL = "http://www.zillow.com/webservice/GetZestimate.htm";

    private static final String ZWSID = ...;

    private static final NumberFormat nf = NumberFormat.getCurrencyInstance();

    // Returns Zestimate value for address.
    public static String getValuation(String address, String cityStateZip) throws SAXException, IOException
    {
        Document deepDoc = docBuilder.parse(DEEP_URL + 
                                        "?zws-id=" + ZWSID + 
                                        "&address=" + address + 
                                        "&citystatezip=" + cityStateZip);
        Element firstResult = (Element)deepDoc.getElementsByTagName("result").item(0);
        String zpid = firstResult.getElementsByTagName("zpid").item(0).getTextContent();
        Document valueDoc = docBuilder.parse(ZESTIMATE_URL + 
                                             "?zws-id=" + ZWSID + 
                                             "&zpid=" + zpid);
        Element zestimate = (Element)valueDoc.getElementsByTagName("zestimate").item(0);
        Element amount = (Element)zestimate.getElementsByTagName("amount").item(0);
        String currency = amount.getAttribute("currency");
        nf.setCurrency(Currency.getInstance(currency));
        return nf.format(Double.parseDouble(amount.getTextContent()));
    }

    public static void main(String[] args) throws Throwable
    {
        String address = args[0];
        String cityStateZip = args[1];
        System.out.println(getValuation(address, cityStateZip));
    }
}
like image 193
Matthew Flaschen Avatar answered Oct 11 '22 14:10

Matthew Flaschen