FreeGeoIP v0.0.3 FreeGeoIP.Search
This module includes the basic search function to get geo information about a specified IP.
Summary
Functions
Performs a IP search
Functions
Performs a IP search.
{:ok, result} = FreeGeoIP.search(ip)
Arguments
ip
: can be either a stinrg or a tuple representing an IPv4 ip formatlocale
: (optional) localize the geolocation data. You can use ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) or any string valid for aAccept-language
HTTP header specification
Sample result
%{
"city" => "San Francisco",
"country_code" => "US",
"country_name" => "United States",
"ip" => "192.30.252.128",
"latitude" => 37.7697,
"longitude" => -122.3933,
"metro_code" => 807,
"region_code" => "CA",
"region_name" => "California",
"time_zone" => "America/Los_Angeles",
"zip_code" => "94107"
}
Errors:
The errors will have the following format:
%{:error, %{reason: reason, error: error_message}}
reason
can be one of the following:
:auth_failed
: the server is protected with basic authentication and you have passed wrong credentials (see below for authentication):process_timeout
: the server responded, but internally caused a timeout:timeout
: server did not respond in a few seconds- Any other reason given by the HTTPoison.Error
:incorrect_ip_range
: incorrect IP provided (like 500.23.1100.32):incorrect_ip_format
: specified IP format not supported. Use only string or tuple.