# [<img src="" alt="IPinfo" width="24"/>]( IPinfo Erlang Client Library

This is the official Erlang/Elixir client library for the []( IP data API, allowing you to lookup your own IP address, or get any of the following details for an IP:

- [IP geolocation data]( (city, region, country, postal code, latitude and longitude)
- [ASN details]( (ISP or network operator, associated domain name, and type, such as business, hosting or company)
- [Company data]( (the name and domain of the business that uses the IP address)
- [Carrier information]( (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic)

Check all the data we have for your IP address [here](

## Getting Started

You'll need an IPinfo API access token, which you can get by signing up for a free account at [](

The free plan is limited to 50,000 requests per month, and doesn't include some of the data fields such as IP type and company data. To enable all the data fields and additional request volumes see [](

## Installation

Add this line to your application's rebar.config:

{deps, [ipinfo]}.

## Usage

{ok, IpInfo} = ipinfo:create(<<"29a75d15">>),
{ok, Details} = ipinfo:details(IpInfo),
#{ip := Ip, city := City, loc := Loc} = Details,
%% ...

### Details Data

`ipinfo:details/1,2` will return a map that contains all fields
listed in the [IPinfo developerdocs](
with a few minor additions. Properties can be accessed directly.

### Configuration


## For elixir folks

alias :ipinfo, as: IPinfo

def current_ip() do
  with {:ok, %IPinfo{} = handler} <- IPinfo.create(),
       {:ok, details} <- IPinfo.details(handler) do
    |> String.to_charlist()
    |> :inet_parse.address()