Building Better User Experiences with IPstack
Knowledge is power. This is perhaps true. What about “knowledge and data are power?” That’s undeniable. Data is the most valuable asset in today’s connected world. For developers, publishers and even enthusiasts, ipstack.com, a service providing IP to geolocation data is a gold mine.
What is ipstack.com?
Ipstack.com is a provider of real-time geolocation data. The API is used by developers, SMBs and even large corporations all around the world in various implementations. The API covers more 2 million unique locations in more than 200.000 cities around the world and provides up-to-date data based on rock-solid sources.
The ipstack.com API is built with scalability and ease of use in mind. Whether you need 100, 1000 or even 1000000 requests a day, ipstack.com has you covered. In fact, per month, the API handles around 3 billion requests per day.
The ipstack.com API
The ipstack.com database and API is integrated with an extended network of ISPs and is continuously updated with data on new or existing IP ranges. In fact, ipstack.com receives around 24 updates per day, making it reliable and relevant.
The API is scalable and robust. Engineered to avoid congestion, the infrastructure behind ipstack.com is based on a modular platform that can be expanded to accommodate spikes in requests without service degradation. And all of this is backed-up by an impressive 99.99% uptime for the last year.
Flexible and Accurate
The API is capable of delivering any geodata you would expect. The three endpoints — Standard IP Lookup, Bulk IP Lookup and Requester IP Lookup — offer granular control over the data you need to extract from the API.
The standard lookup will look up single IPv4 or IPv6 addresses. The syntax is simple. Just add an IPv4 or IPv6 address to the API’s base URL.
https://api.ipstack.com/XXX.XXX.XXX.XXX ? access_key = YOUR_ACCESS_KEY
In addition to the mandatory IP Address and access_key parameters, you can append to you request parameters such as hostname, security, language, callback or output. Each parameter will return a specific value. For example, the output parameter will set the output format to either JSON or XML.
The API response will display the IP, the type of the IP, location data including continent, country code, country name, region code, city or ZIP code. Also, the API will provide geographical coordinates, geoname ID, language, country flag including the country flag emoji, detailed data on the time zone, currency and the ISP provider.
The bulk option works the same, but you can specify multiple targets.
https://api.ipstack.com/XXX.XXX.XXX.XXX,XXX.XXX.XXX.XXX,XXX.XXX.XXX.XXX, ? access_key = YOUR_ACCESS_KEY
If you request a response in JSON, the API will provide one IP data object per requested address. The XML the response will be <batch></batch> and contain one <result></result> with its respective index number per requested IP address/domain.
The third endpoint, the Requester IP Lookup, can be used to generate a response for the current IP address from where the request is made. It has the same parameters available as the other two endpoints.
You can request the response to be delivered in JSON or XML. For JSON you’ll append & output = json to your query or & output = xml for XML.
Custom Response Fields
When you don’t need the all the information the API provides, you can limit the response to specific objects. For example, to display only the country code, your query should look like this:
https://api.ipstack.com/184.108.40.206 ? access_key = YOUR_ACCESS_KEY & fields = country_code
There are quite a lot of options here so you should have a look at ipstack.com extended documentation, where you’ll find all possible implementation of the API, it’s features, options, and integrations.
What Can You Do With the ipstack.com API?
There are a lot of use case scenarios for using the API. For example, I am using the service for two primary situations: usability and security. However, ipstack.com proved to be essential for a somewhat complicated project that I want to forget about it.
Building the ‘China Wall’
It was a state-funded project, designed to provide online access to social and medical services. If you’ve ever worked for a state project, you know that the amount of bureaucracy and technical illiteracy can prove to be a significant bottleneck. The technical requirements were a mess of legal wording and technical utopia. Some of the goodies were contradictory requirements, obsolete technological platforms, and even some severe security threats.
The idea of the project was to design a web-based platform, interconnected with existing tools, that would allow easy access via a website and a mobile application to a set of social services. According to the requirements “any citizen should have immediate, reliable, and full access to the service” but “the service should be accessible only within the country.” Our legal team had a lot of long nights to find a baseline on which we should work.
In an incredible effort, we’ve managed to achieve a perfect balance between the requirements, the legal framework and the technical implementation, with one big exception. While our legal team managed to design a viable concept that would fit with all existing regulations on privacy and data security, we’ve failed to convince anyone from the working group to accept our solution.
So, we had to block anyone outside the borders to access the app. And we did that with ipstack.com’s API. A few lines of code, and we ended up with an elegant module that did the trick.
Usability Tweaks with ipstack.com
I’ve used ipstack.com API for various goals. Everybody knows that the longer a user takes to complete a form, the bigger chance of abandonment. The API helped me to autocomplete location, currency or language fields, estimate delivery times, calculate shipping costs, implement tax calculations and more. Of course, there are other solutions to do that, but ipstack.com is the most efficient method. With reusable code snippets, I can implement the API in a breeze.
Also, ipstack.com allowed me to filter bad IPs, denial of service attacks, spammers and other threats from reaching my projects. Of course, IP filtering is not a panacea, but ipstack.com API is any superhero’s sidekick. And with such an accurate and consistent sidekick, saving the day (or the project), is so much easier.
Get Started With ipstack.com
Getting started with ipstack.com is easy. After you register for a free API access key, you’ll be able to test the the service it in less than 10 minutes. That’s exactly how much time you’ll need to set up a test environment. A quick start tool is available for both free and premium users and will showcase the full power of the API with a few clicks.
Ipstack.com comes with a free tier which will help you test the API on your website or application. Premium plans start at $9.99 per month and include SSL encryption, additional API features including bulk or batch support, and extended support. Ipstack.com is available on a subscription-based model so that you can select the billing frequency based on your needs. If you’ll enroll in an yearly plan, you’ll also get a 20% discount. Payments can be made via credit cards, PayPal or, for enterprises, via standard bank transfer.
By default, ipstack.com guarantees 2,000,000 API requests per month, which is more than enough for most. However, if you need to extend the number of requests, the ipstack.com team will be happy to customize your instance to accommodate your needs. If you’ll exceed your API request volume, you should know that you have a 20% safety net to adjust operations.
Just remember, geolocation is a sensible topic. Ipstack.com is a powerful tool, but it’s just a tool. It’s up to you to find the line that separates a fantastic user experience from abuse. It’s all about privacy by design. Power is nothing without knowledge.