@@ -84,7 +84,7 @@ IPGeolocationAPI api = new IPGeolocationAPI("YOUR_API_KEY");
8484### Geolocation Lookup
8585
8686``` java
87- // Query geolocation for IP address (1.1.1.1) and fields (geo, time_zone and currency)
87+ // Get geolocation for IP address (1.1.1.1) and fields (geo, time_zone and currency)
8888GeolocationParams geoParams = new GeolocationParams ();
8989geoParams. setIPAddress(" 1.1.1.1" );
9090geoParams. setFields(" geo,time_zone,currency" );
@@ -100,37 +100,40 @@ if(geolocation.getStatus() == 200) {
100100 System . out. printf(" Status Code: %d, Message: %s\n " , geolocation. getStatus(), geolocation. getMessage());
101101}
102102
103- // Query geolocation for IP address (1.1.1.1) and all fields
103+ // Get geolocation in Russian** for IP address (1.1.1.1) and all fields
104104GeolocationParams geoParams = new GeolocationParams ();
105105geoParams. setIPAddress(" 1.1.1.1" );
106+ geoParams. setLang(" ru" );
106107
107108Geolocation geolocation = api. getGeolocation(geoParams);
108109
110+ // Check if geolocation lookup was successful
109111if (geolocation. getStatus() == 200 ) {
110112 System . out. println(geolocation. getIPAddress());
111113 System . out. println(geolocation. getCountryName());
112114} else {
113- System . out. printf(" Status Code: %d, Message: %s\n " , geolocation. getStatus(), geolocation. getMessage());
115+ System . out. printf(" Status Code: %d, Message: %s\n " , geolocation. getStatus(), geolocation. getMessage());
114116}
115117
116- // Query geolocation for the calling machine's IP address for all fields
118+ // Get geolocation for the calling machine's IP address for all fields
117119Geolocation geolocation = api. getGeolocation();
118120
119121if (geolocation. getStatus() == 200 ) {
120122 System . out. println(geolocation. getCountryCode2());
121123 System . out. println(geolocation. getTimezone(). getCurrentTime());
122124} else {
123- System . out. printf(" Status Code: %d, Message: %s\n " , geolocation. getStatus(), geolocation. getMessage());
125+ System . out. printf(" Status Code: %d, Message: %s\n " , geolocation. getStatus(), geolocation. getMessage());
124126}
125127```
126128
127129### Bulk Geolocations Lookup
128130
129131``` java
130- // Query geolocations for multiple IP addresses and all fields
131- String [] ips = new String [] {" 1.1.1.1" , " 2.2.2.2" , " 3.3.3.3" };
132+ // Query geolocation in German** for multiple IP addresses and all fields
133+ String [] ips = new String []{" 1.1.1.1" , " 2.2.2.2" , " 3.3.3.3" };
132134GeolocationParams geoParams = new GeolocationParams ();
133135geoParams. setIPAddresses(ips);
136+ geoParams. setLang(" de" );
134137
135138List<Geolocation > geolocations = api. getBulkGeolocation(geoParams);
136139
@@ -140,7 +143,7 @@ System.out.println(geolocations.get(1).getLanguages());
140143System . out. println(geolocations. get(2 ). getTimezone(). getCurrentTime());
141144
142145// Query geolocations for multiple IP addresses but only geo field
143- String [] ips = new String [] {" 1.1.1.1" , " 2.2.2.2" , " 3.3.3.3" };
146+ String [] ips = new String []{" 1.1.1.1" , " 2.2.2.2" , " 3.3.3.3" };
144147GeolocationParams geoParams = new GeolocationParams ();
145148geoParams. setIPAddresses(ips);
146149geoParams. setFields(" geo" );
@@ -153,10 +156,10 @@ System.out.println(geolocations.get(1).getCountryName());
153156System . out. println(geolocations. get(2 ). getLatitude());
154157```
155158
156- ### Time Zone API
159+ ### Timezone API
157160
158161``` java
159- // Query time zone information by time zone ID
162+ // Get time zone information by time zone ID
160163TimezoneParams tzParams = new TimezoneParams ();
161164tzParams. setTimezone(" America/New_York" );
162165
@@ -166,10 +169,10 @@ if(tz.getStatus() == 200) {
166169 System . out. println(tz. getDateTimeWti());
167170 System . out. println(tz. getDateTimeTxt());
168171} else {
169- System . out. printf(" Status Code: %d, Message: %s\n " , geolocation. getStatus(), geolocation. getMessage());
172+ System . out. printf(" Status Code: %d, Message: %s\n " , geolocation. getStatus(), geolocation. getMessage());
170173}
171174
172- // Query time zone information by latitude and longitude of the location
175+ // Get time zone information by latitude and longitude of the location
173176TimezoneParams tzParams = new TimezoneParams ();
174177tzParams. setLocation(37.1838139 , - 123.8105225 );
175178
@@ -178,17 +181,18 @@ Timezone tz = api.getTimezone(tzParams);
178181if (tz. getStatus() == 200 ) {
179182 System . out. println(tz. getTimezone());
180183} else {
181- System . out. println(tz . getMessage());
184+ System . out. printf( " Status Code: %d, Message: %s \n " , geolocation . getStatus(), geolocation . getMessage());
182185}
183186
184- // Query time zone information for IP address (1.1.1.1)
187+ // Get time zone information for IP address (1.1.1.1) and geolocation information Japanese**
185188TimezoneParams tzParams = new TimezoneParams ();
186189tzParams. setIPAddress(" 1.1.1.1" );
190+ tzParams. setLang(" ja" );
187191
188192Timezone tz = api. getTimezone(tzParams);
189193
190194if (tz. getStatus() == 200 ) {
191- System . out. println(tz. toString ());
195+ System . out. println(tz. getTimezone ());
192196} else {
193197 System . out. printf(" Status Code: %d, Message: %s\n " , geolocation. getStatus(), geolocation. getMessage());
194198}
@@ -204,6 +208,19 @@ if(tz.getMessage()) {
204208}
205209```
206210
211+ ** IPGeolocation provides geolocation information in the following languages:
212+ * English (en)
213+ * German (de)
214+ * Russian (ru)
215+ * Japanese (ja)
216+ * French (fr)
217+ * Chinese Simplified (cn)
218+ * Spanish (es)
219+ * Czech (cs)
220+ * Italian (it)
221+
222+ By default, geolocation information is returned in English. Response in a language other than English is available to paid users only.
223+
207224## IP Geolocation API Java SDK Objects Reference
208225
209226IP Geolocation API Java SDK has following classes that you can use to fully leverage it.
0 commit comments