https://github.com/willscott/ip2country
A standalone ip -> country lookup table. Prebuilt & Redistributable.
https://github.com/willscott/ip2country
Last synced: 7 months ago
JSON representation
A standalone ip -> country lookup table. Prebuilt & Redistributable.
- Host: GitHub
- URL: https://github.com/willscott/ip2country
- Owner: willscott
- License: apache-2.0
- Created: 2014-11-28T20:13:46.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2025-04-29T00:42:16.000Z (about 1 year ago)
- Last Synced: 2025-07-23T08:48:11.269Z (11 months ago)
- Language: JavaScript
- Size: 172 KB
- Stars: 28
- Watchers: 9
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
IP 2 Country
============
IP 2 Country provides a current lookup table to geolocate IP address to
the countries in which they are most probably located. Distributed as a
stand-alone NPM module with no dependencies, the list is created at publication
time. This mapping is generated through the use of two databases:
* [autnums](http://www.cidr-report.org/as2.0/autnums.html) Provides a
textual descriptiosn of each registered ASN, including the country to which
that ASN is registered.
* [routeviews.org orginas](http://www.routeviews.org/) Provides a
current list of BGP announcements, allowing us to understand which ASNs
are announcing ownership of which IP prefixes.
Size
-----
```
4.3M ip2country.js
1.1M ip2country.js.gz
```
Installation
-----
```
npm install ip2country
```
Usage
-----
```javascript
import ip2country from 'ip2country';
let country = ip2country(ip);
```
Advanced Usage
--------------
There are several related lookup tables for IP addresses that may be of use.
While not published for direct consumption, this library contains the tools
to generate those tables for your process. This functionality is accessed
through the ```getGenericMap()``` function in build.js. In particular, the
following knobs are exposed when generating the lookup table:
* compress - Should the table be de-duplicated? When false the table will be
faster to generate but slower to look up.
* toCountry - Should the ip-ASN table be joined with an ASN-country table?
When false an IP-ASN lookup table will be generated.
* when - At what point should the table be generated? If set, the full RIB -
routing information base - from the given time will be loaded and an
originas extracted from that file (see historicBGPData.js).
* nocache - Should a new originas be downloaded even if one already exists
on disk? (defaults to false).