← ifconfig.rs

API reference

How to talk to ifconfig.rs from scripts, services, and CLIs.

Overview #

ifconfig.rs serves the visitor's own public IP plus optional geolocation and network enrichment data. The same payload is exposed in three flavors – text/plain, application/json, application/xml – over plain HTTP GET.

The machine-readable OpenAPI 3 spec lives at /api/openapi.json.

Endpoints #

PathContent typeNotes
GET /text/plain · text/htmlContent-negotiates by User-Agent. curl, wget, httpie get plain IP; browsers get the landing page.
GET /plaintext/plainAlways plain text. Best IP (IPv4 preferred) followed by a newline.
GET /jsonapplication/jsonFull payload. Optional ?ip=<addr> looks up an arbitrary IPv4 / IPv6 literal instead of the caller's own address (try it in the browser).
GET /xmlapplication/xmlSame payload as /json, formatted as XML. Optional ?ip=<addr> looks up an arbitrary IPv4 / IPv6 literal instead of the caller's own address.

Family-specific hosts #

The bare ifconfig.rs is dual-stack (it has both A and AAAA records). To force a single family at the transport layer, use the family-specific subdomains – they expose the same endpoints but resolve to one address family only:

HostDNSWhat you get
v4.ifconfig.rsA onlyConnection is forced over IPv4; the returned query is your IPv4.
v6.ifconfig.rsAAAA onlyConnection is forced over IPv6; the returned query is your IPv6.

Examples #

Quick CLI invocations:

$ curl ifconfig.rs
$ curl ifconfig.rs/plain
$ curl ifconfig.rs/json
$ curl v4.ifconfig.rs/plain
$ curl v6.ifconfig.rs/plain
$ curl ifconfig.rs/json?ip=1.1.1.1
$ curl ifconfig.rs/json?ip=2606:4700:4700::1111
$ curl ifconfig.rs/xml
$ curl ifconfig.rs/xml?ip=1.1.1.1

Look-up mode #

When ?ip= is set, /json and /xml both run the supplied IPv4 or IPv6 literal through the same enrichment pipeline used for the caller's own address. Every response carries a status envelope: success when the address is publicly routable, fail when it is not (with a message explaining why – invalid query, private range, reserved range, or not in database). The supplied input is echoed back as query (absent when the input was empty or whitespace-only).

Sample JSON response (successful lookup):

{
    "status": "success",
    "query": "203.0.113.42",
    "continent": "Europe",
    "continentCode": "EU",
    "country": "Serbia",
    "countryCode": "RS",
    "region": "VO",
    "regionName": "Vojvodina",
    "city": "Novi Sad",
    "zip": "21000",
    "lat": 45.2671,
    "lon": 19.8335,
    "timezone": "Europe/Belgrade",
    "offset": 7200,
    "currency": "RSD",
    "isp": "Telekom Srbija",
    "org": "Telekom Srbija a.d.",
    "as": "AS8400 TELEKOM SRBIJA a.d.",
    "asname": "TELEKOM-AS",
    "reverse": "static-203-0-113-42.telekom.rs",
    "mobile": false,
    "proxy": false,
    "hosting": false
}

Sample JSON response (failed lookup – private address):

{
    "status": "fail",
    "message": "private range",
    "query": "10.0.0.1"
}

Sample XML response:

<?xml version="1.0" encoding="UTF-8"?>
<Info>
    <status>success</status>
    <query>203.0.113.42</query>
    <continent>Europe</continent>
    <continentCode>EU</continentCode>
    <country>Serbia</country>
    <countryCode>RS</countryCode>
    <region>VO</region>
    <regionName>Vojvodina</regionName>
    <city>Novi Sad</city>
    <zip>21000</zip>
    <lat>45.2671</lat>
    <lon>19.8335</lon>
    <timezone>Europe/Belgrade</timezone>
    <offset>7200</offset>
    <currency>RSD</currency>
    <isp>Telekom Srbija</isp>
    <org>Telekom Srbija a.d.</org>
    <as>AS8400 TELEKOM SRBIJA a.d.</as>
    <asname>TELEKOM-AS</asname>
    <reverse>static-203-0-113-42.telekom.rs</reverse>
    <mobile>false</mobile>
    <proxy>false</proxy>
    <hosting>false</hosting>
</Info>

Response shape #

All /json and /xml responses are a single flat key-value object – every field at the top level, no nested wrappers. Missing fields are omitted from the response.

Tick the boxes to build the corresponding ?fields= URL. With every box checked, the URL is the bare endpoint (no filter); unticking any field switches to an explicit whitelist. Two equivalent forms are shown: a comma-separated list and a numeric bitmask – each field's bit value (1, 2, 4, 8, …) is published at /api/fields, OR them together to build the integer. The numeric form is just shorter on the wire.

$ curl
$ curl
FieldDescriptionExampleType
statusLookup outcome – success when the IP is publicly routable, fail otherwise.successstring
messageReason when status=fail: one of invalid query, private range, reserved range, not in database (valid public address we have no data for). Absent on success.private rangestring
queryEcho of the input: the caller's IP in client mode, the ?ip= value in lookup mode, the per-item address in batch mode.203.0.113.42string
continentContinent name.Europestring
continentCodeTwo-letter continent code.EUstring
countryCountry name.Serbiastring
countryCodeTwo-letter country code (ISO 3166-1 alpha-2).RSstring
regionRegion / state short code (FIPS or ISO).VOstring
regionNameRegion / state full name.Vojvodinastring
cityCity name.Novi Sadstring
districtDistrict (subdivision of a city). Not available for every address.Limanstring
zipPostal / ZIP code.21000string
latLatitude.45.2671float
lonLongitude.19.8335float
timezoneTimezone identifier (tz database).Europe/Belgradestring
offsetTimezone UTC offset, in seconds (includes DST).7200int
currencyNational currency code.RSDstring
ispISP name.Telekom Srbijastring
orgOrganization name (may differ from ISP).Telekom Srbija a.d.string
asAS number and organization, separated by space (RIR). Empty for IP blocks not announced in BGP.AS8400 TELEKOM SRBIJA a.d.string
asnameAS name (RIR).TELEKOM-ASstring
reverseReverse DNS (PTR) of the IP.static-203-0-113-42.telekom.rsstring
mobileMobile (cellular) connection.falsebool
proxyProxy, VPN, or Tor exit address.falsebool
hostingHosting / co-located / data-center IP.falsebool
disputedNeutrality marker. Present and true only when the country lies in an internationally contested territory (e.g., Crimea, Western Sahara, Kosovo). The country is our geolocation provider's attribution, not a position of ifconfig.rs. Absent otherwise.truebool

Not every field is available for every address. When data is missing, it is dropped from the response – clients should treat the absence of a key as "unknown", not as an empty string or zero.

Authentication (API keys) #

Anonymous use is free and unauthenticated. For higher rate limits, contact us to be provisioned an API key. Once issued, you have two equivalent ways to send it:

  • Header (preferred): Authorization: Bearer YOUR_KEY
  • Query param: ?api_key=YOUR_KEY

If both are present, the header wins. A key may be restricted to a list of source IP ranges; calls from outside the allowlist are rejected with 403.

$ curl -H "Authorization: Bearer YOUR_API_KEY" ifconfig.rs/json
$ curl "ifconfig.rs/json?api_key=YOUR_API_KEY"

Rate limiting #

Two layers run in parallel:

  • Per-IP – anonymous traffic is limited to 60 requests per minute per source IP.
  • Per-key – authenticated traffic uses the key's own per-minute and per-day quotas.

When a key is presented, the per-key limiter takes over for that request; the per-IP limit is not also counted.

Every IP-limited response carries the current budget in its headers (X-RateLimit-* convention popularized by GitHub / Twitter / Stripe):

  • X-RateLimit-Limit – the ceiling for the window (always 60 on the per-IP path).
  • X-RateLimit-Remaining – requests left in the current 60-second window (zero once the window is exhausted).
  • X-RateLimit-Reset – seconds until the window resets and the budget refills.

When the budget is exhausted the server returns 429 Too Many Requests and adds Retry-After with the same seconds-until-reset value. A well-behaved client reads X-RateLimit-Remaining and stops sending when it reaches 0 rather than hammering until it sees a 429. The headers are not emitted on the per-key path – authenticated callers track their quotas against the budget published in the key contract.

Batch endpoint #

POST /batch resolves up to 100 addresses in a single call. API key required – anonymous callers receive 401 (there is no per-IP path for batch).

Body is a JSON array of items; each carries the address to look up and an optional per-item fields whitelist (same syntax as ?fields= on /json). The response is a JSON array of the same length, in the same order, each entry being a flat FlatInfo object. The mapping is positional and guaranteed: the i-th result is the answer for the i-th input item (never reordered or deduplicated). Each entry also echoes its query, so you can match by index or by value.

Quota cost equals the number of items: a batch of 100 against a 60/min key returns 429 for the whole call (no partial consumption).

$ curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
       -H "Content-Type: application/json" \
       -d '[
             {"query": "8.8.8.8"},
             {"query": "1.1.1.1", "fields": "country,city,isp"},
             {"query": "10.0.0.1"}
           ]' \
       ifconfig.rs/batch
[
    { "status": "success", "query": "8.8.8.8",  "country": "United States", "city": "Mountain View", "isp": "Google LLC", ... },
    { "status": "success", "query": "1.1.1.1",  "country": "Australia",     "city": "South Brisbane", "isp": "Cloudflare, Inc." },
    { "status": "fail",    "message": "private range", "query": "10.0.0.1" }
]

HTTP status codes #

CodeMeaning
200Success.
400 Bad RequestUnknown name in ?fields=, all-empty ?fields=, malformed /batch body, empty batch, or batch larger than 100 items.
401 UnauthorizedAn Authorization: Bearer header or ?api_key= was supplied but the key is unknown / revoked. Also returned by /batch when no key is sent at all.
403 ForbiddenKey is valid, but the source IP is outside its allowlist.
429 Too Many RequestsPer-IP, per-minute, or per-day quota exhausted. Retry after the window resets.
503 Service Unavailable/batch only – no API keys are configured server-side, so the endpoint is disabled.

Java client #

An official Java client is published to Maven Central – a thin wrapper over the JDK HttpClient with Jackson, no other HTTP dependency. Requires JDK 21+. Source: github.com/adsdevdoo/ifconfig-java.

<dependency>
    <groupId>rs.adsdev</groupId>
    <artifactId>ifconfig-java</artifactId>
    <version>1.0.1</version>
</dependency>
IfconfigClient client = IfconfigClient.builder()
        .apiKey("alpha-prod-secret-xxx") // required only for /batch
        .build();

IpInfo me = client.myIp();                    // GET /json
IpInfo ip = client.lookup("8.8.8.8");         // GET /json?ip=8.8.8.8
IpInfo c  = client.lookup("8.8.8.8",          // GET /json?ip=8.8.8.8&fields=country,city
        EnumSet.of(Field.COUNTRY, Field.CITY));

List<IpInfo> hits = client.batch(List.of(     // POST /batch
        new BatchQuery("1.1.1.1"),
        new BatchQuery("8.8.8.8")));

Non-2xx responses surface as IfconfigException, which carries the HTTP status code and the raw body so callers can branch on rate-limit (429), bad request (400), etc.

Stability #

The fields documented here are stable. We may add new optional fields without notice; we will not remove or rename existing ones without a deprecation note posted on this page first.

Contact #

For API keys, abuse reports, or integration help, reach us at .