All Projects → fvdm → nodejs-geoip2ws

fvdm / nodejs-geoip2ws

Licence: Unlicense license
Maxmind GeoIP2 Web Services for Node.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nodejs-geoip2ws

locus
MMDB reader for geolocation and ASN lookup of IP addresses
Stars: ✭ 93 (+97.87%)
Mutual labels:  geolocation, geoip2, geoip
GeoIP2-ruby
Ruby API for GeoIP2 webservice client and database reader
Stars: ✭ 41 (-12.77%)
Mutual labels:  geoip2, geoip, maxmind
mmdbwriter
Go library for writing MaxMind DB (mmdb) files
Stars: ✭ 44 (-6.38%)
Mutual labels:  geoip2, geoip, maxmind
MaxMind-DB-Writer-perl
Create MaxMind DB database files
Stars: ✭ 63 (+34.04%)
Mutual labels:  geoip2, geoip, maxmind
Geoip2 Php
PHP API for GeoIP2 webservice client and database reader
Stars: ✭ 1,956 (+4061.7%)
Mutual labels:  geoip2, geoip, maxmind
MaxMind-DB-Reader-python
Python MaxMind DB reader extension
Stars: ✭ 131 (+178.72%)
Mutual labels:  geoip2, geoip, maxmind
geoip2
GeoIP2 Reader for Go
Stars: ✭ 54 (+14.89%)
Mutual labels:  geoip2, geoip, maxmind
MaxMind-DB-Reader-ruby
Ruby reader for the MaxMind DB Database Format
Stars: ✭ 35 (-25.53%)
Mutual labels:  geoip2, geoip, maxmind
geoip2-rs
Fast GeoIP2 Reader for Rust
Stars: ✭ 25 (-46.81%)
Mutual labels:  geoip2, geoip, maxmind
GeoIP2-perl
Perl API for MaxMind's GeoIP2 web services and databases
Stars: ✭ 18 (-61.7%)
Mutual labels:  geoip2, geoip, maxmind
MaxMind-DB-Reader-java
Java reader for the MaxMind DB format
Stars: ✭ 88 (+87.23%)
Mutual labels:  geoip2, geoip, maxmind
Country Ip Blocks
CIDR country-level IP data, straight from the Regional Internet Registries, updated hourly.
Stars: ✭ 100 (+112.77%)
Mutual labels:  geolocation, geoip
Shiny geoip
IP to location API service
Stars: ✭ 172 (+265.96%)
Mutual labels:  geolocation, geoip
Geo ip
Retreive the geolocation of an IP address based on the ipinfodb.com webservice
Stars: ✭ 103 (+119.15%)
Mutual labels:  geolocation, geoip
Iploc
Fastest IP To Country Library
Stars: ✭ 224 (+376.6%)
Mutual labels:  geolocation, geoip
pf-azure-sentinel
Parse pfSense/OPNSense logs using Logstash, GeoIP tag entities, add additional context to logs, then send to Azure Sentinel for analysis.
Stars: ✭ 24 (-48.94%)
Mutual labels:  geoip, maxmind
Geoip2 Golang
Unofficial MaxMind GeoIP2 Reader for Go
Stars: ✭ 1,074 (+2185.11%)
Mutual labels:  geolocation, geoip
GeoLite2-City
GeoLite2-City.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 170 (+261.7%)
Mutual labels:  geoip, maxmind
GeoLite.mmdb
MaxMind's GeoIP2 GeoLite2 Country, City, and ASN databases
Stars: ✭ 690 (+1368.09%)
Mutual labels:  geolocation, geoip
GeoLite2-Country
GeoLite2-Country.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 69 (+46.81%)
Mutual labels:  geoip, maxmind

geoip2ws

Unofficial Node.js module for the Maxmind GeoIP2 Web Services.

npm Build Status Coverage Status

Usage

You can provide the configuration in the require function or inline at lookup time. The lookup always returns a Promise.

Normal configuration

const geo = require ('geoip2ws') ({
  userId: '12345',
  licenseKey: 'abc678',
});

geo ({
  service: 'city',
  ip: '1.2.3.4',
})
  .then (console.log)
  .catch (console.error)
;

Inline configuration

const geo = require ('geoip2ws')();

geo ({
  userId: '12345',
  licenseKey: 'abc678',
  service: 'city',
  ip: '1.2.3.4',
})
  .then (console.log)
  .catch (console.error)
;

Installation

You need a Maxmind account ID and license key with enough credits for one of their GeoIP web services. You can find both here.

npm i geoip2ws

The functions

Setup

The first function is the global config and returns the lookup function. It takes these settings:

parameter type default description
[userId] string User ID
[licenseKey] string License key
[service] string city insights, country or city
[endpoint] string https://geoip.maxmind.com Override endpoint hostname or url
[requestTimeout] integer 5000 Request timeout in ms
const geo = require ('geoip2ws') ({
  userId: '1234',
  licenseKey: 'abc',
  service: 'country',
  requestTimeout: 2000
});

If you are providing the details in the lookup function, then you don't have to set them here but you do need to run this setup function once.

const geo = require ('geoip2ws')();

Lookup

The second function does the IP-address lookup and takes ip and optionally the same settings as above.

parameter type description
ip string The IPv4 or IPv6 address to lookup
geo ({
  ip: '1.2.3.4',
  service: 'city',
  endpoint: 'geoip-eu-west.maxmind.com',
})
  .then (processData)
  .catch (console.error)
;

Errors

error message description
invalid service The service name is invalid
invalid ip The IP-address is invalid

These two conditions are checked before sending the request. Meaning it won't cost you account credits.

Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to https://unlicense.org/

Author

Franklin | Buy me a coffee

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].