diff --git a/backend/agent/tools/data_providers/ZillowProvider.py b/backend/agent/tools/data_providers/ZillowProvider.py new file mode 100644 index 00000000..d7ee2ced --- /dev/null +++ b/backend/agent/tools/data_providers/ZillowProvider.py @@ -0,0 +1,184 @@ +from typing import Dict + +from agent.tools.data_providers.RapidDataProviderBase import RapidDataProviderBase, EndpointSchema + + +class ZillowProvider(RapidDataProviderBase): + def __init__(self): + endpoints: Dict[str, EndpointSchema] = { + "search": { + "route": "/search", + "method": "GET", + "name": "Zillow Property Search", + "description": "Search for properties by neighborhood, city, or ZIP code with various filters.", + "payload": { + "location": "Location can be an address, neighborhood, city, or ZIP code (required)", + "page": "Page number for pagination (optional, default: 0)", + "output": "Output format: json, csv, xlsx (optional, default: json)", + "status": "Status of properties: forSale, forRent, recentlySold (optional, default: forSale)", + "sortSelection": "Sorting criteria (optional, default: priorityscore)", + "listing_type": "Listing type: by_agent, by_owner_other (optional, default: by_agent)", + "doz": "Days on Zillow: any, 1, 7, 14, 30, 90, 6m, 12m, 24m, 36m (optional, default: any)", + "price_min": "Minimum price (optional)", + "price_max": "Maximum price (optional)", + "sqft_min": "Minimum square footage (optional)", + "sqft_max": "Maximum square footage (optional)", + "beds_min": "Minimum number of bedrooms (optional)", + "beds_max": "Maximum number of bedrooms (optional)", + "baths_min": "Minimum number of bathrooms (optional)", + "baths_max": "Maximum number of bathrooms (optional)", + "built_min": "Minimum year built (optional)", + "built_max": "Maximum year built (optional)", + "lotSize_min": "Minimum lot size in sqft (optional)", + "lotSize_max": "Maximum lot size in sqft (optional)", + "keywords": "Keywords to search for (optional)" + } + }, + "search_address": { + "route": "/search_address", + "method": "GET", + "name": "Zillow Address Search", + "description": "Search for a specific property by its full address.", + "payload": { + "address": "Full property address (required)" + } + }, + "propertyV2": { + "route": "/propertyV2", + "method": "GET", + "name": "Zillow Property Details", + "description": "Get detailed information about a specific property by zpid or URL.", + "payload": { + "zpid": "Zillow property ID (optional if URL is provided)", + "url": "Property details URL (optional if zpid is provided)" + } + }, + "zestimate_history": { + "route": "/zestimate_history", + "method": "GET", + "name": "Zillow Zestimate History", + "description": "Get historical Zestimate values for a specific property.", + "payload": { + "zpid": "Zillow property ID (optional if URL is provided)", + "url": "Property details URL (optional if zpid is provided)" + } + }, + "similar_properties": { + "route": "/similar_properties", + "method": "GET", + "name": "Zillow Similar Properties", + "description": "Find properties similar to a specific property.", + "payload": { + "zpid": "Zillow property ID (optional if URL or address is provided)", + "url": "Property details URL (optional if zpid or address is provided)", + "address": "Property address (optional if zpid or URL is provided)" + } + }, + "mortgage_rates": { + "route": "/mortgage/rates", + "method": "GET", + "name": "Zillow Mortgage Rates", + "description": "Get current mortgage rates for different loan programs and conditions.", + "payload": { + "program": "Loan program (required): Fixed30Year, Fixed20Year, Fixed15Year, Fixed10Year, ARM3, ARM5, ARM7, etc.", + "state": "State abbreviation (optional, default: US)", + "refinance": "Whether this is for refinancing (optional, default: false)", + "loanType": "Type of loan: Conventional, etc. (optional)", + "loanAmount": "Loan amount category: Micro, SmallConforming, Conforming, SuperConforming, Jumbo (optional)", + "loanToValue": "Loan to value ratio: Normal, High, VeryHigh (optional)", + "creditScore": "Credit score category: Low, High, VeryHigh (optional)", + "duration": "Duration in days (optional, default: 30)" + } + }, + } + base_url = "https://zillow56.p.rapidapi.com" + super().__init__(base_url, endpoints) + + +if __name__ == "__main__": + from dotenv import load_dotenv + from time import sleep + load_dotenv() + tool = ZillowProvider() + + # Example for searching properties in Houston + search_result = tool.call_endpoint( + route="search", + payload={ + "location": "houston, tx", + "status": "forSale", + "sortSelection": "priorityscore", + "listing_type": "by_agent", + "doz": "any" + } + ) + print("Search Result:", search_result) + print("***") + print("***") + print("***") + sleep(1) + # Example for searching by address + address_result = tool.call_endpoint( + route="search_address", + payload={ + "address": "1161 Natchez Dr College Station Texas 77845" + } + ) + print("Address Search Result:", address_result) + print("***") + print("***") + print("***") + sleep(1) + # Example for getting property details + property_result = tool.call_endpoint( + route="propertyV2", + payload={ + "zpid": "7594920" + } + ) + print("Property Details Result:", property_result) + sleep(1) + print("***") + print("***") + print("***") + + # Example for getting zestimate history + zestimate_result = tool.call_endpoint( + route="zestimate_history", + payload={ + "zpid": "20476226" + } + ) + print("Zestimate History Result:", zestimate_result) + sleep(1) + print("***") + print("***") + print("***") + # Example for getting similar properties + similar_result = tool.call_endpoint( + route="similar_properties", + payload={ + "zpid": "28253016" + } + ) + print("Similar Properties Result:", similar_result) + sleep(1) + print("***") + print("***") + print("***") + # Example for getting mortgage rates + mortgage_result = tool.call_endpoint( + route="mortgage_rates", + payload={ + "program": "Fixed30Year", + "state": "US", + "refinance": "false", + "loanType": "Conventional", + "loanAmount": "Conforming", + "loanToValue": "Normal", + "creditScore": "Low", + "duration": "30" + } + ) + print("Mortgage Rates Result:", mortgage_result) + \ No newline at end of file diff --git a/backend/agent/tools/data_providers_tool.py b/backend/agent/tools/data_providers_tool.py index 4ca8d026..b9e4bd8b 100644 --- a/backend/agent/tools/data_providers_tool.py +++ b/backend/agent/tools/data_providers_tool.py @@ -4,6 +4,7 @@ from agentpress.tool import Tool, ToolResult, openapi_schema, xml_schema from agent.tools.data_providers.LinkedinProvider import LinkedinProvider from agent.tools.data_providers.YahooFinanceProvider import YahooFinanceProvider from agent.tools.data_providers.AmazonProvider import AmazonProvider +from agent.tools.data_providers.ZillowProvider import ZillowProvider class DataProvidersTool(Tool): """Tool for making requests to various data providers.""" @@ -14,7 +15,8 @@ class DataProvidersTool(Tool): self.register_data_providers = { "linkedin": LinkedinProvider(), "yahoo_finance": YahooFinanceProvider(), - "amazon": AmazonProvider() + "amazon": AmazonProvider(), + "zillow": ZillowProvider() } @openapi_schema({