Code examples

Copy an own-IP request or import a single-IP n8n workflow.

Own-IP request examples

Each example calls the same endpoint. The connecting process determines whose IP address is returned.

Use a JavaScript module or browser console with native fetch and AbortSignal.timeout.

Own-IP request
const response = await fetch(
  "https://api.ipquery.io/?format=json",
  { signal: AbortSignal.timeout(5000) }
);
if (!response.ok) {
  const message = await response.text();
  throw new Error("IPQuery " + response.status + ": " + message);
}
const data = await response.json();
console.log(JSON.stringify(data, null, 2));

The examples use five-second timeouts and the language’s standard HTTP tools. Handle failures in your application; do not substitute an empty IP record.

Look up one supplied IP in n8n

Paste this JSON into the n8n Editor. In Set IP, replace 8.8.8.8 with one IPv4 or IPv6 address, then execute the workflow manually.

Single-IP n8n workflow · n8n 2.46.6
{
  "name": "IPQuery single IP lookup",
  "nodes": [
    {
      "parameters": {},
      "id": "manual-trigger",
      "name": "Run manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ip-address",
              "name": "ip",
              "value": "8.8.8.8",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "set-ip",
      "name": "Set IP",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        240,
        0
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ typeof $json.ip === 'string' && /^(?:\\d{1,3}(?:\\.\\d{1,3}){3}|[0-9a-f:.]*:[0-9a-f:.]+)$/i.test($json.ip.trim()) ? 'https://api.ipquery.io/' + encodeURIComponent($json.ip.trim()) + '?format=json' : '' }}",
        "options": {
          "timeout": 8000,
          "response": {
            "response": {
              "responseFormat": "json"
            }
          },
          "redirect": {
            "redirect": {
              "followRedirects": false
            }
          }
        }
      },
      "id": "lookup-ip",
      "name": "Lookup IP",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        480,
        0
      ]
    }
  ],
  "connections": {
    "Run manually": {
      "main": [
        [
          {
            "node": "Set IP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set IP": {
      "main": [
        [
          {
            "node": "Lookup IP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}

The workflow uses n8n’s built-in HTTP Request node without credentials or a community node. Lookup IP requests JSON for the supplied address; bulk lookups are disabled. Calling the own-IP endpoint from n8n would return the n8n server’s connecting address.

Lookup IP stops the workflow on a non-2xx response. Its 8000 ms timeout limits the wait for the response to start, not the total execution time.

Full-list access.

For pricing or full-list access, email contact@ipquery.io.

Selected list
Selected records
Records in this list