aipi
Version:
Get info for an IP from any echoip instance
65 lines (60 loc) • 1.52 kB
TypeScript
interface GeoInfo {
country: string;
region: string;
eu: boolean;
timezone: string;
city: string;
ll: [number, number];
}
interface UserAgent {
product: string;
version: string;
comment: string;
raw_value: string;
}
interface IPInfo {
ip: string;
ip_decimal: number;
country: string;
country_iso: string;
country_eu: boolean;
region_name: string;
region_code: string;
zip_code: string;
city: string;
latitude: number;
longitude: number;
time_zone: string;
asn: string;
asn_org: string;
user_agent: UserAgent;
hostname?: string;
}
declare class IPInfoFetcher {
instanceUrl: string;
/**
* Creates an instance of IPInfoFetcher.
* @param {string} [instanceUrl='https://ifconfig.co/json'] echoip instance URL
* @memberof IPInfoFetcher
*/
constructor(instanceUrl?: string);
/**
* Get info for an IP
* If no IP is provided, the current IP will be looked up
*
* @param {string} [ip] Optional: Custom IP to look up
* @return {Promise<IPInfo>}
* @memberof IPInfoFetcher
*/
getInfo(ip?: string): Promise<IPInfo>;
/**
* Get geographical info for an IP
* Provides almost the same data as geoip-lite
*
* @param {string} [ip] Optional: Custom IP to look up
* @return {Promise<GeoInfo>}
* @memberof IPInfoFetcher
*/
getGeo(ip?: string): Promise<GeoInfo>;
}
export { GeoInfo, IPInfo, IPInfoFetcher, UserAgent };