Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
DelphiRAD Studio

How To Add IP Address Intelligence Services To Your Apps

how-to-create-ip-intelligence-service-using-delphi-ipapi

Have you ever wanted your apps to have the power to examine an IP address and then find out everything you possibly could about it such as what time zone is local to the IP, what currency they use or what internet service provider is used? This capability is called IP address intelligence and it can add a powerfully rich package of knowledge to your applications allowing you to customize how you present information to your users. In this post you will be learn how to quickly and easily integrate IP address Intelligence into your Delphi desktop and mobile applications. We are going to use a service called IPApi, which is one of the market-leading solutions for all your IP Intelligence requirements in one place.

Why would we want to find out information about an IP Address?

The IP address is often tied to an individual user. If you know information about that IP address you can customize some of the information, services or even the user interface to better meet the needs of your users. For example, if you find out that the current time for the IP address is night time then you might want to offer different services to those you offer during their daytime hours. Knowing the local currency in use where the IP address is hosted allows you can offer that as a default for purchases.

Lastly, you may want or need to restrict some of app’s features if an IP address is located in a different country, possibly for security reasons or to comply with local laws or copyright compliance. With proper IP address intelligence information all of this should be possible.

What is the IPApi service?

The IPApi service is a powerful IP lookup RESTful web service that helps to find a different set of information using only the IP address. You can do more fascinating things with IP addresses. For instance:

  • Content Personalization based on location
  • Time Zone Lookup
  • Language Redirection based on geolocation
  • Currency and Fraud detection
  • and more
How To Add IP Address Intelligence Services To Your Apps - IPAPI feature set

The IPApi platform is platform agnostic and offers accurate information. IPApi say their RESTful web service is “trusted by 30,000+ businesses worldwide”.

How do I start getting information about an IP address in my application?

Head over to the IPApi official website to sign up. There is a Free plan to test it out.

How To Add IP Address Intelligence Services To Your Apps example IPAPI plan details
IPApi Example Plan Details

How do I use IPApi to get information about an IP address?

After you sign up, you will have an API access key. And you can utilize that API access key to send requests to the endpoint. 

Here is an example of calling to the endpoint:

How To Add IP Address Intelligence Services To Your Apps IPAPI REST endpoint

And depending on your subscription plan, you get different sets of data in your response:

Furthermore, you can have your IP lookup data in two different representations:

  • JSON
  • XML

Here is a sample request for information about a particular IP address

While sending a request to the base API endpoint you need to specify output type XML or JSON. And here is a sample request for that:

Besides, you can customize response fields. Since the response size is big or you need only location data, for instance. So at this point, you can specify response fields also:

How To Add IP Address Intelligence Services To Your Apps - customizing the REST endpoint

How do I connect my applications to the IPApi API so I can get information about IP addresses?

RAD Studio comes with its handy tools for different jobs. For instance, REST Debugger is one of the most popular tools when you work with RESTful web services. You can customize your API request methods, and based on the response from the endpoint, you can click the “Copy Components” button, which gives an already configured set of REST Client components. Then you can easily add them to your Delphi or C++ Builder project.

These REST Client components are TRESTClientTRESTResponse, and TRESTRequest

How To Add IP Address Intelligence Services To Your Apps in the REST Debugger

How do I build an app which runs on Windows, macOS, Android & iOS and works with the IPApi API?

FireMonkey App Low Code Wizard is the new tool in the RAD Studio toolset, and we will use it in this tutorial.

FireMonkey Low Code Wizard makes the development process several times faster. You can create a fully functional Delphi cross-platform application in seconds. With the low code wizard, you will be asked what kind of features you want. For instance, Settings, Contacts, Profile, Home and Menu windows, and database layer for database needs and more. Moreover, you can customize your app as much as you can. You can read more about what the Low Code Wizard can do for you by clicking here: https://blogs.embarcadero.com/?s=low+code+wizard

How do you start Low Code App development in the RAD Studio Delphi IDE?

Download the newest community edition of Delphi IDE from here. And run the IDE, then go to the Tools menu and open GetIt Package Manager to download FireMonkey App Low-Code Wizard (https://getitnow.embarcadero.com/firemonkey-app-low-code-wizard/)

How To Add IP Address Intelligence Services To Your Apps using the Low Code app wizard

After installation is complete, you need to go on the menu: File->New->Other and select Multi-Device->Firemonkey Template App. And give the project name and choose the screens that you need.

The initial Low Code App Wizard screen

How To Add IP Address Intelligence Services To Your Apps customizing the screens

How can we connect RESTful web service and parse JSON in Delphi?

Well, we’ve already connected to the endpoint using the REST Debugger and copied REST components from it. Now we need to just design our blank new form, and here is our UI structure:

How To Add IP Address Intelligence Services To Your Apps ui structure

After you pasted the REST components that you copied from the REST Debugger, select the RESTRequest1 and open its Params property then clear the access key parameter. Because in this demo, we will customize and parse some exact values.

At this current state, you can call the endpoint using this one line of code:

Here is the final step to getting complete information about an IP address using Delphi

Create an OnClick event on the Check IP button and paste this code:

How To Add IP Address Intelligence Services To Your Apps - the app shown in RAD Studio IDE

This is the finished Delphi IP address information mobile app example running

How To Add IP Address Intelligence Services To Your Apps the APP running on a device

As you can see, creating a cross-platform application and integrating with RESTful web services is easy with Delphi FireMonkey!

Head over and download the full source code for the IPApi with Delphi demo here: https://github.com/checkdigits/IP-Intelligence-in-Delphi-using-ipapi_example


RAD Studio Delphi can easily make your great ideas become real applications in a very short space of time. Why not download a trial today and see for yourself?


What's New for RAD Studio 11

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Software Developer | B.Tech-CSE at AUT | Delphi/C++ Builder Enthusiast | Microsoft Learn Student Ambassador | Microsoft Azure Certified | Udacity Alumni
Related posts
DelphiNewsRAD Studio

Announcing DelphiCon 2021!

C++DelphiIDENewsRAD Studio

New in RAD Studio 11: High DPI IDE and Form Designing!

CodeDelphiRAD Studio

How To Build A Powerful Real-Time Stock Market App

CodeDelphi

11 Tutorials For Working With Ethereum From Delphi

2 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES