Intro
Elixir is a dynamic, functional programming language designed for building scalable and maintainable applications. It runs on the Erlang Virtual Machine (BEAM), which is known for its low-latency, distributed, and fault-tolerant systems – traits that make Elixir especially suitable for real-time and concurrent applications.
For this tutorial, we will demonstrate how easy it is to include the IP2Location.io Erlang library as a dependency in an Elixir project. You can also take a look at the IP2Location.io Erlang codes at its GitHub repo. We’ll be using the library to query the IP2WHOIS API in order to retrieve WHOIS data for a domain name.
Pre-requisites
You’ll need to have Erlang and Elixir installed. Please follow https://elixir-lang.org/install.html for the installation steps. As the IP2Location.io Erlang library requires an IP2Location.io API key, please sign up for one if you don’t currently have one. Our demo will be on a Debian Linux machine so some of the steps will be specifically for that platform.
Creating the Elixir project
Navigate to the folder where you wish to create your project, then run the below command to create the project folder. We’ll call our demo project ip2whoisdemo.
mix new ip2whoisdemo

Adding the IP2Location.io Erlang as a dependency
Now, navigate into the demo project folder and edit the mix.exs file.
cd ip2whoisdemo nano mix.exs
You’ll see the below.

Let’s insert the below line into the deps section and save the file. This will add the IP2Location.io Erlang library as a dependency.
{:ip2location_io_erlang, "~> 1.1"}
In addition, we will also add :ssl and :inets to the extra_applications line.

NOTE: You may need to update the version IP2Location.io Erlang library if there is a newer version.
Now run the below to actually fetch the dependency.
mix deps.get

Modify the test code
Let’s overwrite the generated test code in lib/ip2whoisdemo.ex and replace it with our code below. Remember to replace YOUR_API_KEY with your actual IP2Location.io API key.
nano lib/ip2whoisdemo.ex
defmodule Ip2whoisdemo do def lookup(domain) do api_key = "YOUR_API_KEY" # Initialize with api key :ip2locationio.new(api_key) # Query WHOIS for domain result = :ip2locationio.lookupdomainwhois(domain) # IO.inspect(result) case result do {:error, reason} -> IO.inspect(reason, label: "Error") result_map -> IO.inspect(result_map["domain"], label: "domain") IO.inspect(result_map["domain_id"], label: "domain_id") IO.inspect(result_map["status"], label: "status") IO.inspect(result_map["create_date"], label: "create_date") IO.inspect(result_map["update_date"], label: "update_date") IO.inspect(result_map["expire_date"], label: "expire_date") IO.inspect(result_map["domain_age"], label: "domain_age") IO.inspect(result_map["whois_server"], label: "whois_server") IO.inspect(result_map["nameservers"], label: "nameservers") registrar = result_map["registrar"] IO.inspect(registrar["iana_id"], label: "registrar => iana_id") IO.inspect(registrar["name"], label: "registrar => name") IO.inspect(registrar["url"], label: "registrar => url") registrant = result_map["registrant"] IO.inspect(registrant["name"], label: "registrant => name") IO.inspect(registrant["organization"], label: "registrant => organization") IO.inspect(registrant["street_address"], label: "registrant => street_address") IO.inspect(registrant["city"], label: "registrant => city") IO.inspect(registrant["region"], label: "registrant => region") IO.inspect(registrant["zip_code"], label: "registrant => zip_code") IO.inspect(registrant["country"], label: "registrant => country") IO.inspect(registrant["phone"], label: "registrant => phone") IO.inspect(registrant["fax"], label: "registrant => fax") IO.inspect(registrant["email"], label: "registrant => email") admin = result_map["admin"] IO.inspect(admin["name"], label: "admin => name") IO.inspect(admin["organization"], label: "admin => organization") IO.inspect(admin["street_address"], label: "admin => street_address") IO.inspect(admin["city"], label: "admin => city") IO.inspect(admin["region"], label: "admin => region") IO.inspect(admin["zip_code"], label: "admin => zip_code") IO.inspect(admin["country"], label: "admin => country") IO.inspect(admin["phone"], label: "admin => phone") IO.inspect(admin["fax"], label: "admin => fax") IO.inspect(admin["email"], label: "admin => email") tech = result_map["tech"] IO.inspect(tech["name"], label: "tech => name") IO.inspect(tech["organization"], label: "tech => organization") IO.inspect(tech["street_address"], label: "tech => street_address") IO.inspect(tech["city"], label: "tech => city") IO.inspect(tech["region"], label: "tech => region") IO.inspect(tech["zip_code"], label: "tech => zip_code") IO.inspect(tech["country"], label: "tech => country") IO.inspect(tech["phone"], label: "tech => phone") IO.inspect(tech["fax"], label: "tech => fax") IO.inspect(tech["email"], label: "tech => email") billing = result_map["billing"] IO.inspect(billing["name"], label: "billing => name") IO.inspect(billing["organization"], label: "billing => organization") IO.inspect(billing["street_address"], label: "billing => street_address") IO.inspect(billing["city"], label: "billing => city") IO.inspect(billing["region"], label: "billing => region") IO.inspect(billing["zip_code"], label: "billing => zip_code") IO.inspect(billing["country"], label: "billing => country") IO.inspect(billing["phone"], label: "billing => phone") IO.inspect(billing["fax"], label: "billing => fax") IO.inspect(billing["email"], label: "billing => email") end end end

Launch the interactive shell to run the code
iex -S mix
Then, run the below to query WHOIS data for the domain locaproxy.com.
Ip2whoisdemo.lookup("locaproxy.com")

That’s how easy it is to query WHOIS data using Elixir with the IP2Location.io Erlang library.