Skip to content

Instantly share code, notes, and snippets.

@shripadk
Created May 15, 2011 06:12
Show Gist options
  • Save shripadk/972909 to your computer and use it in GitHub Desktop.
Save shripadk/972909 to your computer and use it in GitHub Desktop.
GeoIP 0.3.4-1
var geoip = require('geoip@0.3.4-1');
var ip = '50.19.121.109';
var data = geoip.open('/usr/local/share/GeoIP/GeoLiteCity.dat');
var result = geoip.City.record_by_addr(data, ip);
console.log(result);
/**
RESULT:
{ country_code: 'US',
country_code3: 'USA',
country_name: 'United States',
continent_code: 'NA',
region: 'WA',
city: 'Seattle',
postal_code: '98144',
latitude: 47.5839,
longitude: -122.2995,
metro_code: 819,
dma_code: 819,
area_code: 206 }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment