### JavaScript Integration Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Provides a JavaScript function `lookupIP` for integrating IP intelligence lookups into Node.js or browser applications using the Fetch API. ```APIDOC ## JavaScript Integration ### `lookupIP` Function An asynchronous function that utilizes the Fetch API to perform IP lookups. It returns a promise that resolves with the complete IP intelligence object. ### Method Signature `async function lookupIP(ip?: string): Promise` ### Parameters - **ip** (string) - Optional. The IP address to look up. If omitted, the API will auto-detect the caller's IP. ### Returns A `Promise` that resolves to an object containing IP intelligence data. ### Usage Example (JavaScript) ```javascript // Auto-detect caller IP and log details const myIP = await lookupIP(); console.log(`IP: ${myIP.ip}`); console.log(`Location: ${formatLocation(myIP)}`); // Lookup a specific IP const googleDNS = await lookupIP('8.8.8.8'); console.log(`ASN: ${googleDNS.network.asn} (${googleDNS.network.org})`); // Check if the IP is from a datacenter if (isDatacenterOrProxy(googleDNS)) { console.log('Datacenter or proxy detected.'); } ``` ``` -------------------------------- ### IP Geolocation Lookup with Go Source: https://github.com/webunblocker/ipbot-examples/blob/main/README.md An example demonstrating IP lookups with the IPBot API in Go, utilizing typed response structs for structured data handling and improved code readability. ```go package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" ) type Location struct { Country string `json:"country"` CountryCode string `json:"country_code"` Region string `json:"region"` City string `json:"city"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` } type Network struct { ASN string `json:"asn"` Org string `json:"org"` Radar string `json:"radar"` } type Security struct { RiskScore int `json:"risk_score"` RiskReasons []string `json:"risk_reasons"` IsDatacenter bool `json:"is_datacenter"` IsProxy bool `json:"is_proxy"` ThreatLevel string `json:"threat_level"` } type IpInfoResponse struct { IP string `json:"ip"` Location Location `json:"location"` Network Network `json:"network"` Security Security `json:"security"` } func getIpInfo(ipAddress string) (*IpInfoResponse, error) { url := fmt.Sprintf("https://api.ipbot.com/%s", ipAddress) resp, err := http.Get(url) if err != nil { return nil, fmt.Errorf("failed to make request: %w", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode) } body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } var ipInfo IpInfoResponse if err := json.Unmarshal(body, &ipInfo); err != nil { return nil, fmt.Errorf("failed to unmarshal JSON: %w", err) } return &ipInfo, nil } func main() { ipToLookup := "8.8.8.8" ipInfo, err := getIpInfo(ipToLookup) if err != nil { log.Fatalf("Error getting IP info: %v", err) } prettyJSON, err := json.MarshalIndent(ipInfo, "", " ") if err != nil { log.Fatalf("Error marshalling JSON: %v", err) } fmt.Println(string(prettyJSON)) } ``` -------------------------------- ### IP Geolocation Lookup with JavaScript (Node.js & Browser) Source: https://github.com/webunblocker/ipbot-examples/blob/main/README.md Provides an example of how to perform an IP lookup using the IPBot API in JavaScript, compatible with both Node.js environments and browser-based fetch API. ```javascript async function getIpInfo(ipAddress) { const apiUrl = `https://api.ipbot.com/${ipAddress}`; try { const response = await fetch(apiUrl); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data; } catch (error) { console.error('Error fetching IP info:', error); return null; } } // Example usage (Node.js or browser console) const ipToLookup = '8.8.8.8'; getIpInfo(ipToLookup).then(data => { if (data) { console.log(JSON.stringify(data, null, 2)); } }); ``` -------------------------------- ### Quick Start: IP Geolocation with cURL Source: https://github.com/webunblocker/ipbot-examples/blob/main/README.md A basic cURL command to quickly retrieve IP geolocation data from the IPBot API. It pipes the output to `jq` for pretty-printing JSON. ```bash curl -s https://api.ipbot.com/8.8.8.8 | jq ``` -------------------------------- ### GET / Source: https://github.com/webunblocker/ipbot-examples/blob/main/README.md Automatically detects the caller's IP address and provides intelligence information. ```APIDOC ## GET / ### Description Automatically detects the caller's IP address and provides intelligence information. ### Method GET ### Endpoint / ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **ip** (string) - The detected IP address. - **location** (object) - Geolocation details. - **network** (object) - Network and ASN information. - **security** (object) - Security-related information including risk score and proxy detection. #### Response Example ```json { "ip": "8.8.8.8", "location": { "country": "United States", "country_code": "US", "region": "California", "city": "Mountain View", "latitude": 37.4056, "longitude": -122.0775 }, "network": { "asn": "AS15169", "org": "Google LLC", "radar": "isp" }, "security": { "risk_score": 15, "risk_reasons": ["public_dns"], "is_datacenter": true, "is_proxy": false, "threat_level": "Low" } } ``` ``` -------------------------------- ### Bash Script for Parallel IP Lookups Source: https://context7.com/webunblocker/ipbot-examples/llms.txt A shell script that performs concurrent IP lookups using `curl` and `jq` for efficient batch processing of multiple IP addresses. It outputs the IP, organization, and risk score for each IP. Requires `curl` and `jq` to be installed. ```bash #!/bin/bash BASE_URL="https://api.ipbot.com" # Batch lookup (parallel) IPS="8.8.8.8 1.1.1.1 208.67.222.222" for ip in $IPS; do curl -s "$BASE_URL/$ip" | jq -c '{ip: .ip, org: .network.org, risk: .security.risk_score}' & done wait # Expected output (order may vary): # {"ip":"8.8.8.8","org":"Google LLC","risk":15} # {"ip":"1.1.1.1","org":"Cloudflare, Inc.","risk":10} # {"ip":"208.67.222.222","org":"Cisco OpenDNS, LLC","risk":12} ``` -------------------------------- ### GET /health Source: https://github.com/webunblocker/ipbot-examples/blob/main/README.md Checks the health status of the IPBot service. ```APIDOC ## GET /health ### Description Checks the health status of the IPBot service. ### Method GET ### Endpoint `/health` ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **status** (string) - The health status of the service (e.g., "OK"). #### Response Example ```json { "status": "OK" } ``` ``` -------------------------------- ### GET /api?ip={ip} Source: https://github.com/webunblocker/ipbot-examples/blob/main/README.md Retrieves intelligence information for a specific IP address using a query parameter. ```APIDOC ## GET /api?ip={ip} ### Description Retrieves intelligence information for a specific IP address using a query parameter. ### Method GET ### Endpoint `/api` ### Parameters #### Path Parameters None #### Query Parameters - **ip** (string) - Required - The IP address to look up. ### Request Example None ### Response #### Success Response (200) - **ip** (string) - The requested IP address. - **location** (object) - Geolocation details. - **network** (object) - Network and ASN information. - **security** (object) - Security-related information including risk score and proxy detection. #### Response Example ```json { "ip": "8.8.8.8", "location": { "country": "United States", "country_code": "US", "region": "California", "city": "Mountain View", "latitude": 37.4056, "longitude": -122.0775 }, "network": { "asn": "AS15169", "org": "Google LLC", "radar": "isp" }, "security": { "risk_score": 15, "risk_reasons": ["public_dns"], "is_datacenter": true, "is_proxy": false, "threat_level": "Low" } } ``` ``` -------------------------------- ### Python Error Handling for IP Lookup Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Demonstrates how to handle potential `ValueError` exceptions when performing an IP lookup with an invalid IP address. This ensures graceful failure and provides informative error messages to the user. ```python try: lookup_ip("invalid-ip") except ValueError as e: print(f"Error: {e}") ``` -------------------------------- ### Go IP Lookup Client Source: https://context7.com/webunblocker/ipbot-examples/llms.txt A typed Go client for IP lookup and risk assessment. It handles HTTP requests, JSON parsing, and provides methods for checking risk scores and identifying datacenters or proxies. Requires no external dependencies beyond standard Go libraries. ```go package main import ( "encoding/json" "fmt" "net/http" "time" ) const BaseURL = "https://api.ipbot.com" type IPInfo struct { IP string `json:"ip"` Location Location `json:"location"` Network Network `json:"network"` Security Security `json:"security"` } type Location struct { Country string `json:"country"` CountryCode string `json:"country_code"` Region string `json:"region"` City string `json:"city"` Postal string `json:"postal"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` Timezone string `json:"timezone"` } type Network struct { ASN string `json:"asn"` Org string `json:"org"` Radar string `json:"radar"` } type Security struct { RiskScore int `json:"risk_score"` RiskReasons []string `json:"risk_reasons"` UsageType string `json:"usage_type"` IsDatacenter bool `json:"is_datacenter"` IsProxy bool `json:"is_proxy"` ThreatLevel string `json:"threat_level"` ThreatLists []string `json:"threat_lists"` } type Client struct { httpClient *http.Client } func NewClient() *Client { return &Client{ httpClient: &http.Client{Timeout: 10 * time.Second}, } } func (c *Client) Lookup(ip string) (*IPInfo, error) { url := BaseURL if ip != "" { url = fmt.Sprintf("%s/%s", BaseURL, ip) } resp, err := c.httpClient.Get(url) if err != nil { return nil, fmt.Errorf("request failed: %w", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return nil, fmt.Errorf("HTTP %d", resp.StatusCode) } var info IPInfo if err := json.NewDecoder(resp.Body).Decode(&info); err != nil { return nil, fmt.Errorf("decode error: %w", err) } return &info, nil } func (info *IPInfo) IsHighRisk(threshold int) bool { return info.Security.RiskScore >= threshold } func (info *IPInfo) IsDatacenterOrProxy() bool { return info.Security.IsDatacenter || info.Security.IsProxy } func main() { client := NewClient() // Auto-detect caller IP myIP, err := client.Lookup("") if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("IP: %s, Location: %s, %s\n", myIP.IP, myIP.Location.City, myIP.Location.Country) // Lookup specific IP googleDNS, _ := client.Lookup("8.8.8.8") fmt.Printf("ASN: %s (%s), Datacenter: %v\n", googleDNS.Network.ASN, googleDNS.Network.Org, googleDNS.Security.IsDatacenter) // Risk check if googleDNS.IsHighRisk(50) { fmt.Printf("High risk! Reasons: %v\n", googleDNS.Security.RiskReasons) } } ``` -------------------------------- ### GET /{ip} Source: https://github.com/webunblocker/ipbot-examples/blob/main/README.md Retrieves intelligence information for a specific IP address provided in the path. ```APIDOC ## GET /{ip} ### Description Retrieves intelligence information for a specific IP address provided in the path. ### Method GET ### Endpoint `/{ip}` ### Parameters #### Path Parameters - **ip** (string) - Required - The IP address to look up. #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **ip** (string) - The requested IP address. - **location** (object) - Geolocation details. - **network** (object) - Network and ASN information. - **security** (object) - Security-related information including risk score and proxy detection. #### Response Example ```json { "ip": "8.8.8.8", "location": { "country": "United States", "country_code": "US", "region": "California", "city": "Mountain View", "latitude": 37.4056, "longitude": -122.0775 }, "network": { "asn": "AS15169", "org": "Google LLC", "radar": "isp" }, "security": { "risk_score": 15, "risk_reasons": ["public_dns"], "is_datacenter": true, "is_proxy": false, "threat_level": "Low" } } ``` ``` -------------------------------- ### Query Parameter Style Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Alternative endpoint that accepts the IP address as a query parameter. Useful when building URLs dynamically or when path-based parameters are inconvenient. ```APIDOC ## GET /api ### Description Retrieves detailed intelligence for a specified IP address using a query parameter. ### Method GET ### Endpoint `/api` ### Parameters #### Path Parameters None #### Query Parameters - **ip** (string) - Required - The IPv4 or IPv6 address to look up. #### Request Body None ### Request Example ```bash curl -s "https://api.ipbot.com/api?ip=1.1.1.1" ``` ### Response #### Success Response (200) - **ip** (string) - The IP address. - **location** (object) - Geolocation details. - **country** (string) - Country name. - **country_code** (string) - Two-letter country code. - **region** (string) - State or region name. - **city** (string) - City name. - **postal** (string) - Postal code. - **latitude** (float) - Latitude coordinate. - **longitude** (float) - Longitude coordinate. - **timezone** (string) - Timezone name. - **network** (object) - Network information. - **asn** (string) - Autonomous System Number. - **org** (string) - Organization name. - **radar** (string) - Network radar type (e.g., 'isp'). - **security** (object) - Security intelligence. - **risk_score** (integer) - Risk score (0-100). - **risk_reasons** (array) - Reasons for the risk score. - **usage_type** (string) - Type of IP usage (e.g., 'residential', 'business'). - **is_datacenter** (boolean) - True if the IP belongs to a datacenter. - **is_proxy** (boolean) - True if the IP is a proxy. - **threat_level** (string) - Threat level (e.g., 'Low', 'Medium', 'High'). - **threat_lists** (array) - Lists the IP is associated with. #### Response Example ```json { "ip": "1.1.1.1", "location": { "country": "Australia", "country_code": "AU", "region": "New South Wales", "city": "Sydney", "postal": "2000", "latitude": -33.8688, "longitude": 151.2093, "timezone": "Australia/Sydney" }, "network": { "asn": "AS13335", "org": "Cloudflare, Inc.", "radar": "cdn" }, "security": { "risk_score": 5, "risk_reasons": [], "usage_type": "cdn", "is_datacenter": true, "is_proxy": false, "threat_level": "Low", "threat_lists": [] } } ``` ``` -------------------------------- ### Risk Assessment Helpers Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Helper functions to evaluate the risk associated with an IP address based on its security score and to detect if the IP belongs to a datacenter or proxy. ```APIDOC ## Risk Assessment Helpers ### Description These functions assist in evaluating IP risk and identifying potential datacenter or proxy usage. ### Functions #### `is_high_risk(info: IPInfo, threshold: int = 50) -> bool` Checks if the IP's security risk score exceeds a specified threshold. #### `is_datacenter_or_proxy(info: IPInfo) -> bool` Determines if the IP address originates from a datacenter or a proxy. ### Usage Example (Python) ```python # Assuming 'ip_info' is the object returned by lookup_ip() if is_high_risk(ip_info): print(f"High risk! Reasons: {ip_info.security.risk_reasons}") if is_datacenter_or_proxy(ip_info): print("Traffic from datacenter or proxy detected") ``` ``` -------------------------------- ### Lookup Specific IP Address using cURL Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Shows how to retrieve detailed intelligence for a specified IPv4 or IPv6 address using cURL. This is useful for fraud prevention and access control. It also demonstrates extracting specific fields. ```bash # Lookup Google DNS server curl -s https://api.ipbot.com/8.8.8.8 | jq # Extract specific fields curl -s https://api.ipbot.com/8.8.8.8 | jq '{ ip: .ip, country: .location.country, city: .location.city, asn: .network.asn, org: .network.org, risk_score: .security.risk_score, is_datacenter: .security.is_datacenter }' # Expected output: { "ip": "8.8.8.8", "country": "United States", "city": "Mountain View", "asn": "AS15169", "org": "Google LLC", "risk_score": 15, "is_datacenter": true } ``` -------------------------------- ### Query Parameter Style IP Lookup using cURL Source: https://context7.com/webunblocker/ipbot-examples/llms.txt An alternative method to look up IP information using a query parameter instead of a path parameter. This is useful for dynamic URL construction. ```bash # Query parameter style lookup curl -s "https://api.ipbot.com/api?ip=1.1.1.1" | jq ``` -------------------------------- ### Auto-Detect Caller IP using cURL Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Demonstrates how to retrieve comprehensive information about the requesting client's IP address using a simple cURL command. This is useful for visitor analytics and logging. ```bash # Auto-detect your IP address curl -s https://api.ipbot.com/ | jq # Expected output: { "ip": "203.0.113.42", "location": { "country": "United States", "country_code": "US", "region": "California", "city": "San Francisco", "postal": "94102", "latitude": 37.7749, "longitude": -122.4194, "timezone": "America/Los_Angeles" }, "network": { "asn": "AS7922", "org": "Comcast Cable Communications", "radar": "isp" }, "security": { "risk_score": 10, "risk_reasons": [], "usage_type": "residential", "is_datacenter": false, "is_proxy": false, "threat_level": "Low", "threat_lists": [] } } ``` -------------------------------- ### Python Risk Assessment Helpers for IP Information Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Provides Python helper functions to assess the security risk of an IP address. It includes checks for high-risk scores against a defined threshold and detection of datacenter or proxy origins. These functions take an `IPInfo` object as input and return a boolean. ```python def is_high_risk(info: IPInfo, threshold: int = 50) -> bool: """Check if IP exceeds risk threshold.""" return info.security.risk_score >= threshold def is_datacenter_or_proxy(info: IPInfo) -> bool: """Check if IP is from datacenter or proxy.""" return info.security.is_datacenter or info.security.is_proxy # Usage ip_info = lookup_ip("8.8.8.8") if is_high_risk(ip_info): print(f"High risk! Reasons: {ip_info.security.risk_reasons}") if is_datacenter_or_proxy(ip_info): print("Traffic from datacenter or proxy detected") ``` -------------------------------- ### IP Geolocation Lookup with Python Source: https://github.com/webunblocker/ipbot-examples/blob/main/README.md Demonstrates a basic IP lookup using the IPBot API in Python, including essential error handling for network requests and response parsing. ```python import requests import json IPBOT_API_URL = "https://api.ipbot.com/" def get_ip_info(ip_address): try: response = requests.get(f"{IPBOT_API_URL}{ip_address}") response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error fetching data: {e}") return None except json.JSONDecodeError: print("Error decoding JSON response.") return None if __name__ == "__main__": ip_to_lookup = "8.8.8.8" ip_data = get_ip_info(ip_to_lookup) if ip_data: print(json.dumps(ip_data, indent=2)) ``` -------------------------------- ### Lookup Specific IP Address Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Retrieves detailed intelligence for any specified IPv4 or IPv6 address. Use this for fraud prevention, access control, or enriching log data. ```APIDOC ## GET /{ip} ### Description Retrieves detailed intelligence for any specified IPv4 or IPv6 address. ### Method GET ### Endpoint `/{ip}` ### Parameters #### Path Parameters - **ip** (string) - Required - The IPv4 or IPv6 address to look up. #### Query Parameters None #### Request Body None ### Request Example ```bash # Lookup Google DNS server curl -s https://api.ipbot.com/8.8.8.8 # Extract specific fields curl -s https://api.ipbot.com/8.8.8.8 | jq '{ ip: .ip, country: .location.country, city: .location.city, asn: .network.asn, org: .network.org, risk_score: .security.risk_score, is_datacenter: .security.is_datacenter }' ``` ### Response #### Success Response (200) - **ip** (string) - The IP address. - **location** (object) - Geolocation details. - **country** (string) - Country name. - **country_code** (string) - Two-letter country code. - **region** (string) - State or region name. - **city** (string) - City name. - **postal** (string) - Postal code. - **latitude** (float) - Latitude coordinate. - **longitude** (float) - Longitude coordinate. - **timezone** (string) - Timezone name. - **network** (object) - Network information. - **asn** (string) - Autonomous System Number. - **org** (string) - Organization name. - **radar** (string) - Network radar type (e.g., 'isp'). - **security** (object) - Security intelligence. - **risk_score** (integer) - Risk score (0-100). - **risk_reasons** (array) - Reasons for the risk score. - **usage_type** (string) - Type of IP usage (e.g., 'residential', 'business'). - **is_datacenter** (boolean) - True if the IP belongs to a datacenter. - **is_proxy** (boolean) - True if the IP is a proxy. - **threat_level** (string) - Threat level (e.g., 'Low', 'Medium', 'High'). - **threat_lists** (array) - Lists the IP is associated with. #### Response Example ```json { "ip": "8.8.8.8", "country": "United States", "city": "Mountain View", "asn": "AS15169", "org": "Google LLC", "risk_score": 15, "is_datacenter": true } ``` ``` -------------------------------- ### JavaScript IP Lookup and Risk Assessment Source: https://context7.com/webunblocker/ipbot-examples/llms.txt An asynchronous JavaScript function `lookupIP` using the Fetch API for IP intelligence lookups, compatible with Node.js 18+ and modern browsers. It returns a promise that resolves to the IP information object. Includes helper functions for risk assessment and location formatting. ```javascript const BASE_URL = 'https://api.ipbot.com'; /** * Lookup IP information * @param {string} [ip] - IP address to lookup. Auto-detects if omitted. * @returns {Promise} IP information object */ async function lookupIP(ip) { const url = ip ? `${BASE_URL}/${ip}` : BASE_URL; const response = await fetch(url, { headers: { 'Accept': 'application/json' } }); const data = await response.json(); if (!response.ok) { throw new Error(data.error || `HTTP ${response.status}`); } return data; } // Helper functions function isHighRisk(info, threshold = 50) { return info.security.risk_score >= threshold; } function isDatacenterOrProxy(info) { return info.security.is_datacenter || info.security.is_proxy; } function formatLocation(info) { const { city, region, country } = info.location; return [city, region, country].filter(Boolean).join(', '); } // Usage example async function main() { try { // Auto-detect caller IP const myIP = await lookupIP(); console.log(`IP: ${myIP.ip}`); console.log(`Location: ${formatLocation(myIP)}`); console.log(`Risk Score: ${myIP.security.risk_score}`); // Lookup specific IP const googleDNS = await lookupIP('8.8.8.8'); console.log(`ASN: ${googleDNS.network.asn} (${googleDNS.network.org})`); console.log(`Is Datacenter: ${googleDNS.security.is_datacenter}`); // Risk check if (isHighRisk(googleDNS)) { console.log(`High risk! Reasons: ${googleDNS.security.risk_reasons.join(', ')}`); } } catch (error) { console.error('Error:', error.message); } } main(); ``` -------------------------------- ### Auto-Detect Caller IP Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Returns comprehensive information about the requesting client's IP address. This is useful for visitor analytics, access logging, or displaying user location. ```APIDOC ## GET / ### Description Returns comprehensive information about the requesting client's IP address. ### Method GET ### Endpoint / ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```bash curl -s https://api.ipbot.com/ ``` ### Response #### Success Response (200) - **ip** (string) - The IP address. - **location** (object) - Geolocation details. - **country** (string) - Country name. - **country_code** (string) - Two-letter country code. - **region** (string) - State or region name. - **city** (string) - City name. - **postal** (string) - Postal code. - **latitude** (float) - Latitude coordinate. - **longitude** (float) - Longitude coordinate. - **timezone** (string) - Timezone name. - **network** (object) - Network information. - **asn** (string) - Autonomous System Number. - **org** (string) - Organization name. - **radar** (string) - Network radar type (e.g., 'isp'). - **security** (object) - Security intelligence. - **risk_score** (integer) - Risk score (0-100). - **risk_reasons** (array) - Reasons for the risk score. - **usage_type** (string) - Type of IP usage (e.g., 'residential', 'business'). - **is_datacenter** (boolean) - True if the IP belongs to a datacenter. - **is_proxy** (boolean) - True if the IP is a proxy. - **threat_level** (string) - Threat level (e.g., 'Low', 'Medium', 'High'). - **threat_lists** (array) - Lists the IP is associated with. #### Response Example ```json { "ip": "203.0.113.42", "location": { "country": "United States", "country_code": "US", "region": "California", "city": "San Francisco", "postal": "94102", "latitude": 37.7749, "longitude": -122.4194, "timezone": "America/Los_Angeles" }, "network": { "asn": "AS7922", "org": "Comcast Cable Communications", "radar": "isp" }, "security": { "risk_score": 10, "risk_reasons": [], "usage_type": "residential", "is_datacenter": false, "is_proxy": false, "threat_level": "Low", "threat_lists": [] } } ``` ``` -------------------------------- ### Service Health Check using cURL Source: https://context7.com/webunblocker/ipbot-examples/llms.txt A simple cURL command to check the current status of the IPBot API service. This is essential for monitoring integrations. ```bash # Health check curl -s https://api.ipbot.com/health | jq ``` -------------------------------- ### IP Lookup API Source: https://context7.com/webunblocker/ipbot-examples/llms.txt This API endpoint allows you to retrieve comprehensive intelligence about a given IP address. It supports auto-detection of the caller's IP if no specific IP is provided. ```APIDOC ## GET / ### Description Retrieves intelligence information for a specified IP address. If no IP is provided, it defaults to the caller's IP address. ### Method GET ### Endpoint `https://api.ipbot.com/` or `https://api.ipbot.com/` (for auto-detection) ### Parameters #### Query Parameters - **ip** (string) - Optional - The IP address to look up. If omitted, the API will attempt to detect the caller's IP. ### Request Example ``` GET https://api.ipbot.com/8.8.8.8 ``` ### Response #### Success Response (200) - **ip** (string) - The IP address. - **location** (object) - Location details (city, region, country). - **network** (object) - Network details (ASN, organization). - **security** (object) - Security information (risk score, datacenter status, proxy status, risk reasons). #### Response Example ```json { "ip": "8.8.8.8", "location": { "city": "Mountain View", "region": "California", "country": "United States" }, "network": { "asn": 15169, "org": "Google LLC" }, "security": { "risk_score": 10, "is_datacenter": true, "is_proxy": false, "risk_reasons": [] } } ``` ``` -------------------------------- ### Lookup IP Information in Python Source: https://context7.com/webunblocker/ipbot-examples/llms.txt Provides a Python function `lookup_ip` to query the IPBot API and retrieve IP intelligence data. It supports auto-detection of the caller's IP and includes error handling. Requires Python 3. ```python #!/usr/bin/env python3 import json import urllib.request import urllib.error from dataclasses import dataclass from typing import Optional BASE_URL = "https://api.ipbot.com" @dataclass class Location: country: str country_code: str region: str city: str postal: str latitude: float longitude: float timezone: str @dataclass class Network: asn: str org: str radar: str @dataclass class Security: risk_score: int risk_reasons: list[str] usage_type: str is_datacenter: bool is_proxy: bool threat_level: str threat_lists: list[str] @dataclass class IPInfo: ip: str location: Location network: Network security: Security @classmethod def from_dict(cls, data: dict) -> "IPInfo": return cls( ip=data["ip"], location=Location(**data["location"]), network=Network(**data["network"]), security=Security(**data["security"]), ) def lookup_ip(ip: Optional[str] = None) -> IPInfo: """Lookup IP information. Pass None for auto-detect.""" url = f"{BASE_URL}/{ip}" if ip else BASE_URL req = urllib.request.Request(url) req.add_header("Accept", "application/json") try: with urllib.request.urlopen(req, timeout=10) as response: data = json.loads(response.read().decode()) return IPInfo.from_dict(data) except urllib.error.HTTPError as e: if e.code == 400: error_data = json.loads(e.read().decode()) raise ValueError(error_data.get("error", "Invalid request")) raise # Usage example my_ip = lookup_ip() # Auto-detect print(f"IP: {my_ip.ip}") print(f"Location: {my_ip.location.city}, {my_ip.location.country}") print(f"Risk Score: {my_ip.security.risk_score}") google_dns = lookup_ip("8.8.8.8") # Specific IP print(f"ASN: {google_dns.network.asn} ({google_dns.network.org})") print(f"Is Datacenter: {google_dns.security.is_datacenter}") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.