Skip to content
locate-me v0.1.0
Checking

ReferenceLookup

Lookup

Locates one IPv4 or IPv6 address: its network, continent, country, region, city and coordinates.

  • API key
  • 1 unit per request
GET/v1/lookup/{ip}
GET/v1/lookup/me

Request

ParameterInDescription
ippathAn IPv4 or IPv6 address, at most 45 characters. IPv4-mapped IPv6 (::ffff:1.2.3.4) is treated as IPv4, and percent-encoded colons are accepted. Zone IDs and leading zeros are rejected.
langqueryLanguage of place names: en (default), de, es, fr, ja, pt-BR, ru or zh-CN, case-insensitive. A name without a translation falls back to English.
X-API-KeyheaderYour key, or Authorization: Bearer <key>. See Authentication.
curl -H "X-API-Key: $LOCATE_ME_KEY" \
  "http://localhost:8080/v1/lookup/8.8.8.8?lang=de"

Response

200 OK // ?lang=de
{
  "ip": "8.8.8.8",
  "network": "8.8.8.0/24",
  "continent": { "code": "NA", "name": "Nordamerika" },
  "country": {
    "code": "US",
    "name": "Vereinigte Staaten von Amerika",
    "in_eu": false
  },
  "region": { "name": "California" },
  "city": "Mountain View",
  "location": { "latitude": 37.422, "longitude": -122.085 }
}

The region has no German name in the database, so it falls back to English. Fields without data are left out rather than sent as null. DB-IP City Lite, the default database, fills continent, country, region.name, city and location; other databases may add the fields marked optional.

FieldTypeDescription
ipstringThe address looked up, in canonical form (::ffff:8.8.8.8 becomes 8.8.8.8).
networkstringThe most specific network in the database that contains the address, as CIDR.
continent.codestringTwo-letter continent code: AF, AN, AS, EU, NA, OC or SA.
continent.namestringContinent name in the requested language.
country.codestringISO 3166-1 alpha-2 country code.
country.namestringCountry name in the requested language.
country.in_eubooleanWhether the country is a member state of the European Union.
region.codestringOptional. ISO 3166-2 subdivision code.
region.namestringFirst-level subdivision: state, province or region.
citystringCity name in the requested language.
postal_codestringOptional. Postal code.
location.latitudenumberDegrees north, WGS 84.
location.longitudenumberDegrees east, WGS 84.
location.accuracy_radius_kmnumberOptional. Radius around the coordinates that likely contains the address.
location.time_zonestringOptional. IANA time zone, such as Europe/Vienna.

Headers

HeaderDescription
RateLimit-LimitBurst capacity of your key. See Rate Limits.
RateLimit-RemainingUnits you can spend right now.
RateLimit-ResetSeconds until your key's bucket is full again.
X-Data-AttributionThe credit the database license requires, on successful lookups.

The Caller's Address

GET /v1/lookup/me locates the address the request comes from. It takes the same lang parameter, costs the same unit and returns the same response.

curl -H "X-API-Key: $LOCATE_ME_KEY" \
  http://localhost:8080/v1/lookup/me

The address is the TCP peer. When the peer is listed in server.trusted_proxies, it is the right-most X-Forwarded-For hop that is not itself a trusted proxy.

Requests from loopback or a private network get 404 reserved_address: those addresses never have a location. Call it from your users' side of the network, or pass their address to /v1/lookup/{ip}.

Errors

StatusCodeWhen
400invalid_ipThe path is not a valid address.
400invalid_langlang is not one of the eight languages.
401unauthorizedMissing, unknown or disabled key.
404not_foundThe database has no location for the address.
404reserved_addressA private, loopback, documentation or other reserved range.
429rate_limitedThe key's quota is spent; wait Retry-After seconds.
503database_unavailableNo database is loaded yet.
Esc