Package rs.adsdev.ifconfig.client
Class IfconfigClient
java.lang.Object
rs.adsdev.ifconfig.client.IfconfigClient
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.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbatch(List<BatchQuery> items) POST /batch— looks up multiple addresses in a single round-trip.static IfconfigClient.Builderbuilder()GET /api/fields— returns the canonical map of wire field name →?fields=Nbit position.GET /json?ip=...— returns geo info for the supplied IPv4 / IPv6 literal.lookup(String ip, Collection<Field> fields) GET /json?ip=...&fields=...— restricts the response to the requested fields.myIp()GET /json— returns geo info for the caller's own IP.plain()GET /plain— returns the caller's own IP as plain text.GET /xml?ip=...— returns the raw XML payload for the supplied IP.
-
Method Details
-
builder
-
myIp
GET /json— returns geo info for the caller's own IP. -
lookup
GET /json?ip=...— returns geo info for the supplied IPv4 / IPv6 literal. -
lookup
GET /json?ip=...&fields=...— restricts the response to the requested fields. Use this when you only care about a few keys (e.g., justcountryon login) and want to skip serializing the rest. -
plain
GET /plain— returns the caller's own IP as plain text. -
xml
GET /xml?ip=...— returns the raw XML payload for the supplied IP. -
batch
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
GET /api/fields— returns the canonical map of wire field name →?fields=Nbit position. Useful for cross-checkingField.bit()values against a particular server deployment.
-