Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var geo = require ('geoip2ws') ('userId', 'licenseKey');
// console.log is limited to only 3 levels
function output (err, data) {
console.dir (err || data, {depth: 10});
}
// Lookup Google
geo ('insights', '173.194.65.100', output);
{ country:
{ iso_code: 'US',
names:
{ 'pt-BR': 'Estados Unidos',
es: 'Estados Unidos',
ru: 'Сша',
en: 'United States',
'zh-CN': '美国',
fr: 'États-Unis',
de: 'USA',
ja: 'アメリカ合衆国' },
geoname_id: 6252001 },
location:
{ longitude: -122.0574,
latitude: 37.4192,
time_zone: 'America/Los_Angeles',
metro_code: 807 },
subdivisions:
[ { iso_code: 'CA',
names:
{ 'pt-BR': 'Califórnia',
es: 'California',
ru: 'Калифорния',
en: 'California',
'zh-CN': '加利福尼亚州',
fr: 'Californie',
de: 'Kalifornien',
ja: 'カリフォルニア州' },
geoname_id: 5332921 } ],
postal: { code: '94043' },
city:
{ names:
{ en: 'Mountain View',
'zh-CN': '芒廷维尤',
fr: 'Mountain View',
de: 'Mountain View',
ja: 'マウンテンビュー',
ru: 'Маунтин-Вью' },
geoname_id: 5375480 },
continent:
{ names:
{ 'pt-BR': 'América do Norte',
es: 'Norteamérica',
ru: 'Северная Америка',
en: 'North America',
'zh-CN': '北美洲',
fr: 'Amérique du Nord',
de: 'Nordamerika',
ja: '北アメリカ' },
geoname_id: 6255149,
code: 'NA' },
maxmind: { queries_remaining: 72081 },
registered_country:
{ iso_code: 'US',
names:
{ 'pt-BR': 'Estados Unidos',
es: 'Estados Unidos',
ru: 'Сша',
en: 'United States',
'zh-CN': '美国',
fr: 'États-Unis',
de: 'USA',
ja: 'アメリカ合衆国' },
geoname_id: 6252001 },
traits:
{ domain: '1e100.net',
autonomous_system_number: 15169,
ip_address: '74.125.206.100',
organization: 'Google',
isp: 'Google',
autonomous_system_organization: 'Google Inc.' } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.