Installations
npm install maxmind
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=12
Node Version
20.18.1
NPM Version
10.9.1
Score
98.4
Supply Chain
100
Quality
84.7
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (95.38%)
Shell (3.63%)
JavaScript (0.98%)
Developer
runk
Download Statistics
Total Downloads
35,872,640
Last Day
14,587
Last Week
114,268
Last Month
751,378
Last Year
9,505,358
GitHub Statistics
613 Stars
1,226 Commits
63 Forks
17 Watching
16 Branches
24 Contributors
Package Meta Information
Latest Version
4.3.23
Package Id
maxmind@4.3.23
Unpacked Size
22.76 kB
Size
7.68 kB
File Count
18
NPM Version
10.9.1
Node Version
20.18.1
Publised On
27 Nov 2024
Total Downloads
Cumulative downloads
Total Downloads
35,872,640
Last day
-55.6%
14,587
Compared to previous day
Last week
-38.1%
114,268
Compared to previous week
Last month
-17.3%
751,378
Compared to previous month
Last year
20%
9,505,358
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
node-maxmind
Javascript module for Geo IP lookup using Maxmind binary databases (aka mmdb or geoip2). Fastest Maxmind lookup library available - up to 17,000% faster than other libraries. Module has 100% test coverage with comprehensive test suite. It natively works with binary Maxmind database format and doesn't require any "CSV - {specific lib format}" conversions as some other modules do. Maxmind binary databases are highly optimized for size and performance so there's no point using other formats.
GEO databases
You might want to use geolite2 module with free geo databases. Alternatively, free databases available for download here. If you need better accuracy you should consider buying commercial subscription.
Installation
1npm i maxmind
Usage
1import maxmind, { CityResponse } from 'maxmind'; 2 3const lookup = await maxmind.open<CityResponse>('/path/to/GeoLite2-City.mmdb'); 4console.log(lookup.get('66.6.44.4')); // inferred type maxmind.CityResponse 5 6console.log(lookup.getWithPrefixLength('66.6.44.4')); // tuple with inferred type [maxmind.CityResponse|null, number]
Sync API
You can use Reader
class directly in case if you would want to instantiate it in non-async fashion. Use cases would include receiving a buffer database over network, or just reading it synchronously from disk.
1import { Reader } from 'maxmind'; 2const buffer = fs.readFileSync('./db.mmdb'); 3const lookup = new Reader<CityResponse>(buffer); 4const city = lookup.get('8.8.8.8'); 5 6const [city2, prefixLength] = lookup.getWithPrefixLength('66.6.44.4');
Supported response types:
- CountryResponse
- CityResponse
- AnonymousIPResponse
- AsnResponse
- ConnectionTypeResponse
- DomainResponse
- IspResponse
IPv6 Support
Module is fully compatible with IPv6. There are no differences in API between IPv4 and IPv6.
1const lookup = await maxmind.open('/path/to/GeoLite2.mmdb'); 2const location = lookup.get('2001:4860:0:1001::3004:ef68');
Options
maxmind.open(filepath, [options])
filepath
:<string>
Path to the binary mmdb database file.options
:<Object>
cache
:<Object>
Cache options. Under the bonnet module uses tiny-lru cache.max
:<number>
Max cache items to keep in memory. Default:10_000
.
watchForUpdates
:<boolean>
Supports reloading the reader when changes occur to the database that is loaded. Default:false
.watchForUpdatesNonPersistent
:<boolean>
Controls whether the watcher should be persistent or not. If it is persistent, a node process will be blocked in watching state if the watcher is the only thing still running in the program. Default:false
.watchForUpdatesHook
:<Function>
Hook function that is fired on database update. Default:null
.
Does it work in browser?
Current module is designed to work in node.js environment. Check out mmdb-lib that's used under the bonnet - it's environment agnostic and does work in browser.
IP addresses validation
Module supports validation for both IPv4 and IPv6:
1maxmind.validate('66.6.44.4'); // returns true 2maxmind.validate('66.6.44.boom!'); // returns false 3 4maxmind.validate('2001:4860:0:1001::3004:ef68'); // returns true 5maxmind.validate('2001:4860:0:1001::3004:boom!'); // returns false
GeoIP Legacy binary format
In case you want to use legacy GeoIP binary databases you should use maxmind@0.6.
References
- MMDB library
- MaxMind DB file format specification http://maxmind.github.io/MaxMind-DB/
- MaxMind test/sample DB files https://github.com/maxmind/MaxMind-DB
- GeoLite2 Free Downloadable Databases http://dev.maxmind.com/geoip/geoip2/geolite2/
- Great talk about V8 performance https://www.youtube.com/watch?v=UJPdhx5zTaw
- V8 Optimization killers https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
- More V8 performance tips http://www.html5rocks.com/en/tutorials/speed/v8/
License
MIT
No vulnerabilities found.
Reason
18 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:7
Reason
Found 2/19 approved changesets -- score normalized to 1
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/runk/node-maxmind/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/runk/node-maxmind/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/runk/node-maxmind/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/runk/node-maxmind/release.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/build.yml:26
- Warn: npmCommand not pinned by hash: .github/workflows/release.yml:21
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Score
5.3
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More