Friday, September 18, 2015

Simple API server for IP Address Information Lookup

I find that I often have the need, in a web application, to lookup information about an IP address that a request comes from.

To serve this purpose I created IPAPI (GitHub), a simple server providing a single API endpoint that returns information about an IP address.

(You should try the server just because the name is a palindrome. Imagine the awe and respect you'll get when you say "I ran a Palindrome API server today.")

The server runs on Node.js and uses the GeoLite2 database from MaxMind.

You can install and run the server with:

git clone [email protected]:guyellis/ipapi.git
npm install
node index.js


npm install ipapi
node node_modules/ipapi/index.js

The server will download and unzip the IP database if it's not found locally.

Using the server is as simple as having your client call http://<your-domain/ip/<x.x.x.x> and getting back JSON with information about the IP.

There are plenty of improvements that can made to this simple server. Pull Requests gladly accepted.


  1. does it auto update its database to the latest ?

    1. It pulls down the latest database if it can't find a DB locally. It then saves the DB locally and uses that on startup. If you want the latest each time you run the server or want it updated on (say) a daily basis then you'd just need to remove the local DB and start the server again. Or modify the code and do a pull request.