0

Get the full information of multiple IP Addresses

by
Published Apr 8, 2025

This API enables you to retrieve information for multiple IP addresses in a single request. By using the `/lookup/ip/bulk` method, you can efficiently gather data such as location, ISP, and risk factors for a batch of IPs, saving time and streamlining your workflow for large-scale analysis.

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 multiple IP Addresses
7
 * This API enables you to retrieve information for multiple IP addresses in a single request.
8

9
By using the `/lookup/ip/bulk` method, you can efficiently gather data such as location, ISP, and risk factors for a batch of IPs, saving time and streamlining your workflow for large-scale analysis.
10
 */
11
export async function main(
12
  auth: Greip,
13
  ips: string,
14
  params: string | undefined,
15
  lang: string | undefined,
16
  format: string | undefined,
17
  mode: string | undefined,
18
  callback: string | undefined,
19
) {
20
  const url = new URL(`https://greipapi.com/lookup/ip/bulk`);
21
  for (const [k, v] of [
22
    ["ips", ips],
23
    ["params", params],
24
    ["lang", lang],
25
    ["format", format],
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