diff --git a/README.md b/README.md index 6ba6992..084f85d 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,16 @@ config :geoip, provider: :ipstack, api_key: "your-api-key" config :geoip, provider: :ipinfo, api_key: "your-api-key" ``` +#### IP2Location.io + +[IP2Location.io](https://ip2location.io) does not support lookup by hostname (only ip address), therefore the above examples where a hostname is used will return an error. + +NOTE: Translation for certain columns is available for Plus and Security plan. You can visit the Parameters section in [https://www.ip2location.io/ip2location-documentation](https://www.ip2location.io/ip2location-documentation) for more information + +```elixir +config :geoip, provider: :ip2locationio, api_key: "your-api-key" +``` + #### test Provides an easy way to provide mock lookup data in test environments. diff --git a/lib/geoip/lookup.ex b/lib/geoip/lookup.ex index 39e1f60..d628a03 100644 --- a/lib/geoip/lookup.ex +++ b/lib/geoip/lookup.ex @@ -81,6 +81,10 @@ defmodule GeoIP.Lookup do do: "#{http_protocol()}://ipinfo.io/#{host}/json?token=#{Config.api_key()}#{Config.extra_params()}" + defp lookup_url(host, :ip2locationio), + do: + "#{http_protocol()}://api.ip2location.io/?key=#{Config.api_key()}&ip=#{host}#{Config.extra_params()}" + defp lookup_url(_host, provider) do raise ArgumentError, "Unknown provider: '#{inspect(provider)}'. Please check your geoip configuration."