Skip to content

Commit a90eafe

Browse files
committed
Add documentation for Core and Plus bundles and resproxy
1 parent 9e49fa4 commit a90eafe

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,107 @@ public class Main {
135135
}
136136
```
137137

138+
##### Core API
139+
140+
The library also supports the [Core API](https://ipinfo.io/developers/data-types#core-data), which provides city-level geolocation with nested geo and AS objects. Authentication with your token is required.
141+
142+
```java
143+
import io.ipinfo.api.IPinfoCore;
144+
import io.ipinfo.api.errors.RateLimitedException;
145+
import io.ipinfo.api.model.IPResponseCore;
146+
147+
public class Main {
148+
public static void main(String... args) {
149+
IPinfoCore ipInfoCore = new IPinfoCore.Builder()
150+
.setToken("YOUR TOKEN")
151+
.build();
152+
153+
try {
154+
IPResponseCore response = ipInfoCore.lookupIP("8.8.8.8");
155+
156+
// Print out the IP
157+
System.out.println(response.getIp()); // 8.8.8.8
158+
159+
// Print out geo information
160+
System.out.println(response.getGeo().getCity()); // Mountain View
161+
System.out.println(response.getGeo().getCountry()); // United States
162+
163+
// Print out AS information
164+
System.out.println(response.getAs().getAsn()); // AS15169
165+
System.out.println(response.getAs().getName()); // Google LLC
166+
} catch (RateLimitedException ex) {
167+
// Handle rate limits here.
168+
}
169+
}
170+
}
171+
```
172+
173+
##### Plus API
174+
175+
The library also supports the [Plus API](https://ipinfo.io/developers/data-types#plus-data), which provides enhanced data including mobile carrier info and privacy detection. Authentication with your token is required.
176+
177+
```java
178+
import io.ipinfo.api.IPinfoPlus;
179+
import io.ipinfo.api.errors.RateLimitedException;
180+
import io.ipinfo.api.model.IPResponsePlus;
181+
182+
public class Main {
183+
public static void main(String... args) {
184+
IPinfoPlus ipInfoPlus = new IPinfoPlus.Builder()
185+
.setToken("YOUR TOKEN")
186+
.build();
187+
188+
try {
189+
IPResponsePlus response = ipInfoPlus.lookupIP("8.8.8.8");
190+
191+
// Print out the IP
192+
System.out.println(response.getIp()); // 8.8.8.8
193+
194+
// Print out geo information
195+
System.out.println(response.getGeo().getCity()); // Mountain View
196+
197+
// Print out mobile and anonymous info
198+
System.out.println(response.getMobile());
199+
System.out.println(response.getAnonymous().isProxy()); // false
200+
} catch (RateLimitedException ex) {
201+
// Handle rate limits here.
202+
}
203+
}
204+
}
205+
```
206+
207+
##### Residential Proxy API
208+
209+
The library also supports the [Residential Proxy API](https://ipinfo.io/developers/residential-proxy-api), which allows you to check if an IP address is a residential proxy. Authentication with your token is required.
210+
211+
```java
212+
import io.ipinfo.api.IPinfo;
213+
import io.ipinfo.api.errors.RateLimitedException;
214+
import io.ipinfo.api.model.ResproxyResponse;
215+
216+
public class Main {
217+
public static void main(String... args) {
218+
IPinfo ipInfo = new IPinfo.Builder()
219+
.setToken("YOUR TOKEN")
220+
.build();
221+
222+
try {
223+
ResproxyResponse response = ipInfo.lookupResproxy("175.107.211.204");
224+
225+
// Print out the IP
226+
System.out.println(response.getIp()); // 175.107.211.204
227+
228+
// Print out resproxy details
229+
System.out.println(response.getLastSeen()); // 2025-01-20
230+
System.out.println(response.getPercentDaysSeen()); // 0.85
231+
System.out.println(response.getService()); // Bright Data
232+
} catch (RateLimitedException ex) {
233+
// Handle rate limits here.
234+
}
235+
}
236+
}
237+
```
238+
138239
#### Caching
139240

140241
This library provides a very simple caching system accessible in `SimpleCache`.

0 commit comments

Comments
 (0)