alt 0.0.2 → 1.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +30 -8
- data/lib/alt/error.rb +1 -1
- data/lib/alt/property.rb +36 -8
- data/lib/alt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 563d2fc47056480cff9fa2d26ea4b281d217ac8d267815c82b70097d50b600b1
|
|
4
|
+
data.tar.gz: e329a3b293b1a192b127e4451f53b65b741917b1d421ab45813a268d81db68bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8611ddf2d4bdf9f70888aebf8279d82ebeb10ed254676aa63735968340230ce0f7b1387344233badf57f6c9bf256628558cc9a053ddd9063104c761ca6600f01
|
|
7
|
+
data.tar.gz: f801ba6e3f41630923742bb836822c327a24e2ddd7c2af39cec0c5b2bcd555ad71e4bec77edbcec50bca1c579819edb96214156d85b3f0782d58ded3cd7ee862
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.0.0] - 2026-08-05
|
|
2
|
+
|
|
3
|
+
- Implement `Alt::Property#property_details`, which was previously a `# TODO` returning `nil`.
|
|
4
|
+
A lookup now issues two requests against RapidAPI's `realty-in-us` host: an
|
|
5
|
+
`/locations/v2/auto-complete` call to resolve the address to a property id, then a
|
|
6
|
+
`/properties/v3/detail` call for the details.
|
|
7
|
+
|
|
1
8
|
## [0.0.2] - 2026-07-28
|
|
2
9
|
|
|
3
10
|
- Initial release
|
data/README.md
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Realtor API Ruby client
|
|
2
|
+
|
|
3
|
+
Fetches property details from Realtor, reached through
|
|
4
|
+
[RapidAPI](https://rapidapi.com/apidojo/api/realty-in-us).
|
|
2
5
|
|
|
3
6
|
## Authentication
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
Subscribe to the Realtor API on RapidAPI and set your key as an environment variable:
|
|
9
|
+
|
|
10
|
+
- `ENV['RAPIDAPI_KEY']`
|
|
6
11
|
|
|
7
|
-
- `
|
|
8
|
-
- `ENV['HOUSECANARY_API_SECRET']`
|
|
12
|
+
The host (`realty-in-us.p.rapidapi.com`) is sent automatically as `X-RapidAPI-Host`.
|
|
9
13
|
|
|
10
14
|
## Available methods
|
|
11
15
|
|
|
12
16
|
```ruby
|
|
13
17
|
property = Alt::Property.new address: "4352 Desert Park Ave", unit: nil, city: "North Las Vegas", zipcode: "89085"
|
|
14
18
|
|
|
15
|
-
property.
|
|
19
|
+
property.property_details # => the parsed `/properties/v3/detail` response body
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Unlike HouseCanary, which returns separate `subject_address`, `public_records` and
|
|
23
|
+
`assessment` objects, Realtor returns a single object, exposed here as `property_details`.
|
|
24
|
+
|
|
25
|
+
## How a lookup works
|
|
26
|
+
|
|
27
|
+
Realtor has no address-to-detail endpoint, so a lookup takes two requests:
|
|
28
|
+
|
|
29
|
+
1. `GET /locations/v2/auto-complete?input=<address>` — resolves the address to a property id
|
|
30
|
+
2. `GET /properties/v3/detail?property_id=<id>` — returns the details
|
|
31
|
+
|
|
32
|
+
`Alt::Error` is raised when either request fails, or when the address matches no property.
|
|
33
|
+
|
|
34
|
+
## Status
|
|
16
35
|
|
|
17
|
-
|
|
36
|
+
The two endpoint paths above are confirmed to exist. The following identifiers are **not yet
|
|
37
|
+
verified against a live response** (the account's RapidAPI quota was exhausted at the time of
|
|
38
|
+
writing) and should be checked against the RapidAPI playground before relying on this client:
|
|
18
39
|
|
|
19
|
-
|
|
20
|
-
|
|
40
|
+
- the `input` query parameter name for `/locations/v2/auto-complete`
|
|
41
|
+
- the `autocomplete` array and its `mpr_id` field in that response
|
|
42
|
+
- the `property_id` query parameter name for `/properties/v3/detail`
|
data/lib/alt/error.rb
CHANGED
data/lib/alt/property.rb
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
# A wrapper for the
|
|
2
|
-
# @see https://
|
|
1
|
+
# A wrapper for the Realtor API, reached through RapidAPI, to fetch property details.
|
|
2
|
+
# @see https://rapidapi.com/apidojo/api/realty-in-us
|
|
3
3
|
module Alt
|
|
4
|
-
# Embeds the logic of a
|
|
4
|
+
# Embeds the logic of a Realtor property.
|
|
5
5
|
class Property
|
|
6
|
-
#
|
|
6
|
+
# The RapidAPI host serving the Realtor data.
|
|
7
|
+
HOST = 'realty-in-us.p.rapidapi.com'
|
|
8
|
+
|
|
9
|
+
# @data [Hash] data the attributes of each property
|
|
7
10
|
# @option data [String] address Building number, street name, and optionally unit number
|
|
8
11
|
# @option data [String] unit Unit number for the property
|
|
9
12
|
# @option data [String] city City in which the property is located
|
|
@@ -12,8 +15,8 @@ module Alt
|
|
|
12
15
|
@data = data
|
|
13
16
|
end
|
|
14
17
|
|
|
15
|
-
# @return [Hash]
|
|
16
|
-
def property_details = details
|
|
18
|
+
# @return [Hash] Details about the property
|
|
19
|
+
def property_details = details
|
|
17
20
|
|
|
18
21
|
private
|
|
19
22
|
|
|
@@ -21,8 +24,33 @@ module Alt
|
|
|
21
24
|
@details ||= fetch
|
|
22
25
|
end
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
# Realtor exposes no address-to-detail endpoint, so the address is resolved to an id first.
|
|
28
|
+
def fetch = get '/properties/v3/detail', property_id: property_id
|
|
29
|
+
|
|
30
|
+
def property_id
|
|
31
|
+
suggestions = get('/locations/v2/auto-complete', input: input)[:autocomplete]
|
|
32
|
+
raise Error if suggestions.nil? || suggestions.empty?
|
|
33
|
+
|
|
34
|
+
suggestions.first[:mpr_id]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def input
|
|
38
|
+
[@data[:address], @data[:unit], @data[:city], @data[:zipcode]]
|
|
39
|
+
.reject { |part| part.to_s.empty? }.join ' '
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def get(path, params)
|
|
43
|
+
uri = URI "https://#{HOST}#{path}"
|
|
44
|
+
uri.query = URI.encode_www_form params
|
|
45
|
+
|
|
46
|
+
request = Net::HTTP::Get.new uri
|
|
47
|
+
request['X-RapidAPI-Key'] = ENV['RAPIDAPI_KEY']
|
|
48
|
+
request['X-RapidAPI-Host'] = HOST
|
|
49
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
|
50
|
+
http.request(request)
|
|
51
|
+
end
|
|
52
|
+
raise Error unless response.is_a?(Net::HTTPSuccess)
|
|
53
|
+
JSON(response.body).with_indifferent_access
|
|
26
54
|
end
|
|
27
55
|
end
|
|
28
56
|
end
|
data/lib/alt/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: alt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Claudio Baccigalupo
|
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
59
|
version: '0'
|
|
60
60
|
requirements: []
|
|
61
|
-
rubygems_version: 4.0.
|
|
61
|
+
rubygems_version: 4.0.10
|
|
62
62
|
specification_version: 4
|
|
63
63
|
summary: A Ruby client for the Realtor API.
|
|
64
64
|
test_files: []
|