Socket
Socket
Sign inDemoInstall

micro-geoip-lite

Package Overview
Dependencies
12
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    micro-geoip-lite

🌍 An extremely lite geoip decoder utilizing the micro-geoip-lite microservice to geo decode the IP info via an https request - the microservice utilizes MaxMind's IP info dataset.


Version published
Weekly downloads
265
decreased by-30.45%
Maintainers
1
Install size
813 kB
Created
Weekly downloads
 

Readme

Source

micro-geoip-lite

🌍 An extremely lite geoip decoder utilizing the micro-geoip-lite microservice to geo decode the IP info via an https request - the microservice utilizes MaxMind's IP info dataset.

npm version

Installation

  • Run yarn add micro-geoip-light, npm i micro-geoip-light

Usage

  • params:

    • ip?: string - optional, defaults to client's IP
    • options?: { serviceUrl: string } - optional, called instead of the default provider URL.
  • returns:

    {
      ip: string, // if ip param was not provided, this defaults to request.ip
      range: [ number, number ],
      country: string,
      region: string,
      eu: string, // '0' or '1'
      timezone: string,
      city: string,
      ll: [ number, number ],
      metro: number,
      area: number,
      // error: 'Error text', // only exists if an error happened
    }
    
  • example - fetch own ip info:

    import geodecodeIp from 'micro-geoip-light';
    
    const result = await geodecodeIp();
    
    {
      ip: '207.97.227.239', // if ip param was not provided, this defaults to request.ip
      range: [ 3479298048, 3479300095 ],
      country: 'US',
      region: 'TX',
      eu: '0',
      timezone: 'America/Chicago',
      city: 'San Antonio',
      ll: [ 29.4969, -98.4032 ],
      metro: 641,
      area: 1000,
      // error: 'Error text', // only exists if an error happened
    }
    
  • example - fetch specific ip info:

    import geodecodeIp from 'micro-geoip-light';
    
    const result = await geodecodeIp('207.97.227.239');
    
  • Live DEMO

Keywords

FAQs

Last updated on 10 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc