Java wrapper for userinfo.io API.
Simply add this dependency to your pom.xml
:
<dependency>
<groupId>io.userinfo</groupId>
<artifactId>userinfo-java<artifactId>
<version>1.1.0</version>
</dependency>
You can also clone this github repository and launch mvn clean install
.
Get your user's info by calling:
String ipAddress = // your user's IP
Info info = UserInfo.getInfo(ipAddress);
System.out.println(info);
If a communication error with the API occurs or if the given IP address is malformed, the getInfo
method will throw a retofit.RetrofitError
.
The retrofit.RetrofitError
has a useful getResponse()
method that will give you access to the status code, the message returned by the server, etc.
DateTime getRequestDate()
: returns the request dateString getIpAddress()
: returns the IP addressPosition getPosition()
: returns the position of the userPlace getContinent()
: returns the place defining the continentPlace getCountry()
: returns the place defining the countryPlace getCity()
: returns the place defining the city
Double getLatitude()
: the latitudeDouble getLongitude()
: the longitudeDouble getAccuracy()
: the accuracy (in km)
String getName()
: the name of the placeString getCode()
: the international code of the place (for a city, it will be the postal code)
joda-time:joda-time:2.4
com.squareup.retrofit:retrofit:1.6.1
junit:junit:4.11
(tests only)
- v1.1.0
- The API url is now in https
- Sending a
X-Userinfo-Client-Id
header with the requests to identify the client
- v1.0.0
- Initial release