Hi I am buiilding a pickaxe that collects Realestate property details to provide a Value Estimate and comparable properties report for users. I am trying to use rentcast.io API to request property data for my pickaxe through a custom Action.
Here is the error description: Error Analysis: The system is returning a NameError indicating that the ‘address’ variable is not defined. This appears to be a technical issue with the API implementation, as we’ve tried multiple address format variations.
I have varified the parameters are correct and the code runs perfectly when run separtely (through Google’s OpenColab for example)
Here is the link to my Pickaxe: [Property Value estimator ]
hi @nomadsofchaos from the surface, it looks like your action code needs tweaking. There might be an issue with how the code is comprehending and passing through the ‘address’ action input.
Try this action code, test, and tweak:
import requests
def rentcast_property_data_api(address: str, propertytype: str, bedrooms: str, bathrooms: str, squarefootage: str, compcount: str):
"""
Retrieve data using the user-provided input.
Args:
address (string): Property Address
propertytype (string): Property Type
bedrooms (string): Number of bedrooms
bathrooms (string): Number of bathrooms
squarefootage (string): Square footage
compcount (string): Number of comparable properties
"""
# Debugging: Print inputs to verify they're being passed correctly
print(f"Inputs: Address={address}, PropertyType={propertytype}, Bedrooms={bedrooms}, Bathrooms={bathrooms}, SquareFootage={squarefootage}, CompCount={compcount}")
# Check if address is not empty
if not address:
return {"error": "Address is required"}
# Construct the API URL
url = f"https://api.rentcast.io/v1/avm/value?address={address}&propertyType={propertytype}&bedrooms={bedrooms}&bathrooms={bathrooms}&squareFootage={squarefootage}&compCount={compcount}"
headers = {
"accept": "application/json",
"X-Api-Key": "YOUR_API_KEY" # Replace with your actual API key
}
try:
# Make the request
response = requests.get(url, headers=headers)
response.raise_for_status()
return response.json() # Return the parsed JSON response
except requests.exceptions.RequestException as e:
return {"error": str(e)}