IPGeolocation.io Java SDK for the IP Geolocation API

Overview

Maven Central Java 8+ Build Endpoints License API Docs Website

Overview

The official Java SDK for the IP Geolocation API. Use /v3/ipgeo and /v3/ipgeo-bulk to get IP geolocation, company and ASN data, timezone and network data, hostname and abuse details, browser and device details, and security signals from one API call. Security signals include VPN detection, proxy detection, threat score, Tor detection, attacker flags, and cloud or data center IP checks.

This SDK supports IPv4, IPv6, and domain lookups, typed Java response classes, raw JSON or XML output, and response metadata including credits charged and request duration.


Installation

Requires Java 8+ and Maven 3.8+.


1. Maven

<dependency>
  <groupId>io.ipgeolocation</groupId>
  <artifactId>ipgeolocation</artifactId>
  <version>3.0.1</version>
</dependency>

2. Gradle (Groovy)

dependencies {
  implementation 'io.ipgeolocation:ipgeolocation:3.0.1'
}

3. Gradle (Kotlin)

dependencies {
  implementation("io.ipgeolocation:ipgeolocation:3.0.1")
}

4. Build From Source

git clone https://github.com/IPGeolocation/ip-geolocation-api-java-sdk.git
cd ip-geolocation-api-java-sdk
mvn clean install

Quick Start

import io.ipgeolocation.sdk.ApiResponse;
import io.ipgeolocation.sdk.IpGeolocationClient;
import io.ipgeolocation.sdk.IpGeolocationClientConfig;
import io.ipgeolocation.sdk.LookupIpGeolocationRequest;
import io.ipgeolocation.sdk.model.IpGeolocationResponse;

IpGeolocationClientConfig config = IpGeolocationClientConfig.builder("YOUR_API_KEY").build();

try (IpGeolocationClient client = new IpGeolocationClient(config)) {
  ApiResponse<IpGeolocationResponse> result = client.lookupIpGeolocation(
      LookupIpGeolocationRequest.builder()
          .ip("8.8.8.8")
          .build());

  System.out.println("IP: " + result.data().ip());

  if (result.data().location() != null) {
    System.out.println("Country: " + result.data().location().countryName());
    System.out.println("City: " + result.data().location().city());
  }

  if (result.data().timeZone() != null) {
    System.out.println("Timezone: " + result.data().timeZone().name());
  }
}

At a Glance

ItemValue
SDK NameIPGeolocation.io Java SDK
API TypeIPGeolocation.io IP Geolocation API
Supported Endpoints/v3/ipgeo, /v3/ipgeo-bulk
Supported InputsIPv4, IPv6, domain
Main Data ReturnedGeolocation, company, ASN, timezone, security, abuse, hostname, user-agent, network, currency
PricingFree plan available; paid plans for higher limits and extra modules
AuthenticationAPI key, request origin allowlisting for /v3/ipgeo only
Response FormatsTyped JSON, raw JSON, raw XML
Bulk LimitUp to 50,000 IPs or domains per request
Java Requirement8+
API Version3.0

Official Release


Get Your API Key

To use the SDK, create or access your IPGeolocation.io account and copy an API key from your dashboard.

  1. Sign up: https://app.ipgeolocation.io/signup
  2. If you signed up with email, verify your email address when prompted.
  3. Sign in: https://app.ipgeolocation.io/login
  4. Open your dashboard: https://app.ipgeolocation.io/dashboard
  5. Copy an API key from the API Keys section
  6. Use that key in IpGeolocationClientConfig.builder("YOUR_API_KEY")

What You Can Get From One API Call

Data SetHow To Request ItCommon Use Cases
IP geolocationDefault responseIP geolocation lookup, localization, geo targeting
Company and ASNDefault responseASN lookup, ISP lookup, ownership enrichment, network analysis
TimezoneDefault responseLocal time lookup, scheduling, regional reporting
Network and currencyDefault responseRouting context, analytics, pricing workflows
Security and risk signalsinclude("security")VPN detection, proxy detection, fraud prevention, threat analysis
Abuse contact datainclude("abuse")Incident response, abuse handling, reporting
Hostname datainclude("hostname"), include("liveHostname"), include("hostnameFallbackLive")Reverse DNS lookup, infrastructure enrichment, hosting checks
User-agent datainclude("user_agent") with userAgent(...)Browser detection, device detection, traffic analysis
Geo accuracy and DMA datainclude("geo_accuracy"), include("dma_code")Local targeting, media market mapping, proximity analysis

Common Use Cases

  • VPN detection and proxy detection for login, signup, and payment screening
  • Threat score checks and IP risk signals for fraud prevention
  • ASN lookup, ISP lookup, and company enrichment for B2B traffic analysis
  • Browser, device, and operating system detection with include=user_agent
  • Abuse contact lookups for investigation and incident response
  • Hostname and reverse DNS enrichment for infrastructure visibility
  • Bulk IP enrichment for analytics pipelines, SIEM workflows, ad verification, and security operations

Security and Risk Signals

Request include("security") to receive the security object. This adds the signals most teams search for when they need VPN detection, proxy detection, threat score data, anonymous IP checks, or data center IP detection from the same API call.

Search Use CaseSDK Fields
VPN detectionisVpn(), vpnProviderNames(), vpnConfidenceScore(), vpnLastSeen()
Proxy detectionisProxy(), proxyProviderNames(), proxyConfidenceScore(), proxyLastSeen()
Residential proxy detectionisResidentialProxy()
Tor detectionisTor()
Anonymous IP detectionisAnonymous()
Threat score and risk scoringthreatScore()
Bot, spam, and attacker signalsisBot(), isSpam(), isKnownAttacker()
Relay detectionisRelay(), relayProviderName()
Cloud, hosting, or data center IP detectionisCloudProvider(), cloudProviderName()

Provider names, confidence scores, and last-seen dates are returned when the API has supporting evidence for the matched VPN, proxy, relay, or hosting signal.


Supported Endpoints

This SDK supports the IP Geolocation API endpoints below.

EndpointHTTP MethodSDK MethodsPrimary Use Case
/v3/ipgeoGETlookupIpGeolocation(...), lookupIpGeolocationRaw(...)Single IPv4, IPv6, or domain lookup
/v3/ipgeo-bulkPOSTbulkLookupIpGeolocation(...), bulkLookupIpGeolocationRaw(...)Bulk lookup for up to 50,000 IPs or domains

Authentication Modes

ModeSDK SetupTypical Use
API key query paramIpGeolocationClientConfig.builder("YOUR_API_KEY")Server-side API calls
Request origin allowlistingIpGeolocationClientConfig.builder()Single lookup with /v3/ipgeo on paid plans

Plan Features and Limits

Feature availability depends on your plan and request parameters. The table below matches the current live API behavior for /v3/ipgeo and /v3/ipgeo-bulk.

Features marked Paid only return 401 Unauthorized (UnauthorizedException) on free plans.

CapabilityFree PlanPaid Plan
IPv4 and IPv6 single lookupSupportedSupported
Domain lookupPaid onlySupported
Bulk endpoint /v3/ipgeo-bulkPaid onlySupported, but always requires an API key
.include("*")Accepted, returns the default response onlyAccepted, returns all available modules
include=security, abuse, hostname, liveHostname, hostnameFallbackLive, geo_accuracy, dma_code, user_agentPaid onlySupported
Non-English langPaid onlySupported
fields and excludesSupportedSupported

1. Free Plan Example

ApiResponse<IpGeolocationResponse> freeResponse = client.lookupIpGeolocation(
    LookupIpGeolocationRequest.builder()
        .ip("8.8.8.8")
        .include("*")
        .fields("location.country_name")
        .excludes("currency")
        .build());

2. Paid Plan Example

ApiResponse<IpGeolocationResponse> paidResponse = client.lookupIpGeolocation(
    LookupIpGeolocationRequest.builder()
        .ip("ipgeolocation.io")
        .lang(io.ipgeolocation.sdk.Language.DE)
        .include("security")
        .include("abuse")
        .include("user_agent")
        .include("hostnameFallbackLive")
        .build());

Client Configuration

Builder MethodTypeDefaultNotes
apiKey(String)Stringnull if omittedRequired unless using request origin allowlisting for /v3/ipgeo
baseUrl(String)Stringhttps://api.ipgeolocation.ioTrailing slash is trimmed
connectTimeout(Duration)Duration10sMust be greater than zero and less than or equal to readTimeout
readTimeout(Duration)Duration30sMust be greater than zero
import java.time.Duration;

IpGeolocationClientConfig config = IpGeolocationClientConfig.builder("YOUR_API_KEY")
    .baseUrl("https://api.ipgeolocation.io")
    .connectTimeout(Duration.ofSeconds(10))
    .readTimeout(Duration.ofSeconds(30))
    .build();

Available Methods


1. Single Lookup

MethodReturn TypeNotes
lookupIpGeolocation(request)ApiResponse<IpGeolocationResponse>Typed body plus metadata
lookupIpGeolocationRaw(request)ApiResponse<String>Raw JSON or XML plus metadata

2. Bulk Lookup

MethodReturn TypeNotes
bulkLookupIpGeolocation(request)ApiResponse<List<BulkLookupResult>>Typed bulk result plus metadata
bulkLookupIpGeolocationRaw(request)ApiResponse<String>Raw JSON or XML plus metadata

Request Options


1. Single Lookup Query Parameters

Builder MethodAPI ParamTypeDefaultNotes
ip(String)ipStringomittedIPv4, IPv6, or domain. Blank is treated as omitted and resolves to the caller IP.
lang(Language)langLanguageAPI default enNon-English requires a paid plan
include(String)includerepeatable StringnoneSent as comma-separated values
fields(String)fieldsrepeatable StringnoneSent as comma-separated values
excludes(String)excludesrepeatable StringnoneSent as comma-separated values
output(ResponseFormat)outputResponseFormatJSONTyped methods are JSON only. Raw methods support JSON and XML

Language values supported by .lang(...):

  • Language.EN for English
  • Language.DE for German
  • Language.RU for Russian
  • Language.JA for Japanese
  • Language.FR for French
  • Language.CN for Chinese Simplified
  • Language.ES for Spanish
  • Language.CS for Czech
  • Language.IT for Italian
  • Language.KO for Korean
  • Language.FA for Persian
  • Language.PT for Portuguese

Dot-separated field paths can be passed to .fields(...) and .excludes(...) to control which parts of the response are returned.

  • .fields(...) returns only the specified fields or objects.
  • .excludes(...) removes the specified fields or objects from the response.

2. include Supported Values

ValueAdds To ResponseExtra Credits
securitysecurity object with threat score, VPN detection, proxy detection, Tor detection, anonymous IP signals, residential proxy signals, bot and spam signals, attacker flags, relay detection, and cloud or hosting or data center IP identification+2
abuseabuse object+1
geo_accuracylocation.locality, location.accuracy_radius, location.confidence0
dma_codelocation.dma_code0
user_agentuser_agent object with browser, device, operating system, and engine details0
hostnamehostname via local source0
liveHostnamehostname via live DNS0
hostnameFallbackLivehostname with fallback strategy0
*All available modules for the plan+3

3. Single Lookup Header Parameters

Builder MethodAPI HeaderTypeDefaultNotes
userAgent(String)User-AgentStringomittedPer-request override for .include("user_agent") requests

4. Bulk Lookup Body, Query, and Header Parameters

Builder MethodAPI Field Or ParamTypeRequiredNotes
addIp(String)body ips[]StringYesAdds one IP or domain
ips(List<String>)body ips[]List<String>YesReplaces the current list
lang(Language)query langLanguageNoSame behavior as single lookup
include(String)query includerepeatable StringNoSent as comma-separated values
fields(String)query fieldsrepeatable StringNoSent as comma-separated values
excludes(String)query excludesrepeatable StringNoSent as comma-separated values
output(ResponseFormat)query outputResponseFormatNoTyped methods are JSON only. Raw methods support JSON and XML
userAgent(String)header User-AgentStringNoPer-request override for include=user_agent requests

Single Lookup Examples

All examples below assume the following client setup:

IpGeolocationClient client = new IpGeolocationClient(
    IpGeolocationClientConfig.builder("YOUR_API_KEY").build());

1. Full Enrichment Example

LookupIpGeolocationRequest request = LookupIpGeolocationRequest.builder()
    .ip("8.8.8.8")
    .include("security")
    .include("abuse")
    .include("user_agent")
    .userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9")
    .build();

ApiResponse<IpGeolocationResponse> response = client.lookupIpGeolocation(request);

System.out.println("IP: " + response.data().ip());
System.out.println("Country: " + response.data().location().countryName());
System.out.println("Timezone: " + response.data().timeZone().name());
System.out.println("Threat Score: " + response.data().security().threatScore());
System.out.println("VPN: " + response.data().security().isVpn());
System.out.println("Proxy: " + response.data().security().isProxy());
System.out.println("Browser: " + response.data().userAgent().name());
System.out.println("OS: " + response.data().userAgent().operatingSystem().name());
System.out.println("Credits: " + response.metadata().creditsCharged());

2. ip

LookupIpGeolocationRequest request = LookupIpGeolocationRequest.builder()
    .ip("2607:fb91:16c6:8860:e531:2d1d:4944:6c7c")
    .build();

ApiResponse<IpGeolocationResponse> response = client.lookupIpGeolocation(request);
System.out.println(response.data().ip());

3. lang

LookupIpGeolocationRequest request = LookupIpGeolocationRequest.builder()
    .ip("8.8.8.8")
    .lang(io.ipgeolocation.sdk.Language.DE)
    .build();

ApiResponse<IpGeolocationResponse> response = client.lookupIpGeolocation(request);
System.out.println(response.data().location().countryName());

4. include

LookupIpGeolocationRequest request = LookupIpGeolocationRequest.builder()
    .ip("8.8.8.8")
    .include("security")
    .include("abuse")
    .build();

ApiResponse<IpGeolocationResponse> response = client.lookupIpGeolocation(request);
System.out.println(response.data().security().threatScore());
System.out.println(response.data().security().isVpn());
System.out.println(response.data().security().isProxy());
System.out.println(response.data().abuse());

5. userAgent

LookupIpGeolocationRequest request = LookupIpGeolocationRequest.builder()
    .ip("91.128.103.196")
    .include("user_agent")
    .userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9")
    .build();

ApiResponse<IpGeolocationResponse> response = client.lookupIpGeolocation(request);
System.out.println(response.data().userAgent().name());
System.out.println(response.data().userAgent().operatingSystem().name());

6. fields

LookupIpGeolocationRequest request = LookupIpGeolocationRequest.builder()
    .ip("8.8.8.8")
    .fields("location.country_name")
    .fields("asn.organization")
    .build();

ApiResponse<IpGeolocationResponse> response = client.lookupIpGeolocation(request);

7. excludes

LookupIpGeolocationRequest request = LookupIpGeolocationRequest.builder()
    .ip("8.8.8.8")
    .excludes("currency")
    .excludes("time_zone")
    .build();

ApiResponse<IpGeolocationResponse> response = client.lookupIpGeolocation(request);

8. output

Typed methods are JSON only.

try {
  client.lookupIpGeolocation(
      LookupIpGeolocationRequest.builder()
          .ip("8.8.8.8")
          .output(ResponseFormat.XML)
          .build());
} catch (io.ipgeolocation.sdk.exceptions.ValidationException ex) {
  System.out.println(ex.getMessage());
}

Raw methods support XML and return raw response text:

ApiResponse<String> xml = client.lookupIpGeolocationRaw(
    LookupIpGeolocationRequest.builder()
        .ip("8.8.8.8")
        .output(ResponseFormat.XML)
        .build());

System.out.println(xml.data());

Raw JSON and XML Methods

Use raw methods when you want the server response body exactly as returned.

MethodOutput ParameterData() TypeResult
lookupIpGeolocation(...)omitted or ResponseFormat.JSONIpGeolocationResponseTyped parse
lookupIpGeolocation(...)ResponseFormat.XMLN/AValidationException
lookupIpGeolocationRaw(...)omitted or ResponseFormat.JSONStringRaw JSON
lookupIpGeolocationRaw(...)ResponseFormat.XMLStringRaw XML
bulkLookupIpGeolocation(...)omitted or ResponseFormat.JSONList<BulkLookupResult>Typed parse
bulkLookupIpGeolocation(...)ResponseFormat.XMLN/AValidationException
bulkLookupIpGeolocationRaw(...)omitted or ResponseFormat.JSONStringRaw JSON
bulkLookupIpGeolocationRaw(...)ResponseFormat.XMLStringRaw XML

1. Single Raw JSON Example

ApiResponse<String> rawJson = client.lookupIpGeolocationRaw(
    LookupIpGeolocationRequest.builder()
        .ip("8.8.8.8")
        .output(ResponseFormat.JSON)
        .build());

System.out.println(rawJson.data());
System.out.println(rawJson.metadata().statusCode());
System.out.println(rawJson.metadata().creditsCharged());

2. Single Raw XML Example

ApiResponse<String> rawXml = client.lookupIpGeolocationRaw(
    LookupIpGeolocationRequest.builder()
        .ip("8.8.8.8")
        .output(ResponseFormat.XML)
        .build());

System.out.println(rawXml.data());
System.out.println(rawXml.metadata().statusCode());
System.out.println(rawXml.metadata().firstHeaderValue("Content-Type"));

3. Bulk Raw JSON Example

ApiResponse<String> rawBulkJson = client.bulkLookupIpGeolocationRaw(
    BulkLookupIpGeolocationRequest.builder()
        .addIp("8.8.8.8")
        .addIp("1.1.1.1")
        .output(ResponseFormat.JSON)
        .build());

System.out.println(rawBulkJson.data());
System.out.println(rawBulkJson.metadata().creditsCharged());

4. Bulk Raw XML Example

ApiResponse<String> rawBulkXml = client.bulkLookupIpGeolocationRaw(
    BulkLookupIpGeolocationRequest.builder()
        .addIp("8.8.8.8")
        .addIp("invalid-ip")
        .output(ResponseFormat.XML)
        .build());

System.out.println(rawBulkXml.data());
System.out.println(rawBulkXml.metadata().statusCode());
System.out.println(rawBulkXml.metadata().rawHeaders());

Bulk Lookup Examples


1. Bulk With All Valid Inputs

import io.ipgeolocation.sdk.model.BulkLookupResult;
import java.util.List;

BulkLookupIpGeolocationRequest request = BulkLookupIpGeolocationRequest.builder()
    .addIp("8.8.8.8")
    .addIp("1.1.1.1")
    .build();

ApiResponse<List<BulkLookupResult>> response = client.bulkLookupIpGeolocation(request);
System.out.println("Count: " + response.data().size());
System.out.println("Credits: " + response.metadata().creditsCharged());

2. Bulk With Mixed Valid and Invalid Inputs

import io.ipgeolocation.sdk.model.BulkLookupError;
import io.ipgeolocation.sdk.model.BulkLookupResult;
import io.ipgeolocation.sdk.model.BulkLookupSuccess;
import java.util.List;

BulkLookupIpGeolocationRequest request = BulkLookupIpGeolocationRequest.builder()
    .addIp("8.8.8.8")
    .addIp("invalid-ip")
    .addIp("1.1.1.1")
    .build();

ApiResponse<List<BulkLookupResult>> results = client.bulkLookupIpGeolocation(request);

for (BulkLookupResult item : results.data()) {
  if (item instanceof BulkLookupSuccess) {
    BulkLookupSuccess success = (BulkLookupSuccess) item;
    System.out.println("OK: " + success.item().ip());
  } else if (item instanceof BulkLookupError) {
    BulkLookupError error = (BulkLookupError) item;
    System.out.println("ERR: " + error.message());
  }
}

Advanced Configuration


1. Response Metadata

All lookup methods return ApiResponse<T>.

ApiResponse<T> contains:

  • data()
  • metadata()

ApiResponseMetadata fields:

FieldTypeDescription
statusCodeintFinal HTTP response status
durationMslongTotal request duration
creditsChargedIntegerParsed from X-Credits-Charged when present
successfulRecordsIntegerParsed from X-Successful-Record for bulk responses
rawHeadersMap<String, List<String>>Immutable raw response header map

Header helper methods:

MethodReturn TypeDescription
headerValues("Header-Name")List<String>Case-insensitive header lookup for all values
firstHeaderValue("Header-Name")StringCase-insensitive header lookup for the first value
ApiResponse<IpGeolocationResponse> response = client.lookupIpGeolocation(
    LookupIpGeolocationRequest.builder().ip("8.8.8.8").build());

System.out.println("Status: " + response.metadata().statusCode());
System.out.println("Duration ms: " + response.metadata().durationMs());
System.out.println("Credits: " + response.metadata().creditsCharged());
System.out.println("Raw X-Credits-Charged: "
    + response.metadata().firstHeaderValue("X-Credits-Charged"));

The client always sends SDK-managed User-Agent and Accept headers. Bulk requests also send Content-Type: application/json.


2. JSON Output Modes

Use JsonOutput for logs or CLI output. By default, it omits null fields from the API response.

ModeBehavior
JsonOutputMode.COMPACTOmits null fields
JsonOutputMode.FULLIncludes null fields
import io.ipgeolocation.sdk.JsonOutput;
import io.ipgeolocation.sdk.JsonOutputMode;

String compact = JsonOutput.toPrettyJson(response.data());
String full = JsonOutput.toPrettyJson(response.data(), JsonOutputMode.FULL);

Error Handling

All SDK exceptions extend IpGeolocationException.

HTTP StatusException
400BadRequestException
401UnauthorizedException
404NotFoundException
405MethodNotAllowedException
413PayloadTooLargeException
415UnsupportedMediaTypeException
423LockedException
429RateLimitException
499ClientClosedRequestException
5xxServerErrorException
Other non-2xxApiException
import io.ipgeolocation.sdk.exceptions.RateLimitException;
import io.ipgeolocation.sdk.exceptions.UnauthorizedException;

try {
  client.lookupIpGeolocation(LookupIpGeolocationRequest.builder().build());
} catch (UnauthorizedException ex) {
  System.err.println("Unauthorized: " + ex.apiMessage());
} catch (RateLimitException ex) {
  System.err.println("Rate limit: " + ex.apiMessage());
}

Troubleshooting

SymptomLikely CauseWhat To Do
IllegalArgumentException: connectTimeout must be <= readTimeoutInvalid timeout relationSet connect timeout less than or equal to read timeout
ValidationException for XML with typed methodsTyped methods are JSON onlyUse lookupIpGeolocationRaw(...) or bulkLookupIpGeolocationRaw(...) for XML
ValidationException: bulk lookup requires apiKey in client configBulk client config has no API keyConfigure IpGeolocationClientConfig with an API key
ValidationException: ips must not be emptyBulk body has no entriesAdd at least one IP or domain
ValidationException: ips must contain at most 50000 entriesBulk request is too largeSplit the request into smaller chunks
UnauthorizedExceptionMissing or invalid key, or plan limitationVerify your key and requested features
RateLimitExceptionUsage or billing conditionReview account usage and plan status
LockedExceptionBogon IP address was queriedUse a valid public IP address
BadRequestExceptionProvided IP address is not validUse a valid public IP address

For the full list of API-side errors, see the IP Geolocation API error codes documentation.


FAQ

Yes. Use include("security") with /v3/ipgeo or /v3/ipgeo-bulk to receive the security object. That object can contain threat score, VPN detection, proxy detection, Tor detection, anonymous IP checks, residential proxy signals, bot and spam signals, known attacker signals, relay detection, and cloud or data center IP identification.
Yes. A single request can return geolocation, company, ASN, timezone, network, and currency data by default, and you can add more modules such as security, abuse, hostname, and user_agent with include(...).
Yes, but domain lookup requires a paid API plan. On free plans, the live API currently returns 401 Unauthorized for domain lookups.
Yes. Use /v3/ipgeo-bulk through bulkLookupIpGeolocation(...) or bulkLookupIpGeolocationRaw(...). Bulk requests support up to 50,000 IPs or domains per request and always require an API key.
Yes. Use lookupIpGeolocationRaw(...) or bulkLookupIpGeolocationRaw(...) with output(ResponseFormat.XML). Typed methods are JSON only.
Use include("user_agent") and set the request User-Agent header with .userAgent(...). The API can then return browser, device, operating system, and rendering engine details in the user_agent object.
On free plans, include("*") returns the default response. On paid plans, it returns all modules available to your plan for that request.
No. Request origin allowlisting works only for /v3/ipgeo on paid plans. /v3/ipgeo-bulk requires an API key.

Links

Subscribe to Our Newsletter

Get the latest in geolocation tech, straight to your inbox.