B4J Library IPLocator - get info on IP addresses

Attached is a small sample console application that uses a class called IPLocator to get a bunch of information (including geolocation info) on IP addresses. The IPLocator class also creates an SQLite database to store these results and prevent unnecessary API calls.

The IPLocator class can call APIs from either ip-api.com or freegeoip.net. I chose these two services because they are both free and don't require an API key. ip-api.com has a 250 request/second rate limit (~14k/hour) but doesn't seem to throttle on a per second basis. freegeoip.net has a 10k request/hour limit and does seem to throttle on a per second basis. ip-api.com has much more verbose and (probably) accurate info about IP addresses however it has restrictions on commercial usage. freegeoip.net doesn't have restrictions on commercial usage and they have a database you can download so you can run your own instance. Check out those sites for more info.

The IPLocator class was written in B4J but it can be easily adapted to run in B4A (and probably B4i). You have all the source code in the attached zip file.

The Main module requires CollectionsExtra. The IPLocator class requires Json, jSQL, jHTTP, jStringUtils, HttpJob and HttpUtils2Service. Those latter dependencies will change if you run the IPLocator class in a JavaFX program or an Android app.
 

Attachments

  • IPLocator.zip
    30.3 KB · Views: 640
Last edited:

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi,

Dim requestQueue As LinkedList Where to get "LinkedList" ?
 
Top