Matt Gifford aka coldfumonkeh | Consultant Developer
View Github Profile


IP API CFML Open Source Component

Oct 9, 2019

A few months ago I needed to write some code to interact with the IP API service to fetch geolocation data for certain conditions within the application.

The code I needed to implement was only a single call to a single endpoint on the API, but that evening I decided to write an API wrapper for it in CFML anyway, which was released as open source that very night.

Instantiation of the component is simple.

Grab an API key from the IP API service and include it within the init() constructor call.

Not all plans on the service support HTTPS, so if you don’t have it, you will need to pass the HTTP endpoint into the constructor method too, using the apiEndpoint argument.

To grab a data structure for a given IP address, simply call the ipLookup() method, passing in the IP address to query:

If your subscription plan includes bulk IP lookups, you can optionally send in a comma-separated list of IP addresses.

You can also perform an IP lookup on any IP address that makes the call to the API, so if you want to test it out easily and verify information for your IP, simply call the originIPLookup() method without sending through any parameters.

As you can see, the response contains a lot of really useful information:

Responses for all requests can be either xml or json (default), which is configurable as an argument for each method.

You can find the project on my Github repository here


Latest Blog Posts

Oct 17, 2019
Lucee 5 - Breaking out of script into tags and back again
Read More
Oct 10, 2019
Using Java to create a CFML .wav file audio player component
Read More