Redfin 'For Sale' Listings API (Async)

Scrape Redfin For Sale pages in structured JSON/CSV with ScraperAPI async in Java. Supports URL, country code, TLD, and raw data extraction for flexible scraping.

This endpoint will retrieve listing information from a single 'For Sale' property listing page and transform it into usable JSON.

Single query request:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "API_KEY";
            String jsonInputString = "{"
                + "\"apiKey\": \"" + apiKey + "\", "
                + "\"url\": \"URL\", "
                + "\"country_code\": \"COUNTRY_CODE\", "
                + "\"tld\": \"TLD\", "
                + "\raw\": \"RAW\", "
                + "\"callback\": {"
                + "    \"type\": \"webhook\", "
                + "    \"url\": \"YYYYY\""
                + "}}";

            URL url = new URL("https://async.scraperapi.com/structured/redfin/forsale");
            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("Accept", "*/*");
            connection.setDoOutput(true);
            try (OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                os.write(input, 0, input.length);
            }
            int responseCode = connection.getResponseCode();
            StringBuilder response = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String readLine;
            while ((readLine = in.readLine()) != null) {
                response.append(readLine);
            }
            in.close();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                System.out.println("Response: " + response.toString());
            } else {
                throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

Multiple query request:

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

Allows you to geotarget the request. Use this parameter if you want Redfin to be scraped from a specific country.

TLD

The top level domain to scrape.

Valid options:

com’ (for redfin.com)

ca’ (for redfin.ca)

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.

Sample Response

For single query requests:

For multiple query requests:

Last updated

Was this helpful?