{
  "nodes": [
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 9,
              "minute": 0
            }
          ]
        }
      },
      "name": "Daily Trigger",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1
    },
    {
      "parameters": {
        "values": {
          "boolean": [],
          "string": [
            {
              "name": "cities",
              "value": "[{\"location\":\"Austin, TX\",\"min_price\":200000,\"max_price\":500000},{\"location\":\"Dallas, TX\",\"min_price\":150000,\"max_price\":400000},{\"location\":\"Houston, TX\",\"min_price\":100000,\"max_price\":300000}]"
            }
          ],
          "number": []
        },
        "options": {}
      },
      "name": "Set Search Cities",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1
    },
    {
      "parameters": {
        "batchSize": 1
      },
      "name": "Split Cities",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1
    },
    {
      "parameters": {
        "url": "https://zillowapi.example.com/search",
        "options": {
          "queryParametersJson": "{\"location\": \"={{$json[\"location\"]}}\",\"min_price\": \"={{$json[\"min_price\"]}}\",\"max_price\": \"={{$json[\"max_price\"]}}\"}"
        },
        "responseFormat": "json",
        "headerParametersJson": "{\"X-RapidAPI-Key\":\"YOUR_API_KEY\"}"
      },
      "name": "Zillow API Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1
    },
    {
      "parameters": {
        "value": "={{ $json[\"results\"] }}"
      },
      "name": "Select Listings Array",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1
    },
    {
      "parameters": {
        "batchSize": 1
      },
      "name": "Loop Listings",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1
    },
    {
      "parameters": {
        "functionCode": "const price = Number($json.price);\nconst ARV = price * 0.9;\nconst repair = 20000;\nconst offer = Math.round(ARV * 0.7 - repair);\nreturn [{ json: { city: $json.location, address: $json.address, price, beds: $json.beds, baths: $json.baths, sqft: $json.sqft, listing_url: $json.url, offer } }];"
      },
      "name": "Calculate Offer",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "append",
        "sheetId": "YOUR_SHEET_ID",
        "range": "A1",
        "fieldsToSend": "specific",
        "options": {},
        "fields": [
          {
            "name": "City",
            "value": "={{ $json.city }}"
          },
          {
            "name": "Address",
            "value": "={{ $json.address }}"
          },
          {
            "name": "Price",
            "value": "={{ $json.price }}"
          },
          {
            "name": "Beds",
            "value": "={{ $json.beds }}"
          },
          {
            "name": "Baths",
            "value": "={{ $json.baths }}"
          },
          {
            "name": "Sqft",
            "value": "={{ $json.sqft }}"
          },
          {
            "name": "URL",
            "value": "={{ $json.listing_url }}"
          },
          {
            "name": "Offer",
            "value": "={{ $json.offer }}"
          }
        ]
      },
      "name": "Write to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1
    }
  ],
  "connections": {
    "Daily Trigger": {
      "main": [
        [
          {
            "node": "Set Search Cities",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Search Cities": {
      "main": [
        [
          {
            "node": "Split Cities",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Cities": {
      "main": [
        [
          {
            "node": "Zillow API Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Zillow API Request": {
      "main": [
        [
          {
            "node": "Select Listings Array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Listings Array": {
      "main": [
        [
          {
            "node": "Loop Listings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Listings": {
      "main": [
        [
          {
            "node": "Calculate Offer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Offer": {
      "main": [
        [
          {
            "node": "Write to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}