Skip to content

How to Automate Google Searches in n8n with the HTTP Request Node

An n8n HTTP Request can time out while we still count the call. Set the 90 second timeout, batching and retries, loop over keywords from a Google Sheet, split results and send a Slack or email digest. Importable workflow included.

How to Automate Google Searches in n8n with the HTTP Request Node

n8n runs an HTTP Request node once for every item it receives, which is exactly what you want until a request outlasts your timeout and the call is counted anyway. A Google search through our API usually comes back in 2 to 4 seconds, but a hard query can take over a minute while we retry behind the scenes. I'll build a keyword-to-Slack workflow with the timeout, batching and retry settings that stop you paying for answers you never receive.

n8n HTTP Request node configured with a JSON body for the JustSERP API

What you need

  • An n8n instance (n8n Cloud or self-hosted) where you can create workflows and credentials.
  • A JustSERP API key. Sign up and copy the key from your dashboard.
  • Optional: a Google Sheet with a keyword column, and a Slack or email account to receive the digest.

How the workflow fits together

The API is a single endpoint: POST https://api.justserp.com/v1/search, with your key in the X-API-Key header and a JSON body such as {"keyword": "best coffee grinder"}. Only keyword is required. The answer is JSON with an organic_results list. In n8n that becomes a short chain of nodes:

n8n workflow diagram: Schedule Trigger, Google Sheets, HTTP Request to JustSERP, Split Out, then Slack or email

A typical request takes 2 to 4 seconds. n8n runs a node once for every incoming item, so a sheet with 30 keywords gives 30 requests with no loop node needed.

Three things about the response will save you debugging time later. We always ask Google for unfiltered, non-personalised results, so the list is the full one without "similar results omitted" and without personal history. The position field restarts at 1 on every page. And country and language take full English names such as "United Kingdom" or "Germany": a code like "UK" or "de" is not an error, the API just falls back to United States and English and still uses a call.

Build the workflow step by step

The pieces below build on each other, so follow them in order.

Step 1: store the API key as a credential

Do not paste the key into the node. Create a credential once and reuse it:

  1. Open Credentials and click Create credential.
  2. Choose Header Auth.
  3. Set Name to X-API-Key and Value to your JustSERP key.
  4. Save it as JustSERP.

The key then lives in n8n's encrypted credential store and never shows up in exported workflow files.

Step 2: get the keywords

Add a Schedule Trigger (for example every day at 07:00), then a Google Sheets node with the operation Get Row(s) in Sheet. Pick your document and sheet and leave the filters empty so it returns every row. Each row becomes one n8n item, with the column headers as field names, so a keyword column is available as {{ $json.keyword }}. No sheet? Use a Code node that returns your own list:

return ['best coffee grinder', 'espresso machine', 'burr grinder']
  .map((keyword) => ({ json: { keyword } }));

Step 3: configure the HTTP Request node

Add an HTTP Request node after the keywords and set these fields:

SettingValue
MethodPOST
URLhttps://api.justserp.com/v1/search
AuthenticationGeneric Credential Type, then Header Auth, then your JustSERP credential
Send BodyOn
Body Content TypeJSON
Specify BodyUsing JSON

For the JSON field, switch it to Expression mode and use JSON.stringify, which escapes quotes in keywords for you:

{{ JSON.stringify({
  keyword: $json.keyword,
  country: "United States",
  language: "English"
}) }}

Add any other parameter the same way, for example device: "mobile", location: "Austin,Texas,United States" or tbs: "qdr:d".

Options and settings that matter

  • Options > Timeout: add the option and set 90000 (milliseconds). Do not go lower, for example 30000. Our side can keep working on a hard query for over a minute, and if n8n hangs up first the call is still counted and you lose the answer.
  • Options > Batching: set Items per Batch to 10 and Batch Interval to 1000. Your plan allows 10 concurrent requests on Free and Personal, 25 on Business and 50 on Enterprise, so keep the batch size at or below that number.
  • Settings tab > Retry On Fail: on, with Max Tries 3 and Wait Between Tries 2000. Status 500 means the page could not be fetched even after our own retries, and no call is used, so retrying it is free. A timeout on your side is different: that request is counted, so keep Max Tries at 3 rather than raising it.
  • Settings tab > On Error: choose Continue (using error output) so one bad keyword does not stop the other 29.

Click Execute step. You should see one item per keyword, each with meta, totalResults and organic_results.

Step 4: split the results into rows

Each response holds about ten organic results in a single list. To work with them one by one, add a Split Out node and set Fields To Split Out to organic_results. Under Include, pick All Other Fields so the original meta object (which contains the query) travels along with every row. After that, each item is one result with position, title, link and description. Because this workflow only reads page 1, position is the absolute rank. If you add page: 2 to the body later, the positions start again at 1, so compute the rank as (page - 1) * 10 + position.

If you only care about where your own domain ranks, a Code node is shorter. This one returns one line per keyword:

const DOMAIN = 'example.com';
const lines = [];

for (const item of $input.all()) {
  const data = item.json;
  const results = data.organic_results ?? [];
  const hit = results.find((r) =>
    new URL(r.link).hostname.replace(/^www\./, '').endsWith(DOMAIN));
  lines.push(data.meta.query + ': ' + (hit ? 'rank ' + hit.position : 'not on page 1'));
}

return [{ json: { text: lines.join('\n') } }];

Blocks like paid_ads and related_questions only exist when Google showed them, so always default with ?? []. Two details about those blocks: paid_ads is a single list in page order with no top or bottom flag, and related_questions holds the question text only, not the answers.

Step 5: send the digest

Slack: add a Slack node, connect your account, set Resource to Message and Operation to Send, choose the channel, and set Message Text to the expression {{ $json.text }}.

Email: add a Send Email node with your SMTP credentials, set the recipient and subject, and use {{ $json.text }} as the text body.

Finally, activate the workflow with the toggle at the top right. The schedule trigger only runs on active workflows.

An importable starter workflow

This minimal workflow has a manual trigger, a keyword list, the configured HTTP Request node and the rank digest from above. Copy it, open a blank workflow in n8n and paste with Ctrl+V (or Cmd+V). Then open the HTTP Request node and select your JustSERP Header Auth credential, which cannot be exported with the file.

{
  "name": "JustSERP keyword check",
  "nodes": [
    {
      "parameters": {},
      "id": "a1b2c3d4-0001-4000-8000-000000000001",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "return ['best coffee grinder', 'espresso machine', 'burr grinder'].map((keyword) => ({ json: { keyword } }));"
      },
      "id": "a1b2c3d4-0002-4000-8000-000000000002",
      "name": "Keywords",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.justserp.com/v1/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ keyword: $json.keyword, country: \"United States\" }) }}",
        "options": {
          "timeout": 90000,
          "batching": {
            "batch": {
              "batchSize": 10,
              "batchInterval": 1000
            }
          }
        }
      },
      "id": "a1b2c3d4-0003-4000-8000-000000000003",
      "name": "JustSERP Search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000
    },
    {
      "parameters": {
        "jsCode": "const DOMAIN = 'example.com';\nconst lines = [];\nfor (const item of $input.all()) {\n  const data = item.json;\n  const results = data.organic_results ?? [];\n  const hit = results.find((r) => new URL(r.link).hostname.replace(/^www\\./, '').endsWith(DOMAIN));\n  lines.push(data.meta.query + ': ' + (hit ? 'rank ' + hit.position : 'not on page 1'));\n}\nreturn [{ json: { text: lines.join('\\n') } }];"
      },
      "id": "a1b2c3d4-0004-4000-8000-000000000004",
      "name": "Build digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        0
      ]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keywords": {
      "main": [
        [
          {
            "node": "JustSERP Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JustSERP Search": {
      "main": [
        [
          {
            "node": "Build digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  }
}

Settings worth double-checking before you activate

  • Use a credential, never a hard-coded key in the node or the keyword list.
  • Mind the call count. Every successful (200) request uses one API call, so 30 keywords every day is 30 calls a day. Errors 400, 500 and other server errors are not charged, and 401 and 429 never count.
  • Test with the manual trigger and three keywords before activating a schedule.
  • Keep batches within your plan's concurrency so requests are never rejected for going over it.
  • Store history. Add a Google Sheets Append Row node at the end to log each day's rank and chart it later.

Next steps

You now have Google results flowing through n8n. Create a free account for 2,000 free requests, no credit card needed, or check the pricing when you are ready to scale. Prefer code? Read the Python guide to the same API.