Skip to main content

Lookup IP Address

Enterprise

This endpoint is part of Countly Enterprise. To get access, contact sales or compare versions. Existing customers can reach the support portal with questions.

Endpoint

/o?method=lookup

Overview

Looks up location data for an IP address using geoip-lite.

Authentication

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions

  • Required permission: Read on the geo feature

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or auth_token)API key authentication
auth_tokenStringYes (or api_key)Auth token authentication
app_idStringYesApplication context for permission validation
ip_addressStringNoIP address to lookup; when omitted, request IP is used

Examples

Example 1: Lookup a Specific IP

https://your-server.com/o?method=lookup&api_key=YOUR_API_KEY&app_id=609bd78d90d7a416d4dfb984&ip_address=8.8.8.8

Example 2: Lookup Request IP

https://your-server.com/o?method=lookup&api_key=YOUR_API_KEY&app_id=609bd78d90d7a416d4dfb984

Response

Success Response

{
"location": {
"country": "US",
"region": "CA",
"city": "San Francisco",
"ll": [37.7749, -122.4194]
}
}

Response Fields

FieldTypeDescription
locationObject or nullGeoIP lookup result for the provided/request IP
location.countryStringCountry code (when available)
location.regionStringRegion code (when available)
location.cityStringCity name (when available)
location.llArray[latitude, longitude] coordinates

Error Responses

HTTP StatusResponse
400Validation/auth error from (for example missing required params)

Behavior

  1. Resolves IP from ip_address or falls back to request IP.
  2. Performs lookup with geoip-lite.
  3. Returns result as { "location": ... }.
Implementation details

Database Collections

This endpoint does not read or write database collections.