Last active
January 16, 2020 05:25
-
-
Save slickplaid/0d71ec82d3434c05369c to your computer and use it in GitHub Desktop.
Get Zillow Estimate and Image from Zillow's API, Quick and Dirty
This file contains 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
I would like to be able to use vb.net to send a request to zillow for a specific property and from the result gain access to the images for the property that are on zillow. Can you assist with ideas?