IPv4 lookup

Location, timezone and network details for an IPv4 address. Leave the address out to look up the caller.

GEThttps://api.mygeocode.com/v1/ipv4

Parameters

ParameterTypeDescription
ipoptionalstringDotted IPv4 address. Default: the address the request came from.
ipsoptionalstringComma-separated addresses, up to 100, for a batch. Returns results array in the same order. Each counts as one request.
langoptionalstringISO 639-1 code for country, region and city names. Default en.
keyoptionalstringAPI key, if not sent as a header.

Example

$ curl "https://api.mygeocode.com/v1/ipv4?ip=1.1.1.1"
// In a browser, with no ip parameter, this returns the visitor's own address
const geo = await (await fetch("https://api.mygeocode.com/v1/ipv4")).json();
console.log(geo.country_code, geo.timezone);
import requests

geo = requests.get("https://api.mygeocode.com/v1/ipv4", params={"ip": "1.1.1.1"}, timeout=5).json()
print(geo["country_code"], geo["org"], geo["is_datacenter"])
Response
{
  "status": "ok",
  "ip": "1.1.1.1",
  "version": 4,
  "country": "Australia",
  "country_code": "AU",
  "region": "Queensland",
  "region_code": "QLD",
  "city": "Brisbane",
  "postcode": "4000",
  "lat": -27.4679,
  "lon": 153.0281,
  "timezone": "Australia/Brisbane",
  "asn": 13335,
  "org": "Cloudflare, Inc.",
  "is_datacenter": true,
  "is_proxy": false,
  "is_private": false
}

Response fields

FieldTypeDescription
ipstringThe address looked up.
versionintegerAlways 4 on this endpoint.
country, country_codestringName in lang, and the upper-case ISO 3166-1 alpha-2 code.
region, region_codestringFirst-level division and its ISO 3166-2 suffix. Absent if unknown.
city, postcodestringBest estimate. Absent if unknown.
lat, lonnumberCentre of the most specific known area.
timezonestringIANA name.
asn, orginteger, stringAutonomous system number and the announcing organisation.
is_datacenterbooleanHosting or cloud range.
is_proxybooleanKnown VPN, Tor or public proxy exit.
is_privatebooleanRFC 1918, loopback, link-local or otherwise not publicly routed. When true, the location fields are absent.

Notes

Errors

400 invalid_request when ip is not a valid IPv4 address, or when an IPv6 address is sent to this endpoint (use /v1/ipv6), or when ips has more than 100 entries.