# Average Rent and Home Price per Zip Code (`trellis-tech/average-rent-and-home-price-per-zip-code`)

This actor collects and calculates the average rent and home price for each zip code. It extracts data from real estate listings, processes the information, and provides a summary of average values by zip code for easy analysis and comparison.

- **URL**: https://beta-securitybyobscurity.apify.com/trellis-tech/average-rent-and-home-price-per-zip-code.md
- **Developed by:** [Trellis Tech](https://beta-securitybyobscurity.apify.com/trellis-tech) (community)
- **Categories:** Real estate
- **Stats:** 3 total users, 3 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

# README

## Real Estate Average Price Calculator

A powerful [Apify Actor](https://apify.com/actors) that aggregates real estate data by ZIP code and calculates average rent and sale prices organized by property type and bedroom count. This Actor processes data from multiple real estate providers (Realtor.com, Zillow) and provides clean, organized pricing insights for any ZIP code in the United States.

### 🏠 What it does

This Actor takes a ZIP code as input and returns comprehensive real estate pricing analysis including:

- **Average prices** organized by property type (Apartment, House, Condo, etc.) and bedroom count
- **Processing statistics** showing data quality metrics and filtering results
- **Organized listings** with detailed property information
- **Raw property data** for further analysis

The Actor filters out suspicious pricing, handles provider-specific data normalization, and processes bedroom ranges to provide accurate market insights.

### 📊 Output Format

The Actor provides data in multiple views:

#### Price Analysis Overview

- Organized averages by property type and bedroom count
- Processing statistics (total processed, excluded properties, data quality metrics)
- Clean, formatted pricing data ready for analysis

#### Raw Property Listings

- Original unprocessed property data from real estate aggregators
- Full property details including addresses, URLs, and provider information

### 🚀 Key Features

- **Multi-Provider Data**: Aggregates data from Realtor.com and Zillow
- **Smart Filtering**: Removes suspicious pricing and unwanted property types
- **Bedroom Range Processing**: Handles properties with bedroom ranges (e.g., 2-3 bedrooms)
- **Data Quality Metrics**: Provides transparency into data processing and filtering
- **Normalized Property Types**: Standardizes property type names across providers
- **Price Validation**: Filters out unrealistic pricing (too low/high)rape single-page in Python template

A template for [web scraping](https://apify.com/web-scraping) data from a single web page in Python. The URL of the web page is passed in via input, which is defined by the [input schema](https://docs.apify.com/platform/actors/development/input-schema). The template uses the [HTTPX](https://www.python-httpx.org) to get the HTML of the page and the [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/) to parse the data from it. The data are then stored in a [dataset](https://docs.apify.com/sdk/python/docs/concepts/storages#working-with-datasets) where you can easily access them.

The scraped data in this template are page headings but you can easily edit the code to scrape whatever you want from the page.

### 🛠️ Built With

- **Multi-source data aggregation** from major real estate platforms
- **Advanced data validation** and quality control algorithms
- **Smart property categorization** and price normalization
- **Robust error handling** for reliable data processing
- **Scalable architecture** built on the Apify platform

### 💡 How it works

1. **Input Processing**: Accepts ZIP code and configuration parameters
2. **Data Collection**: Automatically calls multiple real estate data sources (Realtor.com, Zillow)
3. **Data Validation**: Filters out unreliable data using advanced algorithms:
   - Removes suspicious pricing (too high/low for the area)
   - Excludes unwanted property types (parking spaces, etc.)
   - Validates data quality from different providers
4. **Smart Processing**: Handles complex scenarios:
   - Properties with bedroom ranges (e.g., "2-3 bedrooms")
   - Different price formats across providers
   - Property type normalization
5. **Analysis & Averaging**: Calculates accurate averages grouped by:
   - Property type (Apartment, House, Condo, etc.)
   - Bedroom count (Studio, 1BR, 2BR, etc.)
   - Offer type (Rent vs. Sale)
6. **Result Delivery**: Provides organized data in user-friendly formats

### 📋 Input Parameters

```json
{
  "zipCode": "19460",
  "maxResultsPerProviderPerZIP": 200
}
```

- **zipCode** (string): The ZIP code to analyze (default: "19460")
- **maxResultsPerProviderPerZIP** (number): Maximum number of results per provider (default: 200)

### 📈 Example Output

```json
{
  "organized_averages": {
    "Apartment": {
      "2 Bedroom": {
        "Rent": {
          "average_price": 2150.50,
          "count": 45,
          "formatted": "$2,150.50 (based on 45 properties)"
        }
      }
    },
    "House": {
      "3 Bedroom": {
        "Sale": {
          "average_price": 485000.00,
          "count": 23,
          "formatted": "$485,000.00 (based on 23 properties)"
        }
      }
    }
  },
  "summary": {
    "total_processed": 150,
    "processed_successfully": 140,
    "excluded_provider": 5,
    "excluded_type": 3,
    "invalid_price": 2
  }
}
```

### 🔧 Use Cases

- **Market Research**: Analyze average rental and sale prices in specific areas
- **Investment Analysis**: Compare property values across different property types
- **Real Estate Reporting**: Generate pricing reports for clients or stakeholders
- **Data Integration**: Feed clean pricing data into larger real estate analysis systems
- **Competitive Analysis**: Understand market positioning and pricing trends

### 🚀 Resources

- **[Apify Platform](https://apify.com)** - Learn more about web scraping and automation
- **[API Documentation](https://docs.apify.com/api/v2)** - Integrate this Actor into your applications
- **[Webhooks](https://docs.apify.com/platform/integrations/webhooks)** - Get notified when runs complete
- **[Integrations](https://apify.com/integrations)** - Connect with 1000+ apps via Zapier, Make, and more
- **[Scheduling](https://docs.apify.com/platform/schedules)** - Run this Actor automatically at set intervals

### 💰 Pricing

**This Actor is completely free to use!** However, it relies on the underlying [Real Estate Aggregator Actor](https://apify.com/tri_angle/real-estate-aggregator) which uses a pay-per-event pricing model.

#### Cost Breakdown

The Real Estate Aggregator charges for:

- **Actor start**: $0.053 per run
- **Extracted listing**: $0.002 per property found

#### Real-World Example

For a typical ZIP code with ~300 property listings, the total cost is approximately **$0.84**:

- Actor start: $0.053
- 300 listings × $0.002 = $0.60
- **Total: ~$0.65-$0.84**

#### Apify Platform Credits

- **Free tier**: $5 worth of platform credits monthly
- This covers analysis for ~6-7 ZIP codes per month at no cost
- **Pay-as-you-go**: Only pay for what you use beyond the free tier

[View current pricing →](https://apify.com/pricing)

### 📧 Support

- **Questions?** Contact support through the Apify platform
- **Feature requests?** Use the feedback option in the Actor console
- **Need custom development?** [Contact Apify](https://apify.com/contact) for custom solutions

### 🚀 Getting Started

#### How to Use This Actor

1. **Click "Try for free"** to start using this Actor
2. **Configure the input** with your desired parameters:
   ```json
   {
     "zipCode": "90210",
     "maxResultsPerProviderPerZIP": 150
   }
   ```
3. **Start the Actor** and wait for it to complete
4. **Download or view your results** in multiple formats:
   - **Price Analysis Overview**: Key metrics and average pricing
   - **Raw Property Listings**: Detailed property information

#### Using the Apify API

You can also run this Actor programmatically using the [Apify API](https://docs.apify.com/api/v2):

```bash
curl "https://api.apify.com/v2/acts/Ce9lJdz4J4HEbr04K/runs" \
  -X POST \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "zipCode": "19460",
    "maxResultsPerProviderPerZIP": 200
  }'
```

#### Integration Options

This Actor integrates seamlessly with:

- **[Zapier](https://apify.com/integrations/zapier)** - Automate workflows
- **[Make (Integromat)](https://apify.com/integrations/make)** - Connect with 1000+ apps
- **[Google Sheets](https://apify.com/integrations/google-sheets)** - Export data directly
- **[Webhooks](https://docs.apify.com/platform/integrations/webhooks)** - Real-time notifications

### 📚 Learn More

- **[What is Web Scraping?](https://blog.apify.com/what-is-web-scraping/)** - Introduction to web scraping
- **[Real Estate Data Guide](https://blog.apify.com/real-estate-data-scraping/)** - Best practices for real estate data
- **[Apify Academy](https://docs.apify.com/academy)** - Free courses on web scraping and automation

# Actor input Schema

## `zipCode` (type: `string`):

The ZIP code to analyze for real estate data.

## `maxResultsPerProviderPerZIP` (type: `integer`):

Maximum number of results to fetch per provider for the specified ZIP code.

## Actor input object example

```json
{
  "zipCode": "19460",
  "maxResultsPerProviderPerZIP": 200
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "zipCode": "19460",
    "maxResultsPerProviderPerZIP": 200
};

// Run the Actor and wait for it to finish
const run = await client.actor("trellis-tech/average-rent-and-home-price-per-zip-code").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "zipCode": "19460",
    "maxResultsPerProviderPerZIP": 200,
}

# Run the Actor and wait for it to finish
run = client.actor("trellis-tech/average-rent-and-home-price-per-zip-code").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "zipCode": "19460",
  "maxResultsPerProviderPerZIP": 200
}' |
apify call trellis-tech/average-rent-and-home-price-per-zip-code --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=trellis-tech/average-rent-and-home-price-per-zip-code",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Average Rent and Home Price per Zip Code",
        "description": "This actor collects and calculates the average rent and home price for each zip code. It extracts data from real estate listings, processes the information, and provides a summary of average values by zip code for easy analysis and comparison.",
        "version": "0.1",
        "x-build-id": "aSzx2nKSXubEDmfAu"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/trellis-tech~average-rent-and-home-price-per-zip-code/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-trellis-tech-average-rent-and-home-price-per-zip-code",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/trellis-tech~average-rent-and-home-price-per-zip-code/runs": {
            "post": {
                "operationId": "runs-sync-trellis-tech-average-rent-and-home-price-per-zip-code",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/trellis-tech~average-rent-and-home-price-per-zip-code/run-sync": {
            "post": {
                "operationId": "run-sync-trellis-tech-average-rent-and-home-price-per-zip-code",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "zipCode"
                ],
                "properties": {
                    "zipCode": {
                        "title": "ZIP Code",
                        "pattern": "^[0-9]{5}$",
                        "type": "string",
                        "description": "The ZIP code to analyze for real estate data."
                    },
                    "maxResultsPerProviderPerZIP": {
                        "title": "Max Results Per Provider Per ZIP",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Maximum number of results to fetch per provider for the specified ZIP code."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
