Class IfconfigClient

java.lang.Object
rs.adsdev.ifconfig.client.IfconfigClient

public final class IfconfigClient extends Object
Client for the ifconfig.rs IP / geo lookup service. Thin wrapper over the JDK HttpClient: every method maps 1:1 to a server endpoint.

Build an instance via builder():


 IfconfigClient client = IfconfigClient.builder()
         .baseUrl("https://ifconfig.rs")
         .apiKey("secret")
         .build();
 IpInfo me = client.myIp();
 

The instance is thread-safe and reusable; reuse one per process rather than creating per request.

  • Method Details

    • builder

      public static IfconfigClient.Builder builder()
    • myIp

      @Nonnull public IpInfo myIp()
      GET /json — returns geo info for the caller's own IP.
    • lookup

      @Nonnull public IpInfo lookup(@Nonnull String ip)
      GET /json?ip=... — returns geo info for the supplied IPv4 / IPv6 literal.
    • lookup

      @Nonnull public IpInfo lookup(@Nonnull String ip, @Nonnull Collection<Field> fields)
      GET /json?ip=...&fields=... — restricts the response to the requested fields. Use this when you only care about a few keys (e.g., just country on login) and want to skip serializing the rest.
    • plain

      @Nonnull public String plain()
      GET /plain — returns the caller's own IP as plain text.
    • xml

      @Nonnull public String xml(@Nonnull String ip)
      GET /xml?ip=... — returns the raw XML payload for the supplied IP.
    • batch

      @Nonnull public List<IpInfo> batch(@Nonnull List<BatchQuery> items)
      POST /batch — looks up multiple addresses in a single round-trip. Requires an API key. The server caps the batch at 100 items per call.
    • fieldBits

      @Nonnull public Map<String,Integer> fieldBits()
      GET /api/fields — returns the canonical map of wire field name → ?fields=N bit position. Useful for cross-checking Field.bit() values against a particular server deployment.