{
  "name": "Pull Google Maps leads into Google Sheets with Maps Harvest",
  "nodes": [
    {
      "parameters": {},
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a01",
      "name": "Run it",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "query",
              "value": "Dentist",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "country",
              "value": "us",
              "type": "string"
            },
            {
              "id": "a3",
              "name": "states",
              "value": "Texas",
              "type": "string"
            },
            {
              "id": "a4",
              "name": "cities",
              "value": "Austin",
              "type": "string"
            },
            {
              "id": "a5",
              "name": "max_total_results",
              "value": 50,
              "type": "number"
            },
            {
              "id": "a6",
              "name": "require_phone",
              "value": true,
              "type": "boolean"
            },
            {
              "id": "a7",
              "name": "min_rating",
              "value": 0,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a02",
      "name": "Your search",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.mapsharvest.com/scrape",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ query: $json.query, country: $json.country, states: $json.states, cities: $json.cities || undefined, max_total_results: $json.max_total_results, require_phone: $json.require_phone, min_rating: $json.min_rating || undefined, name: 'n8n: ' + $json.query + ' in ' + ($json.cities || $json.states) }) }}",
        "options": {}
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a03",
      "name": "Start the search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        300
      ]
    },
    {
      "parameters": {
        "amount": 30
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a04",
      "name": "Wait 30 seconds",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        660,
        300
      ],
      "webhookId": "0d7c5f4e-3a1b-4c2d-9e8f-7a6b5c4d3e21"
    },
    {
      "parameters": {
        "url": "=https://api.mapsharvest.com/jobs/{{ $('Start the search').first().json.job_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a05",
      "name": "Check progress",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        300
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "c1",
                    "leftValue": "={{ ['completed', 'stopped'].includes($json.status) }}",
                    "rightValue": true,
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Finished"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "c2",
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "failed",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Failed"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Still running"
        }
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a06",
      "name": "Finished?",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        1100,
        300
      ]
    },
    {
      "parameters": {
        "url": "=https://api.mapsharvest.com/jobs/{{ $('Start the search').first().json.job_id }}/download?fmt=csv",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a07",
      "name": "Download the leads",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1340,
        160
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a08",
      "name": "Read the CSV",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        1560,
        160
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": ""
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a09",
      "name": "Add to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1780,
        160
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'The Maps Harvest search failed: ' + ($json.error || 'no reason given') }}"
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a10",
      "name": "Stop: search failed",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1340,
        320
      ]
    },
    {
      "parameters": {
        "content": "## Google Maps leads to Google Sheets\n\nSearches Google Maps for one kind of business in one place with **Maps Harvest**, waits for the list, and adds every lead (name, phone, address, rating, reviews and more) as a row in your Google Sheet.\n\n### Set up (5 minutes)\n1. Get a free API key: sign up at [mapsharvest.com](https://www.mapsharvest.com/signup?utm_source=n8n&utm_medium=template&utm_campaign=sheets), then **Dashboard → Integrations → API access**. The free plan includes 50 leads.\n2. Create a **Header Auth** credential: Name `Authorization`, Value `Bearer mh_live_...` (your key). Pick it in the three Maps Harvest HTTP nodes.\n3. Edit **Your search**: business type, country (`us`, `uk`, `canada`, `australia`, `germany`, `india`), state or region (for example `Texas`, `Greater London`, `Ontario`), an optional city, and how many leads.\n4. Connect Google Sheets and pick your spreadsheet in **Add to Google Sheets**. Use an empty sheet: the first row becomes the column names.\n\nEach lead uses one credit. API docs: [mapsharvest.com/docs](https://www.mapsharvest.com/docs)",
        "height": 520,
        "width": 420
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a11",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -480,
        100
      ]
    },
    {
      "parameters": {
        "content": "Checks every 30 seconds until the search is done, however long it takes.",
        "height": 120,
        "width": 440,
        "color": 7
      },
      "id": "6f0b1a52-2f5e-4a8e-9a43-0c1f1d2b7a12",
      "name": "Note: waiting",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        640,
        460
      ]
    }
  ],
  "connections": {
    "Run it": {
      "main": [
        [
          {
            "node": "Your search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Your search": {
      "main": [
        [
          {
            "node": "Start the search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start the search": {
      "main": [
        [
          {
            "node": "Wait 30 seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 30 seconds": {
      "main": [
        [
          {
            "node": "Check progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check progress": {
      "main": [
        [
          {
            "node": "Finished?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Finished?": {
      "main": [
        [
          {
            "node": "Download the leads",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: search failed",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 30 seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download the leads": {
      "main": [
        [
          {
            "node": "Read the CSV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read the CSV": {
      "main": [
        [
          {
            "node": "Add to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "pinData": {}
}