10.4.0 β€’ Published 10 months ago

@k03mad/ip2geo v10.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

GeoIP lookup

β€” Using ipwhois.io \ β€” Runtime + filesystem caching

Global

npm i @k03mad/ip2geo -g
ip2geo --help

ip2geo
# your IP info

ip2geo 1.1.1.1
# {
#   ip: '1.1.1.1',
#   continent: 'North America',
#   continentCode: 'NA',
#   country: 'United States',
#   countryCode: 'US',
#   countryEmoji: 'πŸ‡ΊπŸ‡Έ',
#   region: 'District of Columbia',
#   regionCode: 'DC',
#   city: 'Washington',
#   connectionAsn: 13335,
#   connectionOrg: 'APNIC and Cloudflare DNS Resolver project',
#   connectionIsp: 'Cloudflare, Inc.',
#   connectionDomain: 'cloudflare.com'
# }

ip2geo 1.1.1.1 8.8.8.8 --json
# [{"ip":"1.1.1.1","continent":"North America","continentCode":"NA","country":"United States","countryCode":"US","countryEmoji":"πŸ‡ΊπŸ‡Έ","region":"District of Columbia","regionCode":"DC","city":"Washington","connectionAsn":13335,"connectionOrg":"APNIC and Cloudflare DNS Resolver project","connectionIsp":"Cloudflare, Inc.","connectionDomain":"cloudflare.com"},{"ip":"8.8.8.8","continent":"North America","continentCode":"NA","country":"United States","countryCode":"US","countryEmoji":"πŸ‡ΊπŸ‡Έ","region":"California","regionCode":"CA","city":"Mountain View","connectionAsn":15169,"connectionOrg":"Google LLC","connectionIsp":"Google LLC","connectionDomain":"google.com"}]

API

npm i @k03mad/ip2geo
import {ip2geo} from '@k03mad/ip2geo';

const info = await ip2geo({
    ip: '1.1.1.1', // make key falsy to use current external IP
    // defaults
    cacheDir: path.join(os.tmpdir(), '.ip2geo'),
    cacheFileName: 'ips.log',
    cacheFileSeparator: ';;',
    cacheFileNewline: '\n',
    cacheMap: new Map(),
    cacheMapMaxEntries: Number.POSITIVE_INFINITY, // store last N requests, 0 β€” turns cache map off
    rps: 3, // API RPS, useful in Promise.all with IPs array
});

// info {
//   ip: '1.1.1.1',
//   continent: 'North America',
//   continentCode: 'NA',
//   country: 'United States',
//   countryCode: 'US',
//   countryEmoji: 'πŸ‡ΊπŸ‡Έ',
//   region: 'District of Columbia',
//   regionCode: 'DC',
//   city: 'Washington',
//   connectionAsn: 13335,
//   connectionOrg: 'APNIC and Cloudflare DNS Resolver project',
//   connectionIsp: 'Cloudflare, Inc.',
//   connectionDomain: 'cloudflare.com'
// }
10.4.0

10 months ago

10.0.0

11 months ago

10.1.0

11 months ago

10.1.1

11 months ago

10.3.0

11 months ago

9.7.0

11 months ago

9.6.0

11 months ago

9.4.0

11 months ago

9.3.0

11 months ago

7.4.0

12 months ago

7.3.1

12 months ago

7.3.0

1 year ago

7.2.0

1 year ago

7.5.0

11 months ago

8.1.0

11 months ago

8.0.0

11 months ago

9.2.0

11 months ago

9.1.0

11 months ago

9.0.0

11 months ago

7.1.0

1 year ago

7.0.4

1 year ago

7.0.3

1 year ago

7.0.2

1 year ago

7.0.1

1 year ago

6.1.0

1 year ago

6.0.1

1 year ago

6.0.0

1 year ago

7.0.0

1 year ago

5.0.1

1 year ago

5.0.0

1 year ago

4.3.0

1 year ago

4.1.0

1 year ago

4.0.0

1 year ago

4.2.1

1 year ago

4.2.0

1 year ago

3.1.0

1 year ago

3.0.0

1 year ago

2.3.2

1 year ago

2.3.1

1 year ago

2.3.0

1 year ago

2.2.0

1 year ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago