0

Retrieve the IP address of your visitors or users without the need for an account or API key in Greip

by
Published Apr 8, 2025

This method allows you to retrieve the IP address of your visitors or users without the need for an account or API key in Greip. It’s a quick and easy way to access IP information, making it ideal for basic integrations or when you need to capture user IPs with minimal setup.

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 the IP address of your visitors or users without the need for an account or API key in Greip
7
 * This method allows you to retrieve the IP address of your visitors or users without the need for an account or API key in Greip.
8

9
It’s a quick and easy way to access IP information, making it ideal for basic integrations or when you need to capture user IPs with minimal setup.
10
 */
11
export async function main(auth: Greip) {
12
  const url = new URL(`https://greipapi.com/ip`);
13

14
  const response = await fetch(url, {
15
    method: "GET",
16
    body: undefined,
17
  });
18
  if (!response.ok) {
19
    const text = await response.text();
20
    throw new Error(`${response.status} ${text}`);
21
  }
22
  return await response.text();
23
}
24