0

Retrieve threat intelligence information for a given IP address

by
Published Apr 8, 2025

Access comprehensive threat intelligence data linked to a specific IP address. This endpoint provides insights into malicious activity, reputation scoring, and potential security risks associated with the IP address.

Script greip Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Greip = {
3
  apiKey: string;
4
};
5
/**
6
 * Retrieve threat intelligence information for a given IP address
7
 * Access comprehensive threat intelligence data linked to a specific IP address. This endpoint provides insights into malicious activity, reputation scoring, and potential security risks associated with the IP address.
8
 */
9
export async function main(
10
  auth: Greip,
11
  ip: string,
12
  format: string | undefined,
13
  userID: string | undefined,
14
  mode: string | undefined,
15
  callback: string | undefined,
16
) {
17
  const url = new URL(`https://greipapi.com/lookup/ip/threats`);
18
  for (const [k, v] of [
19
    ["ip", ip],
20
    ["format", format],
21
    ["userID", userID],
22
    ["mode", mode],
23
    ["callback", callback],
24
  ]) {
25
    if (v !== undefined && v !== "" && k !== undefined) {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "GET",
31
    headers: {
32
      Authorization: "Bearer " + auth.apiKey,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.text();
41
}
42