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

search(ip, locale \\ nil)

Performs a IP search.

{:ok, result} = FreeGeoIP.search(ip)

Arguments

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.