Git Product home page Git Product logo

geoip's Introduction

==== GeoIP ================================================
Returns the location of an IP address. Based on the http://ipinfodb.com web service.
To use the service user must have a API key, you may get it free after registration: http://ipinfodb.com/register.php.

----- Usage -----------------------------------------------
--- Before using
You must start the daemon before calling any of the functions

1> geoip:start("API_key").
{ok, <0.44.0>}

--- Lookup geolocation
2> geoip:geolocation().
#response{
	ip = {95,30,242,238},
	status = "OK",
	country_code = "RU",
	country_name = "Russian Federation",
	region_code = 48,
	region_name = "Moscow City",
	city = "Moscow",
	zip_postal_code = undefined,
	latitude = 55.7522,
	longitude = 37.6156,
	...
}

or

3> geoip:geolocation({74, 125, 232, 17}).
#response{
	ip = {74,125,232,17},
	status = "OK",
	country_code = "US",         
	country_name = "United States",
	region_code = 6,
	region_name = "California",
	city = "Mountain View",
	zip_postal_code = 94043,
	latitude = 37.4192,
	longitude = -122.057,
	...
}

--- Country precision (faster)

4> geoip:geolocation(#options {precision=country}).                    
#response{
	ip = {2,95,9,156},
	status = "OK",
	country_code = "RU",
	country_name = "Russian Federation",
	...
}

or

5> geoip:geolocation({74, 125, 232, 17}, #options {precision=country}).
#response{
	ip = {74,125,232,17},
	status = "OK",
	country_code = "US",
	country_name = "United States",
	...
}

--- Add timezone data

6> geoip:geolocation(#options {timezone = true}).  
#response{
	ip = {2,95,9,156},
	status = "OK",
	country_code = "RU",
 	country_name = "Russian Federation",
	region_code = 48,
	region_name = "Moscow City",
	city = "Moscow",
	zip_postal_code = undefined,
	latitude = 55.7522,
	longitude = 37.6156,
	timezone = "Europe/Moscow",
	utc_offset = 10800,
	dst = false
}

or

7> geoip:geolocation({74,125,232,17}, #options {timezone = true}).
#response{
	ip = {74,125,232,17},
	status = "OK",
	country_code = "US",
	country_name = "United States",
	region_code = 6,
	region_name = "California",
	city = "Mountain View",
	zip_postal_code = 94043,
	latitude = 37.4192,
	longitude = -122.057,
	timezone = "America/Los_Angeles",
	utc_offset = -25200,
	dst = true
}

--- Lookup your IP address
8> geoip:ip().
{2,95,9,156}

----- Compile & test --------------------------------------
make
cd ebin
./test.escript API_key

----- Copyright -------------------------------------------
Copyright (c) 2010 Andrey Nesterov. See LICENSE for details.

geoip's People

Contributors

manifest avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.