This endpoint will retrieve listing information from a single 'For Sale' property listing page and transform it into usable JSON.
Single query request:
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://async.scraperapi.com/structured/redfin/forsale')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
apiKey: 'API_KEY',
url: 'URL',
country_code: 'COUNTRY_CODE',
tld: 'TLD',
raw: 'RAW',
callback: {
type: 'webhook',
url: 'YYYYY'
}
}.to_json
begin
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
rescue => e
puts "Error: #{e.message}"
end
Multiple query request:
//require 'net/http'
require 'json'
require 'uri'
uri = URI('https://async.scraperapi.com/structured/redfin/forsale')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
apiKey: 'API_KEY',
urls: ['URL1','URL2'],
country_code: 'COUNTRY_CODE',
tld: 'TLD',
raw: 'RAW',
callback: {
type: 'webhook',
url: 'YYYYY'
}
}.to_json
begin
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
rescue => e
puts "Error: #{e.message}"
end
Parameters
Details
API_KEY (required)
User's API Key.
URL (required)
The URL of the Redfin page. The URL has to be the URL of a property for sale.
country_code
TLD
The top level domain to scrape.
Valid options:
raw
This is a boolean param - true or false
If the raw parameter is set to true, the raw data will be extracted from the page without further parsing.
Important: The structure of the data in raw mode cannot be guaranteed, it’s a tradeoff: You get a lot more information back, but the structure of the response may change if Redfin modifies their page layout.