Before you begin#
- A LookupNest account with a verified email and the access your plan requires.
- An active API key created in the customer portal.
- Available lookup credits and an environment allowed by the key restrictions.
- A server-side environment that can make HTTPS requests.
Create and configure your key#
- Open the customer portal and go to API configuration.
- Create a clearly named key. Save the full secret when it is created; listing keys does not return it.
- Set the allowed domains/origins and caller IPs that your integration needs.
- Place the key in a server-side environment variable or secret store.
export LOOKUPNEST_API_KEY="replace_with_your_key"Send an IP lookup#
curl --request POST 'https://api.lookupnest.com/api/v1/lookup/ip' \
--header "x-api-key: $LOOKUPNEST_API_KEY" \
--header 'Content-Type: application/json' \
--header 'Origin: https://app.example.com' \
--data '{"ip":"203.0.113.42"}'// Run on your server. Node.js with built-in fetch.
const key = process.env.LOOKUPNEST_API_KEY;
if (!key) throw new Error('Set LOOKUPNEST_API_KEY');
const response = await fetch('https://api.lookupnest.com/api/v1/lookup/ip', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': key,
Origin: 'https://app.example.com'
},
body: JSON.stringify({"ip":"203.0.113.42"}),
signal: AbortSignal.timeout(15000) // Your client timeout, not a service SLA.
});
const payload = await response.json();
if (!response.ok || payload.success === false) {
throw new Error(payload.message || ('HTTP ' + response.status));
}
// Use payload in your application; do not log credentials or full customer data.
console.log({ status: response.status, creditsCharged: payload.credits_charged });# Python 3 standard library. Run on your server.
import json, os, urllib.request, urllib.error
key = os.environ['LOOKUPNEST_API_KEY']
request = urllib.request.Request(
'https://api.lookupnest.com/api/v1/lookup/ip',
data=json.dumps({"ip":"203.0.113.42"}).encode('utf-8'),
headers={
'Content-Type': 'application/json',
'x-api-key': key,
'Origin': 'https://app.example.com'
},
method='POST'
)
try:
with urllib.request.urlopen(request, timeout=15) as response:
payload = json.load(response)
if payload.get('success') is False:
raise RuntimeError(payload.get('message', 'Lookup failed'))
print({'status': response.status})
except urllib.error.HTTPError as error:
# Handle the documented HTTP status; do not blindly retry charged lookups.
raise RuntimeError(f'LookupNest returned HTTP {error.code}') from error<?php
// Server-side PHP with the cURL extension.
$key = getenv('LOOKUPNEST_API_KEY');
if (!$key) { throw new RuntimeException('Set LOOKUPNEST_API_KEY'); }
$handle = curl_init('https://api.lookupnest.com/api/v1/lookup/ip');
curl_setopt_array($handle, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'x-api-key: ' . $key,
'Origin: https://app.example.com'
],
CURLOPT_POSTFIELDS => json_encode(['ip' => '203.0.113.42'], JSON_THROW_ON_ERROR)
]);
$body = curl_exec($handle);
if ($body === false) { throw new RuntimeException(curl_error($handle)); }
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
$payload = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400 || ($payload['success'] ?? true) === false) {
throw new RuntimeException('LookupNest request failed: HTTP ' . $status);
}
// Use $payload without logging API keys or full submitted customer records.Replace 203.0.113.42 with the IP address you want to query. This documentation address illustrates input formatting. The 15-second timeouts in language examples are client choices, not a service latency promise.
Read the response deliberately#
The typed IP response places the lookup record at payload.data.data. Top-level usage fields describe the recorded charge and remaining balance. Check HTTP status and success before reading the record.
const record = payload.data?.data;
const risk = record?.detections?.risk;
if (typeof risk === "number") {
// Combine risk with the individual flags and your application context.
}A missing value should stay missing. Do not convert an unavailable score into zero or an absent detection into a completed negative check.
Continue building#
- Verify an email with the same supported credential modes.
- Manage the key lifecycle before deployment.
- Handle errors without blindly repeating potentially charged requests.