API Hub

Caller IP and User-Agent

GET /api/v1/ip/whoami

Returns the caller's IP address, its GeoIP location, and a breakdown of their User-Agent header. geo is null for a private IP (such as 127.0.0.1 in development), or if the GeoIP databases aren't installed, rather than the request failing. If you have both IPv4 and IPv6, you'll usually see your IPv6 address. To see your IPv4 address, send the request to https://ipv4.api-hub.samsmith.codes/api/v1/ip/whoami, which only has an IPv4 address. To see your IPv6 address, send it to https://ipv6.api-hub.samsmith.codes/api/v1/ip/whoami, which only has an IPv6 address.

Authentication: an API key with the ip scope. Get an API key

Location data from MaxMind GeoLite2

This product includes GeoLite2 data created by MaxMind, available from maxmind.com. Locations are approximate, and the databases are updated weekly. About the GeoLite2 databases

Rate limit

60 a minute

The default, for this endpoint

Monthly quota

10,000 a month

The default, shared by all endpoints

Your limits

Log in

To see yours →

Try it out

Your API key is hidden above. Copy command includes it.

Example response

{
    "ip": "203.0.113.42",
    "geo": {
        "ipAddress": "203.0.113.42",
        "continentCode": "EU",
        "continentName": "Europe",
        "countryCode": "GB",
        "countryName": "United Kingdom",
        "isInEuropeanUnion": false,
        "subdivisionCode": "ENG",
        "subdivisionName": "England",
        "cityName": "London",
        "postalCode": "EC1A",
        "latitude": 51.5164,
        "longitude": -0.093,
        "accuracyRadius": 20,
        "timeZone": "Europe/London",
        "asn": 64496,
        "asnOrganization": "Example Broadband Ltd"
    },
    "user_agent": {
        "raw": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36",
        "browser": "Chrome",
        "browser_version": "154.0.0.0",
        "platform": "Windows",
        "platform_version": "10.0",
        "device_type": "desktop",
        "is_mobile": false,
        "is_bot": false
    }
}

Response fields

ip string The caller's IP address.
geo object|null The same fields as the IP geolocation lookup, or null.
user_agent.raw string The unmodified User-Agent header.
user_agent.browser string Chrome, Firefox, Safari, Edge, Opera or Unknown.
user_agent.browser_version string|null Detected browser version, or null.
user_agent.platform string Windows, macOS, iOS, Android, Linux or Unknown.
user_agent.platform_version string|null Detected OS version, or null. On macOS this is usually 10.15.7 whatever the real version, because browsers freeze that token.
user_agent.device_type string desktop, mobile or tablet.
user_agent.is_mobile bool Whether the User-Agent looks like a mobile device.
user_agent.is_bot bool Whether the User-Agent looks like a bot, crawler or CLI tool.

Errors

  • 401 No API key was sent, or it's wrong, suspended, or belongs to a suspended account.
  • 403 The API key doesn't have the ip scope.
  • 429 Too many requests: to this endpoint this minute (the X-RateLimit-Limit header shows your limit), or this month across all endpoints, if your monthly quota is used up (X-Quota-Limit).
  • 503 The API is down for maintenance. The Retry-After header, if there is one, says how many seconds to wait before trying again.