1
Get IP address insights from IPinfo - geolocation, privacy detection, company and more
One script reply has been approved by the moderators Verified

Get geolocation, privacy/VPN detection, ASN, company, carrier and other IP address data from the IPinfo.io API.

Created by devrel.ipinfo250 489 days ago Viewed 9233 times
0
Submitted by devrel.ipinfo250 Deno
Verified 489 days ago
1
// import * as wmill from 'https://deno.land/x/windmill/index.ts'
2

3
type Ipinfo {
4
    token: string
5
}
6

7
export async function main(ipinfo?: Ipinfo, ip?:string) {
8
    /**
9
     * Makes an API call to IPinfo to get IP address geolocation data and other IP data.
10
     * @param {string} token - Your IPinfo.io access token. This param is optional.
11
     * @param {string} ip - The IP address to lookup. This param is optional if you want to lookup your current IP.
12
     * @returns {object} - An object with the status and the payload.
13
     */
14
    const ipAddressInformation = await fetch(`https://ipinfo.io${ip ? '/' + ip : '' }/json?token=${ipinfo?.token || ""}`)
15

16
    return {
17
        status: ipAddressInformation.status,
18
        payload: await ipAddressInformation.json(),
19
    };
20
}
Other submissions