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 ]
Can someone please help?
(https://beta.pickaxeproject.com/axe?id=Property_Valuation_Estimator_IFOYA)
1 Like
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)}
Let me know if that worked!
2 Likes
The pickaxe is marked as private so we cannot access it.
It looks like none of your values are in the action code.
Thanks Ned_rvth. I got it working after some tweaks: here is the updated code I used:
Construct the URL
url = f"https://api.rentcast.io/v1/avm/value?address={address}&propertyType={propertytype}&bedrooms={bedrooms}&bathrooms={bathrooms}&squareFootage={squarefootage}&compCount={compcount}"
# Define headers
headers = {
"accept": "application/json",
"X-Api-Key": "My API Key"
}
# Send the API request
response = requests.get(url, headers=headers)
# Print the response
print(response.text)
Example usage:
rentcast_property_data_api(“123 Main St”, “SingleFamily”, “3”, “2”, “1500”, “5”)
2 Likes
You can access my studio live here: https://propbot.terbia.net/
2 Likes
Glad it worked out!
The all looks great. Clean and intuitive user journey and you optimized it for mobile too👌🏼