Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

geo-from-ip

2.0.0 • Public • Published

geo-from-ip

Get geolocation 🌐 information about an IP 📲

Build Status NPM Version NPM Download

Features

  • No frills install 🚀
  • Downloads GeoLite2 databases automatically during installation 🔋
  • Run npm install to upgrade databases == automatic update on deployments 💎

How to use

  • Include package in your project
npm install --save geo-from-ip
# or, if you are using yarn 
yarn add --save geo-from-ip
  • Set MAXMIND_LICENSE_KEY=<your_maxmind_license_key> in your environment variables. Read more about this change on MaxMind's blog.

  • Use package to get geo data from IP

const geoip = require('geo-from-ip')
console.log(geoip.allData('199.188.195.120'))
 
/*
{ code: { state: 'CA', country: 'US', continent: 'NA' },
  city: 'San Francisco',
  state: 'California',
  country: 'United States',
  continent: 'North America',
  postal: '94103',
  location:
   { accuracy_radius: 10,
     latitude: 37.7758,
     longitude: -122.4128,
     metro_code: 807,
     time_zone: 'America/Los_Angeles' } }
 */
  • Update database

Database will get automatically updated every time deployment happens. But if you would like to force an update, just run:

npm install
# or, if you are using yarn 
yarn

Debugging / Developing

Run your code using geo-from-ip as debug flag. Look into pacakge.json for example.

Credits

Developer: 👨‍💻 Vikram Tiwari

If you found this library helpful, or learned something from it and want to thank me, consider buying me a cup of ☕️.

Database: Max-Mind

This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com

Install

npm i geo-from-ip

DownloadsWeekly Downloads

492

Version

2.0.0

License

MIT

Unpacked Size

12.4 kB

Total Files

11

Last publish

Collaborators

  • avatar