DEV Community

2x lazymac
2x lazymac

Posted on • Originally published at api.lazy-mac.com

How to Use the IP Geolocation API — Free REST + MCP Server

Need to know where a user is connecting from? This API returns country, city, region, timezone, ISP, and coordinates for any IP address. One GET request, JSON response, no signup.

Try It Right Now

Get your own IP location:

curl -s https://api.lazy-mac.com/ip-geo/api/v1/me | jq
Enter fullscreen mode Exit fullscreen mode

Response:

{
  "ip": "203.0.113.42",
  "country": "United States",
  "countryCode": "US",
  "region": "California",
  "city": "San Francisco",
  "zip": "94102",
  "lat": 37.7749,
  "lon": -122.4194,
  "timezone": "America/Los_Angeles",
  "isp": "Cloudflare Inc",
  "org": "Cloudflare"
}
Enter fullscreen mode Exit fullscreen mode

Look Up Any IP

curl -s https://api.lazy-mac.com/ip-geo/api/v1/lookup/8.8.8.8 | jq
Enter fullscreen mode Exit fullscreen mode

All Endpoints

Endpoint Description
GET /api/v1/lookup/:ip Look up any IP address
GET /api/v1/me Get caller's IP location
POST /api/v1/batch Look up multiple IPs at once
GET /api/v1/validate/:ip Check if IP is valid

Batch Lookup

curl -s -X POST https://api.lazy-mac.com/ip-geo/api/v1/batch \
  -H "Content-Type: application/json" \
  -d '{"ips": ["8.8.8.8", "1.1.1.1", "208.67.222.222"]}' | jq
Enter fullscreen mode Exit fullscreen mode

Use as an MCP Server

{
  "mcpServers": {
    "ip-geo": {
      "url": "https://api.lazy-mac.com/ip-geo/mcp"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Ask Claude: "Where is IP 8.8.8.8 located?"

Express.js Middleware Example

app.use(async (req, res, next) => {
  const ip = req.headers["x-forwarded-for"] || req.ip;
  const geo = await fetch(
    `https://api.lazy-mac.com/ip-geo/api/v1/lookup/${ip}`
  ).then(r => r.json());
  req.geo = geo;
  next();
});
Enter fullscreen mode Exit fullscreen mode

Pricing

Tier Requests/mo Price
Free 100 $0
Pro 10,000 $9/mo
Business Unlimited $49/mo

Get Pro Access on Gumroad →


Browse all 22 APIs at api.lazy-mac.com →

More from the lazymac API Toolkit:

Top comments (0)