Reference

API

Plain text and JSON over HTTP or HTTPS. No key and no sign-up. Every endpoint answers GET requests and allows cross-origin requests from any site. Examples use addresses reserved for documentation.

curl ipchk.sh prints your address

Hosts

Every path works on all three hosts. Use 4. or 6. to check one protocol on purpose.

HostAnswers overTypical use
ipchk.shIPv4 or IPv6The address your system prefers, usually IPv6 when both work
4.ipchk.shIPv4 onlyYour IPv4 address, even on a dual-stack connection
6.ipchk.shIPv6 onlyYour IPv6 address, or a connection error without IPv6

Plain text

One line with a trailing newline, ready for scripts. N/A means there is no answer, such as an address without a PTR record.

EndpointReturnsExample
GET /Your address, for command-line clients203.0.113.42
GET /ipYour address203.0.113.42
GET /ptrReverse DNS for your addresshost-42.acme.example
GET /asnASN and network nameAS64496 · ACME - Acme, Inc, US

JSON

Served as application/json. /api/geo/ takes any public IPv4 or IPv6 address and is limited to 30 lookups per minute for each visitor.

EndpointReturns
GET /api/ip{"ip":"203.0.113.42"}
GET /api/ptr{"ptr":"host-42.acme.example"}
GET /api/asn{"asn":"AS64496 · ACME - Acme, Inc, US"}
GET /api/allAddress, reverse DNS, network and location in one response
GET /api/geoLocation for your address
GET /api/geo/{ip}Location for any public address
GET /health{"status":"ok","geo":"ready"}

Response fields

A full response from 4.ipchk.sh/api/all. The geo object is also what /api/geo returns.

200 · application/json
{
  "ip": "203.0.113.42",
  "ptr": "host-42.acme.example",
  "asn": "AS64496 · ACME - Acme, Inc, US",
  "geo": {
    "country": "United States",
    "country_code": "US",
    "continent": "North America",
    "continent_code": "NA",
    "city": "Los Angeles",
    "region": "California",
    "region_code": "CA",
    "postal": "90060",
    "latitude": 34.0544,
    "longitude": -118.244,
    "timezone": "America/Los_Angeles",
    "accuracy_km": 20,
    "asn_number": 64496,
    "org": "Acme, Inc"
  },
  "version": 4,
  "type": "public",
  "network": {
    "asn": 64496,
    "name": "Acme, Inc",
    "prefix": "203.0.113.0/24",
    "registry": "ARIN",
    "country": "US",
    "allocated": "2010-01-01"
  }
}
FieldMeaning
ipThe address that made the request
ptrReverse DNS name, or N/A
asnOrigin ASN and network name from Team Cymru
country_codeISO 3166-1 alpha-2 code
region_codeISO 3166-2 subdivision code
latitude, longitudeApproximate point, read with accuracy_km
accuracy_kmRadius of the estimate in kilometers
asn_number, orgNetwork from MaxMind GeoLite2 ASN
geo_errorSet instead of geo when location data is unavailable
version4 or 6
typepublic, or the kind of reserved address
networkASN, name, announced prefix, registry, registry country and allocation date

Errors

JSON endpoints answer errors with a status code and an error field.

StatusWhenBody
400The address in the path is not a valid IP address{"error":"invalid IP address"}
422The address is private or reserved, such as 192.168.1.10{"error":"private or reserved address","type":"private"}
429More than 30 lookups of other addresses in a minute{"error":"too many lookups","retry_after":2}
503Location data is loading or being updated{"error":"location data not ready"}

Embed widget

Add the script once, then place an element with one of the IDs below. The widget fills in the visitor's details as plain text, with no styling of its own.

HTML
<script src="https://ipchk.sh/widget.js"></script>
<p>Your IP address is <span id="ipchk-ip"></span></p>
Renders asYour IP address is 203.0.113.42
Element IDShows
ipchk-ipIPv4 address, or IPv6 when there is no IPv4
ipchk-ip4IPv4 address
ipchk-ip6IPv6 address
ipchk-ptr4Reverse DNS for the IPv4 address
ipchk-ptr6Reverse DNS for the IPv6 address
ipchk-asn4ASN for the IPv4 address
ipchk-asn6ASN for the IPv6 address