IP to Location Lookup

Powered by cdn.api1.in — Auto & Manual IP Detection

🚀 Key Features

Automatic IP Detection

Automatically detects visitor's IP and location on page load

Manual IP Lookup

Lookup any IP address with a simple function call

Rich Location Data

Get country, city, coordinates, ISP, timezone and more

Lightweight SDK

Just 3KB minified with zero dependencies

Enterprise Ready

99.9% uptime with rate limiting and caching

Secure API

HTTPS encryption and API key authentication

🔍 Live Demo

Waiting for input...

📦 SDK Integration

Add this script to your HTML (replace with your app_key):

<script src="https://cdn.api1.in/iptoaddress/sdk.js?app_key=YOUR_APP_KEY" defer></script>
Pro Tip: Use the defer attribute to load the script without blocking page rendering.

Basic Usage

Auto-detect visitor's location:

// Auto-detect current visitor's location
IPtoAddressSDK.getLocation()
  .then(data => {
    console.log('Location data:', data);
    // Example: { ip: '123.45.67.89', country: 'United States', ... }
  })
  .catch(error => {
    console.error('Error:', error.message);
  });

Lookup specific IP address:

// Manual IP lookup
IPtoAddressSDK.getLocation('8.8.8.8')
  .then(data => console.log(data))
  .catch(error => console.error(error));

📚 API Reference

SDK Methods

Method Description Parameters Returns
getLocation() Auto-detects visitor's IP and location None Promise<LocationData>
getLocation(ip) Looks up location for specific IP ip: String (IPv4 address) Promise<LocationData>
version Current SDK version None String

Location Data Structure

Field Type Description
ip String The IP address that was queried
country String Country name
countryCode String 2-letter country code (ISO 3166-1 alpha-2)
region String Region/state name
city String City name
latitude Number Decimal latitude
longitude Number Decimal longitude
timezone String IANA timezone (e.g. "America/New_York")
isp String Internet Service Provider name
asn String Autonomous System Number
organization String Organization name

📡 Direct API Access

Call our API endpoints directly using the app_key query parameter:

1. Auto-Detect Your Location

GET https://api1.in/ip-services/v1/api/location/where-i-am?app_key=YOUR_APP_KEY

JavaScript Fetch Example:

fetch('https://api1.in/ip-services/v1/api/location/where-i-am?app_key=f4d303b37ba344678ec22a29b2a5d267')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

2. Lookup Specific IP Address

GET https://api1.in/ip-services/v1/api/location?ip=8.8.8.8&app_key=YOUR_APP_KEY

JavaScript Fetch Example:

fetch('https://api1.in/ip-services/v1/api/location?ip=8.8.8.8&app_key=f4d303b37ba344678ec22a29b2a5d267')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
Important Security Note:

API Response Structure

{
  "ip": "8.8.8.8",
  "country": "United States",
  "countryCode": "US",
  "region": "California",
  "city": "Mountain View",
  "latitude": 37.4056,
  "longitude": -122.0775,
  "timezone": "America/Los_Angeles",
  "isp": "Google LLC",
  "asn": "AS15169",
  "organization": "Google"
}

Error Responses

Status Description Example Response
400 Invalid IP format {"error": "Invalid IP address"}
401 Invalid/missing app_key {"error": "Unauthorized"}
429 Rate limit exceeded {"error": "Too many requests"}
Usage Tips:

🛠 Best Practices

Performance Optimization

Error Handling

Security

❓ Frequently Asked Questions

How accurate is the location data?

Accuracy varies by IP and region. Typically:

Is there a rate limit?

Yes, the free tier allows 1,000 requests/day. Contact us for higher limits.

Can I use this in my mobile app?

Yes! The SDK works in web views, or you can call the API directly from native code.

How often is the IP database updated?

Our database is updated weekly with the latest IP allocations and locations.