### Install node-iplocate Source: https://www.iplocate.io/docs/quick-start Installs the 'node-iplocate' package using npm, yarn, or pnpm. This package is required for server-side integration with the IPLocate API. ```bash npm install node-iplocate # or yarn add node-iplocate # or pnpm add node-iplocate ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Get Go IPLocate Client Source: https://www.iplocate.io/docs/integrations/client-libraries Installs the go-iplocate package using the go get command, which is necessary for using the IPLocate service in Go applications. ```bash go get github.com/iplocate/go-iplocate ``` -------------------------------- ### Look up IP Address Details using IPLocate API Source: https://www.iplocate.io/docs/quick-start Initializes the IPLocate client with an API key and performs a lookup for a given IP address. It logs the full JSON response containing IP details such as country, city, and coordinates. ```javascript import IPLocate from 'node-iplocate'; const client = new IPLocate('YOUR_API_KEY'); const result = await client.lookup('8.8.8.8'); console.log(result); // full JSON (ip, country, country_code, city, latitude, longitude, privacy, ...) ``` -------------------------------- ### Configure API Key Environment Variable Source: https://www.iplocate.io/docs/quick-start Sets the IPLocate API key as an environment variable. It is recommended to use environment variables for API keys in production environments. ```bash IPLOCATE_API_KEY=YOUR_API_KEY ``` -------------------------------- ### Untitled No description -------------------------------- ### Install Ruby IPLocate Client Source: https://www.iplocate.io/docs/integrations/client-libraries Installs the official 'iplocate' gem for Ruby, enabling integration with the IPLocate service. ```ruby gem install iplocate ``` -------------------------------- ### Install Python IPLocate Client Source: https://www.iplocate.io/docs/integrations/client-libraries Installs the official python-iplocate library using pip. This is the first step to using the IPLocate service in Python applications. ```bash pip install python-iplocate ``` -------------------------------- ### Get Country Code for IP Address using IPLocate API Source: https://www.iplocate.io/docs/quick-start Initializes the IPLocate client and performs an IP address lookup, then extracts and logs the country code from the result. This is useful for geo-targeting or country-specific logic. ```javascript import IPLocate from 'node-iplocate'; const client = new IPLocate('YOUR_API_KEY'); const result = await client.lookup('8.8.8.8'); console.log(result.country_code); // US ``` -------------------------------- ### Untitled No description -------------------------------- ### Install PHP IPLocate Client Source: https://www.iplocate.io/docs/integrations/client-libraries Installs the php-iplocate package using Composer, which is required to use the IPLocate service in PHP applications. ```bash composer require iplocate/php-iplocate ``` -------------------------------- ### Example: Get Full IP Details using MCP Source: https://www.iplocate.io/docs/integrations/mcp-server This JSON object shows how to request full details for an IP address using the IPLocate MCP server. It utilizes the `lookup_ip_address_details` tool with the specified IP address. ```json { "tool": "lookup_ip_address_details", "params": {"ip": "1.1.1.1"} } ``` -------------------------------- ### Untitled No description -------------------------------- ### IPLocate Client Library Usage Source: https://www.iplocate.io/docs/getting-started/authentication Example of using the IPLocate Javascript client library, which accepts the API key during initialization. ```APIDOC ## IPLocate Javascript Client Library ### Description This section provides an example of how to use the IPLocate client library for Javascript to perform an IP address lookup. ### Usage Initialize the client with your API key and then use the `lookup` method. ### Request Example ```javascript import IPLocate from 'node-iplocate'; const client = new IPLocate('YOUR_API_KEY'); async function performLookup() { try { const result = await client.lookup('8.8.8.8'); console.log(result); } catch (error) { console.error('Error performing lookup:', error); } } performLookup(); ``` ### Response #### Success Response The `lookup` method returns a promise that resolves to an object containing the IP address details, similar to the API response. #### Response Example ```json { "ip": "8.8.8.8", "city": "Mountain View", "state": "California", "post_code": "94043", "country": "United States", "country_code": "US", "continent": "North America", "latitude": 37.4056, "longitude": -122.0775, "timezone": "America/Los_Angeles", "asn": "AS15169", "asn_description": "Google LLC" } ``` ``` -------------------------------- ### Example IP Lookup using EU API (cURL) Source: https://www.iplocate.io/docs/reference/eu-api-endpoint Demonstrates how to perform an IP address lookup using the iplocate.io EU API endpoint via cURL. Requires an API key for authentication. This example shows a request to the lookup endpoint. ```curl curl "https://eu-api.iplocate.io/api/lookup/8.8.8.8?apikey=YOUR_API_KEY" ``` -------------------------------- ### Check if IP Address is VPN or Proxy using IPLocate API Source: https://www.iplocate.io/docs/quick-start Initializes the IPLocate client and performs an IP address lookup. It then checks the 'privacy' object in the result to determine if the IP address belongs to a VPN or proxy, logging the outcome. ```javascript import IPLocate from 'node-iplocate'; const client = new IPLocate('YOUR_API_KEY'); const result = await client.lookup('8.8.8.8'); if (result.privacy.is_vpn) { console.log('This IP address is a VPN'); } else if (result.privacy.is_proxy) { console.log('This IP address is a proxy'); } else { console.log('This IP address is not a VPN or proxy'); } ``` -------------------------------- ### EU API Endpoint Overview Source: https://www.iplocate.io/docs/reference/eu-api-endpoint This section provides information about the base URL for the EU API endpoint and an example of how to perform a lookup. ```APIDOC ## EU API Endpoint ### Description This API endpoint is specifically designed to route all requests to servers located within the European Union. It's a courtesy for EU customers who require data to be processed within the EU for privacy or data transfer reasons. ### Method GET ### Endpoint `https://eu-api.iplocate.io/api/` ### Parameters #### Query Parameters - **apikey** (string) - Required - Your unique API key for authentication. #### Path Parameters - **ip_address** (string) - Required - The IP address you want to look up. ### Request Example ``` curl "https://eu-api.iplocate.io/api/lookup/8.8.8.8?apikey=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **ip** (string) - The IP address that was looked up. - **country** (string) - The country where the IP address is located. - **city** (string) - The city where the IP address is located. - **latitude** (number) - The latitude coordinate of the IP address location. - **longitude** (number) - The longitude coordinate of the IP address location. #### Response Example ```json { "ip": "8.8.8.8", "country": "United States", "city": "Mountain View", "latitude": 37.4056, "longitude": -122.0775 } ``` ``` -------------------------------- ### API Error Handling Guide Source: https://www.iplocate.io/docs/reference/api-errors This section outlines the standard HTTP status codes used by the IPLocate API and the structure of error responses. It also details common error scenarios and provides code examples for handling these errors in JavaScript and Python. ```APIDOC ## API Errors The IPLocate API uses standard HTTP status codes and provides detailed error messages to help you handle issues programmatically. ### HTTP Status Codes * **200 Success** - Request processed successfully * **400 Bad Request** - Invalid input parameters * **401 Unauthorized** - Authentication or authorization error * **404 Not Found** - IP address not found * **429 Too Many Requests** - Rate limit exceeded * **500 Internal Server Error** - Server-side error ### Error Response Format Error responses return a JSON object with an `error` property that describes what went wrong: ```json { "error": "Error message describing what went wrong" } ``` ### Common Errors #### 400 Bad Request ```json { "error": "Invalid IP address" } ``` **Common causes:** * Malformed IPv4 or IPv6 address format * If behind a proxy, passing the result of an `X-Forwarded-For` header which may include multiple IP addresses, such as `127.0.0.1, 192.168.1.1` * Passing an IP address that is `undefined` or `null` #### 401 Unauthorized ```json { "error": "Missing API key" } ``` ```json { "error": "Invalid API key" } ``` #### 404 Not Found ```json { "error": "Not found" } ``` **Common causes:** * IP address or entity not found #### 429 Too Many Requests ```json { "error": "Rate limit exceeded. Please upgrade your plan at iplocate.io/account" } ``` ### Handling Errors #### JavaScript Example ```javascript try { const response = await fetch('https://iplocate.io/api/lookup/8.8.8.8?apikey=YOUR_API_KEY'); if (!response.ok) { const errorData = await response.json(); console.error('API Error:', errorData.error); switch (response.status) { case 429: // Handle rate limiting const resetDate = new Date(response.headers.get('X-RateLimit-Reset') * 1000); console.log(`Rate limited. Try again after ${resetDate.toISOString()}`); break; case 401: // Handle authentication errors console.log('Check your API key.'); break; default: console.log('Request failed:', response.status); } return; } const data = await response.json(); console.log('Success:', data); } catch (error) { console.error('Network error:', error); } ``` #### Python Example ```python import requests try: response = requests.get('https://iplocate.io/api/lookup/8.8.8.8', params={'apikey': 'YOUR_API_KEY'}) if response.status_code != 200: error_data = response.json() print(f"API Error: {error_data['error']}") if response.status_code == 429: print(f"Rate limited. Resets at {response.headers['X-RateLimit-Reset']}") elif response.status_code == 401: print("Authentication failed. Check API key.") return data = response.json() print(f"Success: {data}") except requests.RequestException as e: print(f"Network error: {e}") ``` ### Troubleshooting #### Getting 401 errors? * Verify your API key is correct and active * Ensure you're not using an expired key * Ensure your API key is being passed in the request - see Authentication #### Getting 429 errors? * Check your current usage in the account dashboard * Upgrade your plan or purchase credits * Implement caching or request throttling in your application #### Getting 500 errors? This indicates a server-side issue. Check our status page for any known issues, or contact us for support. ``` -------------------------------- ### Authenticate with API Key using JavaScript Client Library Source: https://www.iplocate.io/docs/getting-started/authentication This example shows how to authenticate using the IPLocate JavaScript client library. The API key is typically provided during the client's initialization. ```javascript import IPLocate from 'node-iplocate'; const client = new IPLocate('YOUR_API_KEY'); const result = await client.lookup('8.8.8.8'); // ... ``` -------------------------------- ### Lookup IP Address with API Key as Header Source: https://www.iplocate.io/docs/getting-started/authentication This example shows how to perform an IP address lookup by providing your API key in the 'X-API-Key' header. ```APIDOC ## GET /api/lookup/{ip_address} ### Description Performs an IP address lookup. ### Method GET ### Endpoint `/api/lookup/{ip_address}` ### Parameters #### Headers - **X-API-Key** (string) - Required - Your unique API key. #### Path Parameters - **ip_address** (string) - Required - The IP address to look up. ### Request Example ```bash curl "https://iplocate.io/api/lookup/8.8.8.8" -H "X-API-Key: YOUR_API_KEY" ``` ### Response #### Success Response (200) - **ip** (string) - The IP address. - **city** (string) - The city of the IP address. - **state** (string) - The state or region of the IP address. - **post_code** (string) - The postal code of the IP address. - **country** (string) - The country of the IP address. - **country_code** (string) - The country code of the IP address. - **continent** (string) - The continent of the IP address. - **latitude** (number) - The latitude coordinate of the IP address. - **longitude** (number) - The longitude coordinate of the IP address. - **timezone** (string) - The timezone of the IP address. - **asn** (string) - The Autonomous System Number (ASN) associated with the IP address. - **asn_description** (string) - The description of the ASN. #### Response Example ```json { "ip": "8.8.8.8", "city": "Mountain View", "state": "California", "post_code": "94043", "country": "United States", "country_code": "US", "continent": "North America", "latitude": 37.4056, "longitude": -122.0775, "timezone": "America/Los_Angeles", "asn": "AS15169", "asn_description": "Google LLC" } ``` ``` -------------------------------- ### Configure MCP Server for VS Code (Preview) Source: https://www.iplocate.io/docs/integrations/mcp-server This JSON configuration for VS Code (Preview), typically placed in `.vscode/mcp.json`, enables the IPLocate MCP server. It defines the server type, command, arguments for installation, and environment variables including the API key. ```json { "servers": { "iplocate": { "type": "stdio", "command": "npx", "args": ["-y", "@iplocate/mcp-server"], "env": { "IPLOCATE_API_KEY": "your_api_key_here" } } } } ``` -------------------------------- ### Lookup IP Address with API Key as Query Parameter Source: https://www.iplocate.io/docs/getting-started/authentication This example demonstrates how to perform an IP address lookup by including your API key in the 'apikey' query parameter. ```APIDOC ## GET /api/lookup/{ip_address} ### Description Performs an IP address lookup. ### Method GET ### Endpoint `/api/lookup/{ip_address}` ### Parameters #### Query Parameters - **apikey** (string) - Required - Your unique API key. #### Path Parameters - **ip_address** (string) - Required - The IP address to look up. ### Request Example ```bash curl "https://iplocate.io/api/lookup/8.8.8.8?apikey=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **ip** (string) - The IP address. - **city** (string) - The city of the IP address. - **state** (string) - The state or region of the IP address. - **post_code** (string) - The postal code of the IP address. - **country** (string) - The country of the IP address. - **country_code** (string) - The country code of the IP address. - **continent** (string) - The continent of the IP address. - **latitude** (number) - The latitude coordinate of the IP address. - **longitude** (number) - The longitude coordinate of the IP address. - **timezone** (string) - The timezone of the IP address. - **asn** (string) - The Autonomous System Number (ASN) associated with the IP address. - **asn_description** (string) - The description of the ASN. #### Response Example ```json { "ip": "8.8.8.8", "city": "Mountain View", "state": "California", "post_code": "94043", "country": "United States", "country_code": "US", "continent": "North America", "latitude": 37.4056, "longitude": -122.0775, "timezone": "America/Los_Angeles", "asn": "AS15169", "asn_description": "Google LLC" } ``` ``` -------------------------------- ### Use PHP IPLocate Client Source: https://www.iplocate.io/docs/integrations/client-libraries Provides an example of using the PHP IPLocate client to fetch and display IP address details, including the IP and country. An API key is necessary for this operation. ```php lookup('8.8.8.8'); echo "IP: {$result->ip}\n"; echo "Country: {$result->country}\n"; ``` -------------------------------- ### Configure MCP Server for Claude Desktop Source: https://www.iplocate.io/docs/integrations/mcp-server This JSON configuration snippet is used in Claude Desktop's Developer settings to connect to the IPLocate MCP server. It specifies the command to run, arguments for installation, and environment variables, including the API key. ```json { "mcpServers": { "iplocate": { "command": "npx", "args": ["-y", "@iplocate/mcp-server"], "env": { "IPLOCATE_API_KEY": "your_api_key_here" } } } } ``` -------------------------------- ### IPv4 and IPv6 API Lookup Examples Source: https://www.iplocate.io/docs/reference/ipv4-ipv6 Demonstrates how to perform lookups for both IPv4 and IPv6 addresses using the IPLocate API with curl. Requires an API key for authentication. Handles connections from both IPv4 and IPv6 callers. ```bash # IPv4 lookup curl "https://iplocate.io/api/lookup/8.8.8.8?apikey=YOUR_API_KEY" ``` ```bash # IPv6 lookup curl "https://iplocate.io/api/lookup/2001:4860:4860::8888?apikey=YOUR_API_KEY" ``` -------------------------------- ### Untitled No description -------------------------------- ### IPv4 API Response Example Source: https://www.iplocate.io/docs/reference/ipv4-ipv6 Illustrates a typical JSON response from the IPLocate API when a lookup is performed for an IPv4 address. Includes details like the IP address, country, and country code. ```json { "ip": "8.8.8.8", "country": "United States", "country_code": "US", "is_eu": false } ``` -------------------------------- ### Example: Check IP Security Posture using MCP Source: https://www.iplocate.io/docs/integrations/mcp-server This JSON object demonstrates a request to the IPLocate MCP server to check the IP security posture. It specifies the tool `lookup_ip_address_privacy` and the target IP address as a parameter. ```json { "tool": "lookup_ip_address_privacy", "params": {"ip": "8.8.8.8"} } ``` -------------------------------- ### Untitled No description -------------------------------- ### IPv6 API Response Example Source: https://www.iplocate.io/docs/reference/ipv4-ipv6 Presents a sample JSON response from the IPLocate API for an IPv6 address lookup. The structure is consistent with IPv4 responses, providing geolocation data for the given IPv6 address. ```json { "ip": "2001:4860:4860::8888", "country": "United States", "country_code": "US", "is_eu": false } ``` -------------------------------- ### IP Address Batch Processing Example Source: https://www.iplocate.io/docs/reference/ipv4-ipv6 Shows how to send a batch request to the IPLocate API containing a mix of IPv4 and IPv6 addresses. This allows for efficient processing of multiple lookups in a single API call. ```json [ "8.8.8.8", "2001:4860:4860::8888", "1.1.1.1" ] ``` -------------------------------- ### Example Hosting Data Response Source: https://www.iplocate.io/docs/ip-intelligence-api/data-types This JSON object illustrates the 'hosting' data provided by the API. It contains details about the hosting provider, including its domain, network range, region, and the specific service the IP address is used for. This object is only present if detailed hosting information is available. ```json { "hosting": { "provider": "Amazon AWS", "domain": "aws.amazon.com", "network": "3.5.140.0/22", "region": "ap-northeast-2", "service": "EC2" } } ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Use Go IPLocate Client Source: https://www.iplocate.io/docs/integrations/client-libraries Shows how to create a new IPLocate client in Go, authenticate with an API key, perform an IP lookup, and handle potential errors. The result is then printed. ```go package main import ( "fmt" "log" "github.com/iplocate/go-iplocate" ) func main() { client := iplocate.NewClient(nil).WithAPIKey("YOUR_API_KEY") result, err := client.Lookup("8.8.8.8") if err != nil { log.Fatal(err) } fmt.Println(result) } ``` -------------------------------- ### Untitled No description -------------------------------- ### GET /json - Get Current IP Address (JSON) Source: https://www.iplocate.io/docs/ip-intelligence-api/get-current-ip-free-api Retrieves the current IP address of the requester in JSON format. This endpoint is free, unlimited, and requires no API key. ```APIDOC ## GET /json ### Description Retrieves the current IP address of the requester in JSON format. This endpoint is free, unlimited, and requires no API key. ### Method GET ### Endpoint https://api.iplocate.io/json ### Parameters None ### Request Example ```bash curl https://api.iplocate.io/json ``` ### Response #### Success Response (200) - **ip** (string) - The public IP address of the client. #### Response Example ```json { "ip": "123.243.56.78" } ``` ``` -------------------------------- ### Untitled No description -------------------------------- ### GET / - Get Current IP Address (Plain Text) Source: https://www.iplocate.io/docs/ip-intelligence-api/get-current-ip-free-api Retrieves the current IP address of the requester in plain text format. This endpoint is free, unlimited, and requires no API key. ```APIDOC ## GET / ### Description Retrieves the current IP address of the requester in plain text format. This endpoint is free, unlimited, and requires no API key. ### Method GET ### Endpoint https://api.iplocate.io/ ### Parameters None ### Request Example ```bash curl https://api.iplocate.io/ ``` ### Response #### Success Response (200) - **ip_address** (string) - The public IP address of the client. #### Response Example ``` 123.243.56.78 ``` ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Get IP Address (Plain Text) Source: https://www.iplocate.io/docs/ip-intelligence-api/get-current-ip-free-api This snippet demonstrates how to fetch the current IP address in plain text format using a simple GET request. It's useful for scripts or applications that only need the IP value without additional formatting. No API key or rate limiting is required. ```shell curl https://api.iplocate.io/ ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Common 404 Not Found Error Example Source: https://www.iplocate.io/docs/reference/api-errors An example of a JSON error response for a '404 Not Found' status. This usually means the requested IP address or entity could not be located by the API. ```json { "error": "Not found" } ``` -------------------------------- ### Common 401 Unauthorized Error Examples Source: https://www.iplocate.io/docs/reference/api-errors Shows examples of JSON error responses for '401 Unauthorized' errors. These indicate issues with API key authentication, such as a missing or invalid API key. ```json { "error": "Missing API key" } ``` ```json { "error": "Invalid API key" } ``` -------------------------------- ### Untitled No description