ip-geo-zone
v1.0.0
Published
Simple library for determining country and timezone from IP address
Downloads
7
Maintainers
Readme
ip-geo-zone
⚠️ Maintenance Notice: This project is provided as-is and is unlikely to receive updates.
Simple library for determining country and timezone from IP address using embedded country and timezone data.
Installation
npm install ip-geo-zoneUsage
import { findCountryByIp, findTimezonesByCountry, aton4 } from 'ip-geo-zone'
// Get country code from IP
const country = findCountryByIp('8.8.8.8')
console.log(country) // 'US'
// Get timezones for country
const timezones = findTimezonesByCountry('US')
console.log(timezones) // ['America/New_York', 'America/Los_Angeles', ...]
// Convert IP to numeric representation
const numeric = aton4('192.168.1.1')
console.log(numeric) // 3232235777API
findCountryByIp(ipAddress: string): string | null
Returns country code (e.g., 'US') for the given IP address, or null if not found.
findTimezonesByCountry(countryCode: string): string[] | null
Returns array of timezone names for the given country code, or null if not found.
aton4(ipAddress: string): number
Converts IPv4 address string to numeric representation.
License
ISC
