Unparalleled suite of productivity-boosting Web APIs & cloud-based micro-service applications for developers and companies of any size.


How Geolocation API Can Improve App Development

Your business can gain an advantage over the competition and convert more sales simply by knowing your user’s location. Think about it. You can outsell your competition simply by providing product information in your user’s native tongue. Best of all, that is just one use case of many where IP tracking and Geolocation can put your company out in front.  

There are many ways to gather geographical info about your users. Firstly, you can use device data, but you need user permission for that. If the user does not approve the permission to access geographical location data, then you can go with a Geolocation API.

What is a Geolocation API?

A Geolocation API provides user location information using IP addresses. In addition,  these APIs offer other information. This includes a user’s currency, time zone information, and what ISP they are using. Geolocation APIs even have security modules that detect proxies and crawlers. 

Are there Free Geolocation APIs?

The good news is, yes there are. There are many geolocation APIs on the market and one of the most widely used is the ipstack API

If you only need limited features the, Ipstack API provides free geolocation. If you go for a paid subscription, however, you also get features like bank-grade security and access to other useful components.

What can You Get from a Geolocation API?

  • Physical address: country, city, postal code, latitude & longitude
  • IP address and ISP details
  • Carrier information like area and network code
  • Local data like timezone, language, currency information
  • Threat information – detecting if an IP address has been a source of malicious activity.

Use Cases of Geolocation API

While there are endless applications for a Geolocation API, customizing a user’s digital experience is by far the most common. Some key customization areas are:  

  • Marketing & Customer Engagement
  • Digital Maps
  • Weather Reports
  • Social Media

What is ipstack?

Ipstack is a robust, real-time IP to geolocation API capable of looking up accurate location data and also assessing security threats originating from risky IP addresses. 

Ipstack delivers results within milliseconds in JSON or XML format. Using the ipstack API, you can immediately locate your website visitors and tailor your user experience accordingly.

How to Get Free API Access Key?

It is easy to get an Ipstack API key. Just head over to the subscriptions page and sign up for a free subscription plan.

It is also easy to get started with ipstack. The ipstack primary endpoint is called Standard Lookup and is used to look up single IPv4 or IPv6 addresses. To call this endpoint, attach any IPv4 or IPv6 address to the API’s base URL.

Example Request:

Example Response: 

How can Geolocation API Improve App Development?

Generally speaking, integrating APIs into your project is usually better than building a service from scratch. Essentially, integrating third-party APIs is a cheaper and faster way to implement geolocation capabilities. 

Over the years APIs have evolved to high standards. As a result, they can save you dozens of hours over engineering solutions yourself. They also ensure smooth integrations with third-party services. Let’s briefly talk about the benefits of using APIs for businesses.

1. Less Maintenance

Less maintenance is everyone’s favorite use case. Because APIs are third-party interfaces, your vendor is responsible for maintenance and updates. If there are changes in the API structure, you will need to make changes on your end,  but that won’t take much time.

2. Less Engineering Hours

Reducing engineering time on your end saves you money. Switching to APIs is a best practice for limiting the expense of creating new applications and saving time prototyping and creating new software. 

APIs are the easiest way to block build your software. 

3. Enhanced Security & Authority

Software systems using APIs are accepted and trusted, APIs have higher authority and trust factors.

Moreover, APIs provide a secure gateway for exchanging information between your app and a database. APIs are also more stable and offer robust security. In addition, they are encrypted for safety.

Now, let’s learn how to integrate ipstack, our geolocation API,  into a cross-platform Delphi FireMonkey application.

How to Integrate ipstack API into Delphi FireMonkey Cross-Platform App?

This demonstration will integrate the ipstack API into our Delphi FireMonkey cross-platform application using the endpoints and fetching and processing JSON data.

The first step is to install the Delphi IDE on your machine. Head over and download the Community Edition, where you can build and play with your projects.

How to Use Bulk IP Lookup?

Ipstack offers the ability to request data for multiple IPv4 or IPv6 addresses simultaneously. Firstly, to process IP addresses in bulk, append multiple comma-separated IP addresses to the API’s base URL.

After installing Delphi Community Edition, start the IDE. Then click the File menu, and select the New command to create a new project. This will give you a set of templates that you can start with. 

I will show you how to connect the ipstack endpoint to fetch data and display the data in the user interface without any code. To do this, you should open REST Debugger, which comes with the Delphi IDE. You can find it here:

Then you can put the URL and send the request, and then the REST Debugger creates the required REST Client configured components so that you can easily Copy and Paste to the project.

After that, click the Copy Components button and paste the configured components to the form.

Then select the RESTRequest1 component and open its context menu and fetch the data. Next add the StringGrid or ListView component and connect the data source (RESTResponse1) to the Grid or List view in the LiveBindings Designer.

Then add one line of code to the OnCreate event of the form. That means, when you start the application, it will fire up the request to the endpoint and fetch the data.

Now finally, you can save the project files and start compiling and building them. Here is the result we get:

How to Enable the Security Module?

You need to subscribe to the Professional Plus subscription plan to use the security module for detecting proxies, crawlers, or threat levels. 

To use this feature, append the API’s security parameter and set it to 1.

Example Request:

If your subscription plan supports the Security Module, the API response will contain a security object. For illustration purposes, the IP address, known to be used by the Tor system, has been used for this example API request.

Example Response:

How to Enable Hostname Lookup?

By default, the ipstack API does not return information about the hostname an IP address resolves to. To include the hostname object in your API result, you should append the API’s hostname parameter and set it to the 1.

Example Request:

Example response, if hostname lookup is enabled, the API response will now come with a hostname object containing the given hostname value. 

Example Response:

How to Fetch & Work JSON Responses in Delphi?

Since we have connected to the endpoint via the REST Debugger and used LiveBindings to show the data, we have written only one line of code. Here, however,  is how to integrate the API manually.

Here is the function that you need to fetch results from the ipstack API: (You can find the whole source code here on this GitHub repository)

Moreover, I have used TStyleBook component and here is the final result:

Head over to the ipstack and get your free API access key right now!

Related posts

Easy Steps to Automate Data Security by Verifying New Phone Prospects with Zapier


How Live Airplane Trackers Work: The Technology Behind Real-Time Flight Tracking


The Best Free APIs to Use in 2024 for Your Business


App Store Search API: How To Optimize Your App's Visibility

Leave a Reply

Your email address will not be published. Required fields are marked *