ipquery
Version:
ipquery sdk for javascript
53 lines (49 loc) • 1.36 kB
text/typescript
type IPQueryJsonResponse = {
ip: string;
isp: IspInfo;
location: LocationInfo;
risk: RiskInfo;
};
type IPQueryTextResponse = string;
interface IspInfo {
asn: string;
org: string;
isp: string;
}
interface LocationInfo {
country: string;
country_code: string;
city: string;
state: string;
zipcode: string;
latitude: number;
longitude: number;
timezone: string;
localtime: string;
}
interface RiskInfo {
is_mobile: boolean;
is_vpn: boolean;
is_tor: boolean;
is_proxy: boolean;
is_datacenter: boolean;
risk_score: number;
}
type IPQueryResponseFormat = "text" | "json" | "yaml" | "xml";
type IPAddr = string & {};
type IPQueryInput = "self" | IPAddr | IPAddr[];
type IPQueryConfig = {
cache?: {
disable?: boolean;
ttl?: number;
limit?: number;
};
};
declare let config: IPQueryConfig;
declare const ip: {
config(overrides: Partial<typeof config>): void;
readonly query: <TInput extends IPQueryInput, TFormat extends IPQueryResponseFormat = "json">(input: TInput, options?: {
format?: TFormat | IPQueryResponseFormat;
}) => Promise<TInput extends string[] ? TFormat extends "json" ? IPQueryJsonResponse[] : IPQueryTextResponse[] : TFormat extends "json" ? IPQueryJsonResponse : IPQueryTextResponse>;
};
export { ip };