0

List a VPC's IP addresses

by
Published Oct 17, 2025

Returns a paginated list of IP addresses for a single VPC. > --- - __CLI__. ``` linode-cli vpcs ip-list 123 ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) - __OAuth scopes__. ``` ips:read_only ``` [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * List a VPC's IP addresses
7
 * Returns a paginated list of IP addresses for a single VPC.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli vpcs ip-list 123
19
    ```
20

21
    [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)
22

23
- __OAuth scopes__.
24

25
    ```
26
    ips:read_only
27
    ```
28

29
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
30
 */
31
export async function main(
32
  auth: Linode,
33
  apiVersion: "v4" | "v4beta",
34
  vpcId: string,
35
  page: string | undefined,
36
  page_size: string | undefined,
37
) {
38
  const url = new URL(`https://api.linode.com/${apiVersion}/vpcs/${vpcId}/ips`);
39
  for (const [k, v] of [
40
    ["page", page],
41
    ["page_size", page_size],
42
  ]) {
43
    if (v !== undefined && v !== "" && k !== undefined) {
44
      url.searchParams.append(k, v);
45
    }
46
  }
47
  const response = await fetch(url, {
48
    method: "GET",
49
    headers: {
50
      Authorization: "Bearer " + auth.token,
51
    },
52
    body: undefined,
53
  });
54
  if (!response.ok) {
55
    const text = await response.text();
56
    throw new Error(`${response.status} ${text}`);
57
  }
58
  return await response.json();
59
}
60