-
-
Save bhubbard/e28986eb0cd4fa509f6c274b95601a23 to your computer and use it in GitHub Desktop.
Get Zillow Estimate and Image from Zillow's API, Quick and Dirty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Quick and dirty, should be wrapped better but this is just a demo */ | |
var app = app || {}; | |
app.apikeys = app.apikeys || {}; | |
app.urls = app.urls || {}; | |
app.methods = app.methods || {}; | |
app.apikeys.zillow = 'YOUR API KEY HERE'; | |
app.urls.zillow = { | |
getSearchResults: 'http://www.zillow.com/webservice/GetSearchResults.htm', | |
getUpdatedPropertyDetails: 'http://www.zillow.com/webservice/GetUpdatedPropertyDetails.htm' | |
}; | |
/* | |
@input: address, city, state, zip, | |
@callback: function(error, output) | |
@return: valid input | |
*/ | |
app.methods.getZillowEstimate = function(input, callback) { | |
var key = app.apikeys.zillow; | |
var address, city, state, citystate, zip; | |
var address = input.address; | |
var city = input.city; | |
var state = input.state; | |
var citystate = city+', '+state; | |
var zip = input.zip; | |
var response = {}; | |
var citystatezip = zip; | |
if(!zip && !city && !state) { | |
return false; | |
} else if(city && state) { | |
citystatezip = citystate; | |
} | |
$.post(app.urls.zillow.getSearchResults, | |
{ | |
'zws-id': app.apikeys.zillow, | |
'address': address, | |
'citystatezip': citystatezip, | |
'rentzestimate': true | |
}, | |
function(xml){ | |
var $xml = $(xml); | |
var amount = $xml | |
.find('response') | |
.find('results') | |
.find('result:eq(0)') | |
.find('zestimate') | |
.find('amount').text(); | |
response.marketValue = amount; | |
var zpid = $xml | |
.find('response') | |
.find('results') | |
.find('result:eq(0)') | |
.find('zpid').text(); | |
if(!zpid) { | |
return callback(null, response); | |
} | |
$.post(app.urls.zillow.getUpdatedPropertyDetails, | |
{ | |
'zws-id': key, | |
'zpid': zpid | |
}, | |
function(x) { | |
$x = $(x); | |
var img = $x | |
.find('response') | |
.find('images') | |
.find('image:eq(0)') | |
.find('url').text(); | |
response.image = img; | |
return callback(null, response); | |
}) | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you assist me in using vb.net to search for a property and then if found gain access to the images of the property that are on the zillow website?