### Install IPinfo CLI with Ubuntu PPA Source: https://ipinfo.io/developers/llms-full.txt Install the IPinfo CLI on Ubuntu using a PPA. Ensure to update apt and install the package. ```bash # Ubuntu PPA echo "deb [trusted=yes] https://ppa.ipinfo.net/ /" | sudo tee "/etc/apt/sources.list.d/ipinfo.ppa.list" sudo apt update sudo apt install ipinfo ``` -------------------------------- ### Install IPinfo CLI with Ubuntu PPA Source: https://ipinfo.io/developers/cli Install the IPinfo CLI on Ubuntu using a PPA. Ensure you update your package list and then install the package. ```bash # Ubuntu PPA echo "deb [trusted=yes] https://ppa.ipinfo.net/ /" | sudo tee "/etc/apt/sources.list.d/ipinfo.ppa.list" sudo apt update sudo apt install ipinfo ``` -------------------------------- ### Install IPinfo CLI with Homebrew Source: https://ipinfo.io/developers/cli Use Homebrew to install the IPinfo CLI on macOS. ```bash # macOS brew install ipinfo-cli ``` -------------------------------- ### Fetch API (Async/Await) Example Source: https://ipinfo.io/developers/llms-full.txt Example of using the Fetch API with async/await syntax to retrieve IP information from the IPinfo API. ```APIDOC ## GET /lite/me ### Description Demonstrates fetching IP information using the Fetch API with async/await syntax for cleaner asynchronous code. ### Method GET ### Endpoint https://api.ipinfo.io/lite/me?token=$TOKEN ### Parameters #### Query Parameters - **token** (string) - Required - Your IPinfo API token. ### Request Example ```javascript const request = await fetch("https://api.ipinfo.io/lite/me?token=$TOKEN"); const jsonResponse = await request.json(); console.log(jsonResponse.ip, jsonResponse.country); ``` ### Response #### Success Response (200) - A JSON object containing IP information. #### Response Example ```json { "ip": "102.135.36.0", "country": "Turkey" } ``` ``` -------------------------------- ### Install IPinfo CLI Auto-completion Source: https://ipinfo.io/developers/llms-full.txt Command to install shell auto-completion for the IPinfo CLI. ```bash ipinfo completion install ``` -------------------------------- ### Fetch API (Promise) Example Source: https://ipinfo.io/developers/llms-full.txt Example of using the Fetch API with Promises to retrieve IP information from the IPinfo API. ```APIDOC ## GET /lite/me ### Description Demonstrates fetching IP information using the Fetch API and handling the response with Promises. ### Method GET ### Endpoint https://api.ipinfo.io/lite/me?token=$TOKEN ### Parameters #### Query Parameters - **token** (string) - Required - Your IPinfo API token. ### Request Example ```javascript fetch("https://api.ipinfo.io/lite/me?token=$TOKEN") .then((response) => response.json()) .then((jsonResponse) => console.log(jsonResponse.ip, jsonResponse.country)); ``` ### Response #### Success Response (200) - A JSON object containing IP information. #### Response Example ```json { "ip": "102.135.36.0", "country": "Turkey" } ``` ``` -------------------------------- ### Get Information on Your IP Address (Bash) Source: https://ipinfo.io/developers/lite-api This example shows how to retrieve information about your current IP address using a simple curl command. Replace `$TOKEN` with your actual IPinfo API token. ```APIDOC ## Get Information on Your IP Address ### Description Retrieves details for the IP address making the request. ### Method `GET` ### Endpoint `/lite/me` ### Query Parameters - **token** (string) - Required - Your IPinfo API token. ### Request Example ```bash curl https://api.ipinfo.io/lite/me?token=$TOKEN ``` ### Response #### Success Response (200) Returns a JSON object containing IP address details. - **ip** (string) - The IP address. - **asn** (string) - The Autonomous System Number. - **as_name** (string) - The name of the organization associated with the ASN. - **as_domain** (string) - The domain name associated with the ASN. - **country_code** (string) - The two-letter country code. - **country** (string) - The full country name. - **continent_code** (string) - The two-letter continent code. - **continent** (string) - The full continent name. ### Response Example ```json { "ip": "8.8.8.8", "asn": "AS15169", "as_name": "Google LLC", "as_domain": "google.com", "country_code": "US", "country": "United States", "continent_code": "NA", "continent": "North America" } ``` ``` -------------------------------- ### Install shell completions Source: https://ipinfo.io/developers/cli Automatically install shell completion scripts for your current shell. ```bash ipinfo completion install ``` -------------------------------- ### IPinfo Core API - Full Response Example Source: https://ipinfo.io/developers/ip-privacy-detection-api-data Example of a full response from the IPinfo Core API, including privacy detection flags. ```json { "is_anonymous": true, "is_hosting": true } ``` -------------------------------- ### Java - Initialize Lite Client and Lookup IP Source: https://ipinfo.io/developers/llms-full.txt Illustrates how to set up the Java IPinfo Lite client and perform an IP address lookup. ```APIDOC ## Initialize Lite Client and Lookup IP ```java import io.ipinfo.api.IPinfoLite; import io.ipinfo.api.errors.RateLimitedException; import io.ipinfo.api.model.IPResponseLite; public class Main { public static void main(String[] args) { // Read token from env var (equivalent to $TOKEN in curl) String token = System.getenv("TOKEN"); // Initialize Lite client IPinfoLite client = new IPinfoLite.Builder() .setToken(token) .build(); try { // Lookup an IP (Lite endpoint: https://api.ipinfo.io/lite/{ip}) IPResponseLite details = client.lookupIP("8.8.8.8"); // Access fields (names match the Lite response) System.out.println(details.getIp()); // 8.8.8.8 System.out.println(details.getAsn()); // AS15169 System.out.println(details.getAsName()); // Google LLC System.out.println(details.getAsDomain()); // google.com System.out.println(details.getCountryCode()); // US System.out.println(details.getCountry()); // United States System.out.println(details.getContinentCode()); // NA System.out.println(details.getContinent()); // North America } catch (RateLimitedException ex) { // Handle rate limits here (HTTP 429) System.err.println("Rate limited by IPinfo API"); } } } ``` ``` -------------------------------- ### Retrieve Specific Field: City Source: https://ipinfo.io/developers/llms-full.txt To get a single field, append the field name to the /geo path. This example retrieves only the city. ```bash $ https://api.ipinfo.io/lookup/37.67.193.154/geo/city?token=$TOKEN ``` -------------------------------- ### Create a WHOIS Server Source: https://ipinfo.io/developers/llms-full.txt This guide explains how to build a WHOIS server from scratch, likely for querying IP address information. It involves understanding network protocols and data handling. ```go package main import ( "fmt" "net" "os" "strings" ) func main() { port := "43" listener, err := net.Listen("tcp", ":"+port) if err != nil { fmt.Println("Error listening:", err.Error()) os.Exit(1) } defer listener.Close() fmt.Println("Listening on port " + port) for { conn, err := listener.Accept() if err != nil { fmt.Println("Error accepting:", err.Error()) continue } go handleConnection(conn) } } func handleConnection(conn net.Conn) { buffer := make([]byte, 1024) _, err := conn.Read(buffer) if err != nil { fmt.Println("Error reading:", err.Error()) return } query := strings.TrimSpace(string(buffer)) fmt.Printf("Received query: %s\n", query) // In a real WHOIS server, you would query a WHOIS database here response := "WHOIS information for " + query + "\n" _, err = conn.Write([]byte(response)) if err != nil { fmt.Println("Error writing:", err.Error()) } conn.Close() } ``` -------------------------------- ### Querying IPinfo Databases with Python Library Source: https://ipinfo.io/developers/guides Getting started with the IPinfo-DB Python library to download and query IPinfo databases directly from your Python applications. ```python from ipinfo_db import IPinfoDB db = IPinfoDB(token='YOUR_TOKEN') # Query by IP address print(db.get_details('8.8.8.8')) # Query by IP address range print(db.get_details('1.0.0.0/24')) ``` -------------------------------- ### Go - Initialize Lite Client and Get IP Info Source: https://ipinfo.io/developers/llms-full.txt Demonstrates initializing the Go Lite client, retrieving information for the current IP, and for a specific IP address. ```APIDOC ## Initialize Lite Client and Get IP Info ```go name=main.go package main import ( "encoding/json" "fmt" "log" "net" "os" "github.com/ipinfo/go/v2/ipinfo" ) func main() { // Read token (same as $TOKEN in your curl example) token := os.Getenv("IPINFO_TOKEN") if token == "" { log.Fatal("missing IPINFO_TOKEN") } // Initialize Lite client (https://api.ipinfo.io/lite/) client := ipinfo.NewLiteClient(nil, nil, token) // Call GetIPInfo() with no IP to get "me" myInfo, err := client.GetIPInfo(nil) if err != nil { log.Fatal(err) } fmt.Println("My IP:", myInfo.IP) fmt.Println("My country:", myInfo.Country) // Call GetIPInfo() for a specific IP (like: /lite/8.8.8.8?token=...) info, err := client.GetIPInfo(net.ParseIP("8.8.8.8")) if err != nil { log.Fatal(err) } // Get ALL details as JSON b, _ := json.MarshalIndent(info, "", " ") fmt.Println(string(b)) } ``` ### Response Example ```json { "ip": "8.8.8.8", "asn": "AS15169", "as_name": "Google LLC", "as_domain": "google.com", "country_code": "US", "country": "United States", "continent_code": "NA", "continent": "North America" } ``` ``` -------------------------------- ### Get IPv6 Address Information Source: https://ipinfo.io/developers/code-snippets Retrieve detailed information for a given IPv6 address. Replace the example IP with your target IPv6 address. Ensure your token is set. ```bash https://api.ipinfo.io/lookup/2001:1900:2100:280e::f0?token=$TOKEN ``` -------------------------------- ### Initialize Lite Client and Get IP Info (Go) Source: https://ipinfo.io/developers/lite-api Initialize the IPinfo Lite client in Go using an environment variable for the token. Fetch details for the current IP address. ```go package main import ( "encoding/json" "fmt" "log" "net" "os" "github.com/ipinfo/go/v2/ipinfo" ) func main() { // Read token (same as $TOKEN in your curl example) token := os.Getenv("IPINFO_TOKEN") if token == "" log.Fatal("missing IPINFO_TOKEN") // Initialize Lite client (https://api.ipinfo.io/lite/) client := ipinfo.NewLiteClient(nil, nil, token) // Call GetIPInfo() with no IP to get "me" myInfo, err := client.GetIPInfo(nil) if err != nil log.Fatal(err) fmt.Println("My IP:", myInfo.IP) fmt.Println("My country:", myInfo.Country) ``` -------------------------------- ### Get IPv4 Address Information Source: https://ipinfo.io/developers/code-snippets Retrieve detailed information for a given IPv4 address. Replace the example IP with your target IPv4 address. Ensure your token is set. ```bash https://api.ipinfo.io/lookup/106.54.79.181?token=$TOKEN ``` -------------------------------- ### Get IPv6 Address Info with Plus API Source: https://ipinfo.io/developers/llms-full.txt Retrieve detailed information for a specific IPv6 address using the Plus API. Replace the example IP with your target address. ```bash https://api.ipinfo.io/lookup/2c0f:4280:6040:1dbe:89e4:b86e:9e0a:cbb0?token=$TOKEN ``` -------------------------------- ### Initialize Lite Client and Lookup IP (Go) Source: https://ipinfo.io/developers/llms-full.txt Initialize the IPinfo Lite client using an API token and perform a lookup for a specific IP address. This example demonstrates client initialization and IP lookup. ```go package main import ( "encoding/json" "fmt" "log" "net" "os" "github.com/ipinfo/go/v2/ipinfo" ) func main() { // Read token (same as $TOKEN in your curl example) token := os.Getenv("IPINFO_TOKEN") if token == "" log.Fatal("missing IPINFO_TOKEN") // Initialize Lite client (https://api.ipinfo.io/lite/) client := ipinfo.NewLiteClient(nil, nil, token) // Call GetIPInfo() with no IP to get "me" myInfo, err := client.GetIPInfo(nil) if err != nil log.Fatal(err) fmt.Println("My IP:", myInfo.IP) fmt.Println("My country:", myInfo.Country) // Call GetIPInfo() for a specific IP (like: /lite/8.8.8.8?token=...) info, err := client.GetIPInfo(net.ParseIP("8.8.8.8")) if err != nil log.Fatal(err) // Get ALL details as JSON b, _ := json.MarshalIndent(info, "", " ") fmt.Println(string(b)) } ``` -------------------------------- ### Get IPv4 Address Info with Plus API Source: https://ipinfo.io/developers/llms-full.txt Retrieve detailed information for a specific IPv4 address using the Plus API. Replace the example IP with your target address. ```bash https://api.ipinfo.io/lookup/88.246.188.185?token=$TOKEN ``` -------------------------------- ### Initialize ipinfo client in Python Source: https://ipinfo.io/developers/llms-full.txt Imports the ipinfo library to prepare for IP address lookups. ```python import ipinfo ``` -------------------------------- ### Get IPv6 Address Info Source: https://ipinfo.io/developers/code-snippets Retrieve detailed information for a specific IPv6 address. Replace the example IP with your target IPv6 address. Ensure your API token is set. ```bash https://api.ipinfo.io/lookup/2c0f:4280:6040:1dbe:89e4:b86e:9e0a:cbb0?token=$TOKEN ``` -------------------------------- ### Get IPv4 Address Info Source: https://ipinfo.io/developers/code-snippets Retrieve detailed information for a specific IPv4 address. Replace the example IP with your target IPv4 address. Ensure your API token is set. ```bash https://api.ipinfo.io/lookup/88.246.188.185?token=$TOKEN ``` -------------------------------- ### Log in or save token Source: https://ipinfo.io/developers/cli Initialize the CLI by logging in interactively or by providing a token directly. Use '--no-check' to skip token validation. ```bash ipinfo init [token] ``` -------------------------------- ### Using IP4R Extension with PostgreSQL Source: https://ipinfo.io/developers/guides Guides on installing and using the IP4R extension in PostgreSQL for IP address management and querying. It highlights advantages over native network address types. ```sql CREATE EXTENSION ip4r; ``` ```sql SELECT ip, network FROM ip_addresses; ``` -------------------------------- ### Get IPv4 Address Lite API Info Source: https://ipinfo.io/developers/code-snippets Fetch country and ASN details for a specific IPv4 address using the Lite API. Replace the example IP with your target address. ```bash https://api.ipinfo.io/lite/3.153.114.80?token=$TOKEN ``` -------------------------------- ### Initialize Lite Client and Lookup IP (Java) Source: https://ipinfo.io/developers/llms-full.txt Initialize the IPinfo Lite client with a token and perform a lookup for a specific IP address. This example shows how to access individual fields from the Lite response. ```java import io.ipinfo.api.IPinfoLite; import io.ipinfo.api.errors.RateLimitedException; import io.ipinfo.api.model.IPResponseLite; public class Main { public static void main(String[] args) { // Read token from env var (equivalent to $TOKEN in curl) String token = System.getenv("TOKEN"); // Initialize Lite client IPinfoLite client = new IPinfoLite.Builder() .setToken(token) .build(); try { // Lookup an IP (Lite endpoint: https://api.ipinfo.io/lite/{ip}) IPResponseLite details = client.lookupIP("8.8.8.8"); // Access fields (names match the Lite response) System.out.println(details.getIp()); // 8.8.8.8 System.out.println(details.getAsn()); // AS15169 System.out.println(details.getAsName()); // Google LLC System.out.println(details.getAsDomain()); // google.com System.out.println(details.getCountryCode()); // US System.out.println(details.getCountry()); // United States System.out.println(details.getContinentCode()); // NA System.out.println(details.getContinent()); // North America } catch (RateLimitedException ex) { // Handle rate limits here (HTTP 429) System.err.println("Rate limited by IPinfo API"); } } } ``` -------------------------------- ### Python SDK - Get All Details Source: https://ipinfo.io/developers/llms-full.txt Demonstrates how to retrieve all available details for an IP address using the Python SDK. ```APIDOC ## Get ALL details as a dictionary ```python print(my_details.all) ``` ### Response Example ```json { "ip": "8.8.8.8", "asn": "AS15169", "as_name": "Google LLC", "as_domain": "google.com", "country_code": "US", "country": "United States", "continent_code": "NA", "continent": "North America" } ``` ``` -------------------------------- ### Get IP Ranges for a Specific ASN Source: https://ipinfo.io/developers/llms-full.txt Retrieve IP address ranges in CIDR format for a given ASN using the IP_ASN database. The `range_to_cidr` UDF converts start and end IPs into CIDR notation. ```sql -- Example asn: AS39927 -- Using the ASN database SELECT flat_data.value as IP_RANGE FROM ( SELECT ipinfo.public.range_to_cidr(start_ip, end_ip) as ip_range FROM ipinfo.public.ip_asn WHERE asn='AS39927' ) as_ips, TABLE(FLATTEN(as_ips.ip_range)) flat_data ``` -------------------------------- ### Node.js - Lookup IP and Access Details Source: https://ipinfo.io/developers/llms-full.txt Shows how to initialize the Node.js client, look up an IP address, and access its details. ```APIDOC ## Lookup IP and Access Details ```js import { IPinfoLiteWrapper } from "node-ipinfo"; // Initialize Lite client const client = new IPinfoLiteWrapper(process.env.TOKEN || "$TOKEN"); // Call lookupIp() with an IP address (Lite endpoint) const details = await client.lookupIp("8.8.8.8"); // Access fields (note: this SDK uses camelCase) console.log(details.ip); // "8.8.8.8" console.log(details.asn); // "AS15169" console.log(details.asName); // "Google LLC" console.log(details.asDomain); // "google.com" console.log(details.countryCode); // "US" console.log(details.country); // "United States" console.log(details.continentCode); // "NA" console.log(details.continent); // "North America" // Get ALL details as an object console.log(details); ``` ### Response Example ```json { "ip": "8.8.8.8", "asn": "AS15169", "as_name": "Google LLC", "as_domain": "google.com", "country_code": "US", "country": "United States", "continent_code": "NA", "continent": "North America" } ``` ``` -------------------------------- ### Example API URLs Source: https://ipinfo.io/developers/llms-full.txt Construct API URLs for IPinfo Lite, Lookup, and Legacy endpoints, including IP addresses, field filters, and authentication tokens. ```text https://api.ipinfo.io/lite/me?token=$TOKEN https://api.ipinfo.io/lookup/8.8.8.8?token=$TOKEN https://api.ipinfo.io/lite/2001:4860:4860::8888/country?token=$TOKEN ``` -------------------------------- ### Initialize IPinfo CLI with a Token Source: https://ipinfo.io/developers/llms-full.txt Authenticate the IPinfo CLI with your token. A token is necessary for bulk lookups and advanced features. ```bash ipinfo init ``` -------------------------------- ### Initialize IPinfo client in Python Source: https://ipinfo.io/developers/lite-api Initializes the IPinfo client with an access token. This is a boilerplate setup for subsequent API calls. ```python import ipinfo ``` -------------------------------- ### API Response Example Source: https://ipinfo.io/developers/llms-full.txt This is an example of the JSON response structure for a general API request. ```json { // [...] "country_code": "FR", "country": "France", "continent_code": "EU", "continent": "Europe" } ``` -------------------------------- ### Authenticate IPinfo CLI Source: https://ipinfo.io/developers/cli Initialize the IPinfo CLI by running the 'init' command. A token is required for bulk lookups and some advanced APIs; without one, data is limited. ```bash ipinfo init ``` -------------------------------- ### API Response Example Source: https://ipinfo.io/developers/llms-full.txt This is an example of the JSON response structure you can expect when querying the Privacy API. ```json { "vpn": true, "proxy": false, "tor": false, "relay": false, "hosting": true, "service": "CyberGhost", "confidence": 3, "coverage": 1, "census": true, "census_ports": "500", "device_activity": false, "inferred": false, "vpn_config": true, "whois": false, "first_seen": "2025-12-12", "last_seen": "2025-12-12" } ``` -------------------------------- ### Install IPinfo CLI with Docker Source: https://ipinfo.io/developers/cli Run the IPinfo CLI using Docker. This command pulls the specified version and runs it interactively. ```bash # Docker docker run --rm -it ipinfo/ipinfo:3.3.1 ``` -------------------------------- ### Legacy API Response Example Source: https://ipinfo.io/developers/plus-api An example of the JSON response structure from the legacy IPinfo API. ```json { "ip": "8.8.8.8", "hostname": "dns.google", "anycast": true, "city": "Mountain View", "region": "California", "country": "US", "loc": "37.4056,-122.0775", "postal": "94043", "timezone": "America/Los_Angeles", "asn": { "asn": "AS15169", "name": "Google LLC", "domain": "google.com", "route": "8.8.8.0/24", "type": "business" }, "privacy": { "vpn": false, "proxy": false, "tor": false, "relay": false, "hosting": false, "service": "" } } ``` -------------------------------- ### Hosting IP Lookup Source: https://ipinfo.io/developers/llms-full.txt This example demonstrates how to look up a hosting IP address. The response indicates `is_hosting: true`. ```APIDOC ## Hosting IP Lookup ### Description This endpoint allows you to retrieve information about a hosting IP address. The response includes details such as hostname, geolocation, and ASN information, with the `is_hosting` flag set to true. ### Method GET ### Endpoint `https://api.ipinfo.io/lookup/{ip}?token=$TOKEN` ### Parameters #### Path Parameters - **ip** (string) - Required - The IP address to look up. - **token** (string) - Required - Your ipinfo.io API token. ### Request Example ```bash https://api.ipinfo.io/lookup/69.55.136.48?token=$TOKEN ``` ### Response #### Success Response (200) - **ip** (string) - The IP address. - **hostname** (string) - The hostname associated with the IP address. - **geo** (object) - Geolocation information. - **city** (string) - The city. - **region** (string) - The region or state. - **region_code** (string) - The region code. - **country** (string) - The country. - **country_code** (string) - The country code. - **continent** (string) - The continent. - **continent_code** (string) - The continent code. - **latitude** (number) - The latitude coordinate. - **longitude** (number) - The longitude coordinate. - **timezone** (string) - The timezone. - **postal_code** (string) - The postal code. - **as** (object) - Autonomous System Number information. - **asn** (string) - The ASN number. - **name** (string) - The ASN name. - **domain** (string) - The domain associated with the ASN. - **type** (string) - The type of the ASN (e.g., isp). - **is_anonymous** (boolean) - Indicates if the IP is anonymous. - **is_anycast** (boolean) - Indicates if the IP is anycast. - **is_hosting** (boolean) - Indicates if the IP is hosting. - **is_mobile** (boolean) - Indicates if the IP is mobile. - **is_satellite** (boolean) - Indicates if the IP is satellite. #### Response Example ```json { "ip": "69.55.136.48", "geo": { "city": "Kansas City", "region": "Missouri", "region_code": "MO", "country": "United States", "country_code": "US", "continent": "North America", "continent_code": "NA", "latitude": 39.09973, "longitude": -94.57857, "timezone": "America/Chicago", "postal_code": "64106" }, "as": { "asn": "AS62943", "name": "Missouri Network Alliance, LLC", "domain": "bluebirdnetwork.com", "type": "isp" }, "is_anonymous": false, "is_anycast": false, "is_hosting": true, "is_mobile": false, "is_satellite": false } ``` ``` -------------------------------- ### API Response Example Source: https://ipinfo.io/developers/llms-full.txt This is an example of the JSON response structure you can expect when performing a full IP lookup. ```json { "city": "Paris", "region": "Île-de-France", "region_code": "IDF", "country": "France", "country_code": "FR", "continent": "Europe", "continent_code": "EU", "latitude": 48.85341, "longitude": 2.3488, "timezone": "Europe/Paris", "postal_code": "75000" } ``` -------------------------------- ### Print CLI version Source: https://ipinfo.io/developers/cli Display the currently installed version of the IPinfo CLI. ```bash ipinfo version ``` -------------------------------- ### Look up IP Address Details in Go Source: https://ipinfo.io/developers/lite-api Initialize the `ipinfo.NewLiteClient` with your token. Use `client.GetIPInfo` for lookups and `json.MarshalIndent` to get all details as JSON. ```go package main import ( "encoding/json" "fmt" "log" "net" "os" "github.com/ipinfo/go/v2/ipinfo" ) func main() { // Initialize Lite client token := os.Getenv("IPINFO_TOKEN") // same as $TOKEN if token == "" { log.Fatal("missing IPINFO_TOKEN") } client := ipinfo.NewLiteClient(nil, nil, token) // Look up a specific IP address details, err := client.GetIPInfo(net.ParseIP("8.8.8.8")) if err != nil { log.Fatal(err) } // Access individual fields fmt.Println(details.IP.String()) // "8.8.8.8" fmt.Println(details.CountryCode) // "US" fmt.Println(details.Country) // "United States" fmt.Println(details.ASN) // "AS15169" fmt.Println(details.ASName) // "Google LLC" // Get ALL details as JSON b, _ := json.MarshalIndent(details, "", " ") fmt.Println(string(b)) } ``` -------------------------------- ### Legacy API Schema Example Source: https://ipinfo.io/developers/max-api An example of the response structure for the legacy IPinfo API, which is still maintained. ```APIDOC ## Legacy API Schema Example ### Description This example demonstrates the JSON response format for the legacy IPinfo API. ### Request Example ```bash curl https://ipinfo.io/8.8.8.8/json?token=$TOKEN ``` ### Response Example ```json { "ip": "8.8.8.8", "hostname": "dns.google", "anycast": true, "city": "Mountain View", "region": "California", "country": "US", "loc": "37.4056,-122.0775", "postal": "94043", "timezone": "America/Los_Angeles", "asn": { "asn": "AS15169", "name": "Google LLC", "domain": "google.com", "route": "8.8.8.0/24", "type": "business" }, "privacy": { "vpn": false, "proxy": false, "tor": false, "relay": false, "hosting": false, "service": "" } } ``` ``` -------------------------------- ### Extract IP, Currency, Symbol, and Flag with IPinfo CLI Bulk Source: https://ipinfo.io/developers/guides This example demonstrates how to extract specific details like IP, currency, symbol, and flag from a bulk lookup using the IPinfo CLI. ```bash ipinfo --token bulk ip,currency,symbol,flag ``` -------------------------------- ### Get IPv4 Prefixes for an ASN Source: https://ipinfo.io/developers/llms-full.txt Get a list of IPv4 prefixes owned by an ASN using JQ. ```APIDOC ## Get IPv4 Prefixes for an ASN ### Description Get a list of IPv4 prefixes owned by an ASN using JQ. ### Command ```bash curl "ipinfo.io/AS7922/json?token=$TOKEN" | jq -r '.prefixes[].netblock' ``` ### Parameters - `AS7922` - The ASN to query. - `token` - Your IPinfo API token. ``` -------------------------------- ### Deploy App on Search Head Cluster CLI Source: https://ipinfo.io/developers/llms-full.txt Use this command on the Deployer server within a Search Head Cluster environment to deploy the IPinfo app bundle to all search heads. The `-target :` flag applies the bundle to the current configuration. ```bash ./splunk apply shcluster-bundle -target : -auth : ``` -------------------------------- ### Get Timezone Source: https://ipinfo.io/developers/code-snippets Using the IPinfo Core API service, get your/user/visitor IP address timezone information. ```APIDOC ## Get Timezone ### Description Using the IPinfo Core API service, get your/user/visitor IP address timezone information. ### Method GET ### Endpoint https://api.ipinfo.io/lookup/me/geo/timezone?token=$TOKEN ### Response #### Success Response (200) - **timezone** (string) - The timezone information. ``` -------------------------------- ### Enrich Sample IPs with Hosted Domains using ip_hosted_domains UDTF Source: https://ipinfo.io/developers/llms-full.txt This example demonstrates using the `ip_hosted_domains` UDTF with a Common Table Expression (CTE) for sample IP addresses. Ensure your IP column is correctly referenced. ```sql WITH sample_ips (ip) AS ( SELECT * FROM ( VALUES ('8.8.8.8'), ('198.35.26.98') ) ) SELECT * FROM ( SELECT ip FROM sample_ips -- sample log database ) logs JOIN TABLE (ipinfo.public.ip_hosted_domains(logs.ip)); ``` -------------------------------- ### Get Anycast Status Source: https://ipinfo.io/developers/llms-full.txt Using the IPinfo Core API service, get your/user/visitor IP address anycast status. ```APIDOC ## GET /lookup/me/is_anycast ### Description Checks if the user's IP address is an anycast address. ### Method GET ### Endpoint https://api.ipinfo.io/lookup/me/is_anycast?token=$TOKEN ### Response #### Success Response (200) - **is_anycast** (boolean) - True if the IP is anycast, false otherwise. ``` -------------------------------- ### Initialize Lite Client and Lookup IP (Java) Source: https://ipinfo.io/developers/lite-api Initialize the IPinfo Lite client in Java using a token and perform a lookup for a specific IP address. Handle potential rate limiting exceptions. ```java import io.ipinfo.api.IPinfoLite; import io.ipinfo.api.errors.RateLimitedException; import io.ipinfo.api.model.IPResponseLite; public class Main { public static void main(String[] args) { // Read token from env var (equivalent to $TOKEN in curl) String token = System.getenv("TOKEN"); // Initialize Lite client IPinfoLite client = new IPinfoLite.Builder() .setToken(token) .build(); try { // Lookup an IP (Lite endpoint: https://api.ipinfo.io/lite/{ip}) IPResponseLite details = client.lookupIP("8.8.8.8"); ``` -------------------------------- ### Batch IP Lookup with URL Patterns Source: https://ipinfo.io/developers/llms-full.txt Demonstrates how to use the batch endpoint to look up information for multiple IPs and hostnames. The output shows detailed information for some IPs and specific data for others based on the URL pattern. ```bash cat ip_urls.txt | curl -XPOST --data-binary @- "https://api.ipinfo.io/batch?token=$TOKEN" ``` ```json { "1.1.1.1": { "ip": "1.1.1.1", "hostname": "one.one.one.one", "geo": { "city": "Brisbane", "region": "Queensland", "region_code": "QLD", "country": "Australia", "country_code": "AU", "continent": "Oceania", "continent_code": "OC", "latitude": -27.48159, "longitude": 153.0175, "timezone": "Australia/Brisbane", "postal_code": "4101", "geoname_id": "2174003", "radius": 10, "last_changed": "2024-10-20" }, "as": { "asn": "AS13335", "name": "Cloudflare, Inc.", "domain": "cloudflare.com", "type": "hosting", "last_changed": "2025-03-09" }, "mobile": {}, "anonymous": { "is_proxy": false, "is_relay": false, "is_tor": false, "is_vpn": false }, "is_anonymous": false, "is_anycast": true, "is_hosting": true, "is_mobile": false, "is_satellite": false }, "lite/8.8.4.4/country": "United States", "8.8.4.4/anonymous": { "is_proxy": false, "is_relay": false, "is_tor": false, "is_vpn": false }, "lite/8.8.4.4": { "ip": "8.8.4.4", "asn": "AS15169", "as_name": "Google LLC", "as_domain": "google.com", "country_code": "US", "country": "United States", "continent_code": "NA", "continent": "North America" } } ``` -------------------------------- ### Get Anonymous Status Source: https://ipinfo.io/developers/llms-full.txt Using the IPinfo Core API service, get your/user/visitor IP address anonymous status. ```APIDOC ## GET /lookup/me/is_anonymous ### Description Checks if the user's IP address is associated with an anonymous proxy. ### Method GET ### Endpoint https://api.ipinfo.io/lookup/me/is_anonymous?token=$TOKEN ### Response #### Success Response (200) - **is_anonymous** (boolean) - True if the IP is anonymous, false otherwise. ``` -------------------------------- ### Get ASN Value Source: https://ipinfo.io/developers/code-snippets Using the IPinfo Core API service, get your/user/visitor IP address ASN value. ```APIDOC ## Get ASN Value ### Description Using the IPinfo Core API service, get your/user/visitor IP address ASN value. ### Method GET ### Endpoint https://api.ipinfo.io/lookup/me/as/asn?token=$TOKEN ### Response #### Success Response (200) - **asn** (string) - The ASN number. ``` -------------------------------- ### PHP - Get All Details and Lookup Specific IP Source: https://ipinfo.io/developers/llms-full.txt Shows how to get all details for the current IP and how to look up a specific IP address using the PHP SDK. ```APIDOC ## Get ALL details as an associative array (Lite response payload) ```php getDetails(); // Access your information echo $my_details->ip . PHP_EOL; // Your IP address echo $my_details->country . PHP_EOL; // Your country // Get ALL details as an associative array (Lite response payload) print_r($my_details->all); // Lookup a specific IP $details = $client->getDetails('8.8.8.8'); echo json_encode($details->all, JSON_PRETTY_PRINT), PHP_EOL; ``` ### Response Example ```json { "ip": "8.8.8.8", "asn": "AS15169", "as_name": "Google LLC", "as_domain": "google.com", "country_code": "US", "country": "United States", "continent_code": "NA", "continent": "North America" } ``` ``` -------------------------------- ### Install IPinfo CLI with Docker Source: https://ipinfo.io/developers/llms-full.txt Run the IPinfo CLI using a Docker container. This command ensures a clean environment for each run. ```bash # Docker docker run --rm -it ipinfo/ipinfo:3.3.1 ```