0

Get the full information of a given IP address

by
Published Apr 8, 2025

Use this API to retrieve comprehensive information about a given IP address. It provides details such as location, ISP, and potential risk factors, enabling you to analyze and verify IP data for enhanced security, fraud prevention, and user profiling.

Script greip Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Greip = {
3
  apiKey: string;
4
};
5
/**
6
 * Get the full information of a given IP address
7
 * Use this API to retrieve comprehensive information about a given IP address. It provides details such as location, ISP, and potential risk factors, enabling you to analyze and verify IP data for enhanced security, fraud prevention, and user profiling.
8
 */
9
export async function main(
10
  auth: Greip,
11
  ip: string,
12
  params: string | undefined,
13
  lang: string | undefined,
14
  format: string | undefined,
15
  userID: string | undefined,
16
  mode: string | undefined,
17
  callback: string | undefined,
18
) {
19
  const url = new URL(`https://greipapi.com/lookup/ip`);
20
  for (const [k, v] of [
21
    ["ip", ip],
22
    ["params", params],
23
    ["lang", lang],
24
    ["format", format],
25
    ["userID", userID],
26
    ["mode", mode],
27
    ["callback", callback],
28
  ]) {
29
    if (v !== undefined && v !== "" && k !== undefined) {
30
      url.searchParams.append(k, v);
31
    }
32
  }
33
  const response = await fetch(url, {
34
    method: "GET",
35
    headers: {
36
      Authorization: "Bearer " + auth.apiKey,
37
    },
38
    body: undefined,
39
  });
40
  if (!response.ok) {
41
    const text = await response.text();
42
    throw new Error(`${response.status} ${text}`);
43
  }
44
  return await response.text();
45
}
46