Search code examples
javascriptapizillow

How to call Zillow API with JavaScript?


I'm new to APIs and am trying to figure out how to make a Zillow call with JavaScript, specifically the "getsearchresults". Thanks


Solution

  • You'll need to use Javascript on the server-side using Node. It won't be possible to call the API on the front-end with Javascript. See this answer.

    For using Node to call the Zillow API, check out the node-zillow package. Here's an example of how to use it with the GetSearchResults API call:

    const Zillow = require("node-zillow")
    
    const zillow = new Zillow('your key here')
    
    const parameters = {
        address: "2114 Bigelow Ave",
        citystatezip: "Seattle, WA",
        rentzestimate: false
    }
    
    zillow.get('GetSearchResults', parameters)
        .then(results => {
            console.log(results)
            return results
        })
    

    Make sure you signup for ZWSID here: https://www.zillow.com/webservice/Registration.htm. You'll use this unique id when making the request to the API. It'll look something like this: X2-Ijdjkxlujnkd_jske2. Keep it secret, keep it safe!