UNPKG

@minilibs/ip2geo

Version:

Ip to Geo location instantly ⚡

88 lines (85 loc) 2.81 kB
interface Ip { ip: string; type: string; continent: string; continentCode: string; country: string; countryCode: string; region: string; regionCode: string; city: string; latitude: number; longitude: number; isEu: boolean; postal: string; callingCode: string; capital: string; borders: Array<string>; flag: { img: string; emoji: string; emojiUnicode: string; }; connection: { asn: number; org: string; isp: string; domain: string; }; timezone: { id: string; abbr: string; isDst: boolean; offset: number; utc: Array<string>; currentTime: Date; }; } /** * Get geo information from an IP address. * * The function fetches detailed geographical and connection-related information * for a given IP address. The returned data includes properties such as continent, * country, region, city, latitude, longitude, timezone, and connection details. * * @param ip - The IP address to retrieve geo information for. * @returns A Promise resolving to an object of type `Ip` containing geo and connection details, or `null` if no data is found or something goes wrong. * * @typedef Ip * @property ip - The IP address. * @property type - The type of IP (e.g., IPv4, IPv6). * @property geo - Geographical information: * - continent: The continent name. * - continentCode: The continent code. * - country: The country name. * - countryCode: The country code. * - region: The region name. * - regionCode: The region code. * - city: The city name. * - latitude: The latitude coordinate. * - longitude: The longitude coordinate. * - isEu: Whether the location is in the European Union. * - postal: The postal code. * - callingCode: The calling code. * - capital: The capital city. * - borders: An array of bordering countries. * @property flag - Information about the country's flag: * - img: The URL of the flag image. * - emoji: The flag emoji. * - emojiUnicode: The Unicode representation of the flag emoji. * @property connection - Connection details: * - asn: The autonomous system number. * - org: The organization name. * - isp: The internet service provider. * - domain: The domain name. * @property timezone - Timezone information: * - id: The timezone ID. * - abbr: The timezone abbreviation. * - isDst: Whether daylight saving time is active. * - offset: The timezone offset in hours. * - utc: An array of UTC offsets. * - currentTime: The current time in the timezone. */ declare const GetGeoFromIP: (ip: string) => Promise<Ip | null>; export { GetGeoFromIP as default, GetGeoFromIP as getGeoFromIP }; export type { Ip };