rillow 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README +6 -0
  2. data/lib/rillow.rb +281 -0
  3. metadata +55 -0
data/README ADDED
@@ -0,0 +1,6 @@
1
+ # This api is created by Leo Chan on 10/29/2007.
2
+ # There is no license requirement. Use it or copy any part of the code that you want to use.
3
+ # Rillow is a simple ruby wrapper to zillow webservice api: http://www.zillow.com/howto/api/APIOverview.htm
4
+ # It does the web service call and gets the result back for you. You don't have to know about the url request formate, url encoding or
5
+ # parsing the result. The result object is in hash/array format. So no need to parse xml.
6
+ # You will need to register with zillow to get the Zillow Web Service Identifier first.
@@ -0,0 +1,281 @@
1
+ #!/usr/bin/ruby
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'rubygems'
5
+ require 'xmlsimple'
6
+
7
+ # This api is created by Leo Chan on 10/29/2007.
8
+ # There is no license requirement. Use it or copy any part of the code that you want to use.
9
+ # Rillow is a simple ruby wrapper to zillow webservice api: http://www.zillow.com/howto/api/APIOverview.htm
10
+ # It does the web service call and gets the result back for you. You don't have to know about the url request, url encoding or
11
+ # parsing the result. The result object is in hash/array format. So no need to parsse xml.
12
+ # You will need to register with zillow to get the Zillow Web Service Identifier first.
13
+ # You will need to pass the Zillow Web Service Identifier to the constructor.
14
+ # This wrapper depends on xmlsimple.
15
+ #
16
+ # Example:
17
+ # rillow = Rillow.new('your-zillow-service identifier')
18
+ # result = rillow.get_search_results('2114 Bigelow Ave','Seattle, WA')
19
+ class Rillow
20
+ @@zillow_webservice_url='http://www.zillow.com/webservice/'
21
+
22
+ # rillow = Rillow.new('your-zillow-service identifier')
23
+ def initialize(zwsid)
24
+ @zwsid=zwsid
25
+ end
26
+
27
+ #The get_search_results finds a property for a specified address.
28
+ #The content returned contains the address for the property or properties as well as the Zillow Property ID (ZPID) and current Zestimate.
29
+ #It also includes the date the Zestimate was computed, a valuation range and the Zestimate ranking for the property within its ZIP code.
30
+ #If no exact address match for a property is found, a list of closely matching properties is returned.
31
+ #See: http://www.zillow.com/howto/api/GetSearchResults.htm
32
+ # parameter:
33
+ # address street address
34
+ # citystatezip city&state or zip code
35
+ #Example:
36
+ # rillow = Rillow.new('your-zillow-service identifier')
37
+ # result = rillow.get_search_results('2114 Bigelow Ave','Seattle, WA')
38
+ # result.to_hash
39
+ def get_search_results(address,citystatezip)
40
+ url_s=@@zillow_webservice_url+'GetSearchResults.htm?zws-id='+@zwsid+'&address='+address.to_s+'&citystatezip='+citystatezip.to_s
41
+ fetch_result(url_s)
42
+ end
43
+
44
+ #For a specified Zillow property identifier (zpid), the get_zestimate returns:
45
+ #1. The most recent property Zestimate
46
+ #2. The date the Zestimate was computed
47
+ #3. The valuation range
48
+ #4. The Zestimate ranking within the property's ZIP code.
49
+ #5. The full property address and geographic location (latitude/longitude) and a set of identifiers that uniquely represent the region (ZIP code, city, county & state) in which the property exists.
50
+ #The GetZestimate API will only surface properties for which a Zestimate exists.
51
+ #If a request is made for a property that has no Zestimate, an error code is returned.
52
+ #See: http://www.zillow.com/howto/api/GetZestimate.htm
53
+ #parameter:
54
+ # zpid zillow property id
55
+ #Example:
56
+ # rillow = Rillow.new('your-zillow-service identifier')
57
+ # result = rillow.get_zestimate('48749425')
58
+ # result.to_hash
59
+ def get_zestimate(zpid)
60
+ url_s=@@zillow_webservice_url+'GetZestimate.htm?zws-id='+@zwsid+'&zpid='+zpid.to_s
61
+ fetch_result(url_s)
62
+ end
63
+
64
+ #The get_chart api generates a URL for an image file that displays historical Zestimates for a specific property.
65
+ #The API accepts as input the Zillow Property ID as well as a chart type: either percentage or dollar value change.
66
+ #Optionally, the API accepts width and height parameters that constrain the size of the image.
67
+ #The historical data can be for the past 1 year, 5 years or 10 years.
68
+ #See: http://www.zillow.com/howto/api/GetChart.htm
69
+ #parameters:
70
+ #require:
71
+ # zpid: The Zillow Property ID for the property; the parameter type is an integer
72
+ # unit_type: A string value that specifies whether to show the percent change, parameter value of "percent,"
73
+ # or dollar change, parameter value of "dollar"
74
+ #options:
75
+ # :width => width of the generated graph. The value must be between 200 and 600, inclusive
76
+ # :height=> height of the generated graph. The value must be between 100 and 300, inclusive.
77
+ # :chart_duration => The duration of past data that needs to be shown in the chart. Valid values are "1year",
78
+ # "5years" and "10years". If unspecified, the value defaults to "1year"
79
+ #Example:
80
+ # rillow = Rillow.new('your-zillow-service identifier')
81
+ # result = rillow.get_chart('48749425','percent',:width=>300, :height=>150, :chart_duration=>'5years')
82
+ # result.to_hash
83
+ def get_chart(zpid,unit_type,options={})
84
+ url_s=@@zillow_webservice_url+'GetChart.htm?zws-id='+@zwsid+'&zpid='+zpid.to_s+'&unit-type='+unit_type.to_s
85
+ if options[:width]!=nil then
86
+ url_s=url_s+'&width='+options[:width].to_s
87
+ end
88
+ if options[:height]!=nil then
89
+ url_s=url_s+'&height='+options[:height].to_s
90
+ end
91
+ if options[:chart_duration]!=nil then
92
+ url_s=url_s+'&chartDuration='+options[:chart_duration].to_s
93
+ end
94
+ fetch_result(url_s)
95
+ end
96
+
97
+ #The get_region_chart generates a URL for an image file that displays the historical Zestimates for a specific geographic region.
98
+ #The API accepts as input the name of the region as well as a chart type: either percentage or dollar value change. #
99
+ #Optionally, the API accepts width and height parameters that constrain the size of the image.
100
+ #The historical data can be for the past 1 year, 5 years or 10 years.
101
+ #see: http://www.zillow.com/howto/api/GetRegionChart.htm
102
+ #parameters:
103
+ #require:
104
+ # unit_type: A string value that specifies whether to show the percent change, parameter value of "percent,"
105
+ # or dollar change, parameter value of "dollar"
106
+ #options:
107
+ # :city=> name of the city
108
+ # :state=> The two-letter abbreviation for a state
109
+ # :zip=> The 5-digit ZIP code
110
+ # :width=> width of the generated graph. The value must be between 200 and 600, inclusive
111
+ # :height=> height of the generated graph. The value must be between 100 and 300, inclusive.
112
+ # :chart_duration => The duration of past data that needs to be shown in the chart. Valid values are "1year",
113
+ # "5years" and "10years". If unspecified, the value defaults to "1year"
114
+ #Example:
115
+ # rillow = Rillow.new('your-zillow-service identifier')
116
+ # result = rillow.get_region_chart('percent',:city=>'seattle',:state=>'WA',:width=>300, :height=>150, :chart_duration=>'5years')
117
+ # result.to_hash
118
+ def get_region_chart(unit_type,options={})
119
+ url_s=@@zillow_webservice_url+'GetRegionChart.htm?zws-id='+@zwsid+'&unit-type='+unit_type.to_s
120
+ if options[:city]!=nil then
121
+ url_s=url_s+'&city='+options[:city].to_s
122
+ end
123
+ if options[:state]!=nil then
124
+ url_s=url_s+'&state='+options[:state].to_s
125
+ end
126
+ if options[:zip]!=nil then
127
+ url_s=url_s+'&ZIP='+options[:zip].to_s
128
+ end
129
+ if options[:width]!=nil then
130
+ url_s=url_s+'&width='+options[:width].to_s
131
+ end
132
+ if options[:height]!=nil then
133
+ url_s=url_s+'&height='+options[:height].to_s
134
+ end
135
+ if options[:chart_duration]!=nil then
136
+ url_s=url_s+'&chartDuration='+options[:chart_duration].to_s
137
+ end
138
+ fetch_result(url_s)
139
+ end
140
+
141
+ #For a specified region, the GetDemographics API returns a set of demographic data which includes:
142
+ # * A URL linking to the corresponding demographics page at Zillow.com
143
+ # * Census Information (i.e. total population, median household income, recent homeowners, etc)
144
+ # * Age Distributions
145
+ # * Who Lives Here (if available for the region)
146
+ # * What's Unique About the People (if available for the region)
147
+ # A region can be specified either through its respective Region ID or by providing one to three parameters:
148
+ # state, city, neighborhood. The neighborhood parameter can be omitted if demographic data on a city is desired.
149
+ # The state and city parameter are always required.
150
+ # see: http://www.zillow.com/howto/api/GetDemographics.htm
151
+ # parameters:
152
+ # :rid => region id
153
+ # :city=> name of the city
154
+ # :state=> The two-letter abbreviation for a state
155
+ # :neighborhood=> The neighborhood of the region to retrieve data
156
+ #Example:
157
+ # rillow = Rillow.new('your-zillow-service identifier')
158
+ # result = rillow.get_demographics(:city=>'seattle',:state=>'WA',:neighborhood=>'Ballard')
159
+ # result.to_hash
160
+ def get_demographics(options={})
161
+ url_s=@@zillow_webservice_url+'GetDemographics.htm?zws-id='+@zwsid
162
+ if options[:city]!=nil then
163
+ url_s=url_s+'&city='+options[:city].to_s
164
+ end
165
+ if options[:state]!=nil then
166
+ url_s=url_s+'&state='+options[:state].to_s
167
+ end
168
+ if options[:rid]!=nil then
169
+ url_s=url_s+'&rid='+options[:rid].to_s
170
+ end
171
+ if options[:neighborhood]!=nil then
172
+ url_s=url_s+'&neighborhood='+options[:neighborhood].to_s
173
+ end
174
+ fetch_result(url_s)
175
+ end
176
+
177
+ # For a specified region, the get_region_children API returns a list of subregions with the following information:
178
+ # * Subregion Type
179
+ # * Region IDs
180
+ # * Region Names
181
+ # * Latitudes and Longitudes
182
+ #A region can be specified at various levels of the region hierarchy.
183
+ #An optional childtype parameter can also be specified to return subregions of a specific type.
184
+ #Allowable region types include:
185
+ #country, state, county, and city. Country and county are optional parameters unless they are the region to be specified.
186
+ #Possible childtype parameters include: state, county, city, zipcode, and neighborhood.
187
+ #Any childtype parameter can be specified as long as the childtype parameter is a subregion type
188
+ #(i.e.. you cannot retrieve the subregion counties of a city).
189
+ #The only exception is that only subregion state can be specified for a country (otherwise it returns too many results).
190
+ #
191
+ #Childtype parameter is optional and defaults to types dependent on the specified region type:
192
+ #country defaults to return subregions of type state, state -> county, county -> city, city -> zipcode.
193
+ #see: http://www.zillow.com/howto/api/GetRegionChildren.htm
194
+ #parameters:
195
+ # :city=> name of the city. The city of the region to retrieve subregions from.
196
+ # :state=> The two-letter abbreviation for a state. The state of the region to retrieve subregions from.
197
+ # :country=> The country of the region to retrieve subregions from.
198
+ # :rid=> The regionId of the region to retrieve subregions from.
199
+ # :childtype=> The type of subregions to retrieve (available types: state, county, city, zipcode, and neighborhood)
200
+ # Example:
201
+ # rillow = Rillow.new('your-zillow-service identifier')
202
+ # result = rillow.get_region_children(:city=>'seattle',:state=>'WA',:country=>'united states',:childtype=>'neighborhood')
203
+ # result.to_hash
204
+ def get_region_children(options={})
205
+ url_s=@@zillow_webservice_url+'GetRegionChildren.htm?zws-id='+@zwsid
206
+ if options[:city]!=nil then
207
+ url_s=url_s+'&city='+options[:city].to_s
208
+ end
209
+ if options[:state]!=nil then
210
+ url_s=url_s+'&state='+options[:state].to_s
211
+ end
212
+ if options[:country]!=nil then
213
+ url_s=url_s+'&country='+options[:country].to_s
214
+ end
215
+ if options[:rid]!=nil then
216
+ url_s=url_s+'&rid='+options[:rid].to_s
217
+ end
218
+ if options[:childtype]!=nil then
219
+ url_s=url_s+'&childtype='+options[:childtype].to_s
220
+ end
221
+ fetch_result(url_s)
222
+ end
223
+
224
+ #The get_comps returns a list of comparable recent sales for a specified property.
225
+ #The result set returned contains the address, Zillow property identifier, and Zestimate for the comparable properties and
226
+ #the principal property for which the comparables are being retrieved.
227
+ #see: http://www.zillow.com/howto/api/GetComps.htm
228
+ #parameters:
229
+ #zpid The Zillow Property ID for the property for which to obtain information; the parameter type is an integer
230
+ #count The number of comparable recent sales to obtain
231
+ # Examples:
232
+ # rillow = Rillow.new('your-zillow-service identifier')
233
+ # result = rillow.get_comps('48749425',5)
234
+ # result.to_hash
235
+ def get_comps(zpid,count)
236
+ url_s=@@zillow_webservice_url+'GetComps.htm?zws-id='+@zwsid+'&zpid='+zpid.to_s+'&count='+count.to_s
237
+ fetch_result(url_s)
238
+ end
239
+
240
+ #The get_deep_search_results finds a property for a specified address
241
+ #(or, if no exact match for a property is found, a list of closely matching properties is returned).
242
+ #The result set returned contains the full address(s), zpid and Zestimate data that is provided by the get_search_results API.
243
+ #Moreover, this API call also gives rich property data like lot size, year built, bath/beds, last sale details etc.
244
+ #see: http://www.zillow.com/howto/api/GetDeepSearchResults.htm
245
+ # parameter:
246
+ # address street address
247
+ # citystatezip city&state or zip code
248
+ #Example:
249
+ # rillow = Rillow.new('your-zillow-service identifier')
250
+ # result = rillow.get_deep_search_results('2114 Bigelow Ave','Seattle, WA')
251
+ # result.to_hash
252
+ def get_deep_search_results(address,citystatezip)
253
+ url_s=@@zillow_webservice_url+'GetDeepSearchResults.htm?zws-id='+@zwsid+'&address='+address.to_s+'&citystatezip='+citystatezip.to_s
254
+ fetch_result(url_s)
255
+ end
256
+
257
+ #The get_deep_comps api returns a list of comparable recent sales for a specified property.
258
+ #The result set returned contains the address, Zillow property identifier,
259
+ #and Zestimate for the comparable properties and the principal property for which the comparables are being retrieved.
260
+ #This API call also returns rich property data for the comparables.
261
+ #see: http://www.zillow.com/howto/api/GetDeepComps.htm
262
+
263
+ def get_deep_comps(zpid,count)
264
+ url_s=@@zillow_webservice_url+'GetDeepComps.htm?zws-id='+@zwsid+'&zpid='+zpid.to_s+'&count='+count.to_s
265
+ fetch_result(url_s)
266
+ end
267
+
268
+ #parameters:
269
+ #zpid The Zillow Property ID for the property for which to obtain information; the parameter type is an integer
270
+ #count The number of comparable recent sales to obtain
271
+ # Examples:
272
+ # rillow = Rillow.new('your-zillow-service identifier')
273
+ # result = rillow.get_deep_comps('48749425',5)
274
+ # result.to_hash
275
+ private
276
+ def fetch_result(url_s)
277
+ url = URI.parse(URI.escape(url_s))
278
+ res = Net::HTTP.get_response(url)
279
+ doc = XmlSimple.xml_in res.body
280
+ end
281
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: rillow
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2007-10-30 00:00:00 -04:00
8
+ summary: Ruby wrapper api to the Zillow webservice api
9
+ require_paths:
10
+ - lib
11
+ email: mountainntream@forge.org
12
+ homepage:
13
+ rubyforge_project:
14
+ description: rillow is a ruby wrapper api to the Zillow webservice api.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Leo Chan
31
+ files:
32
+ - lib/rillow.rb
33
+ - README
34
+ test_files: []
35
+
36
+ rdoc_options: []
37
+
38
+ extra_rdoc_files:
39
+ - README
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ requirements: []
45
+
46
+ dependencies:
47
+ - !ruby/object:Gem::Dependency
48
+ name: xml-simple
49
+ version_requirement:
50
+ version_requirements: !ruby/object:Gem::Version::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.11
55
+ version: