0

List disks

by
Published Oct 17, 2025

View Disk information for Disks associated with this Linode. > --- - __CLI__. ``` linode-cli linodes disks-list 123 ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) - __OAuth scopes__. ``` linodes: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 disks
7
 * View Disk information for Disks associated with this Linode.
8

9

10
>
11

12
---
13

14

15
- __CLI__.
16

17
    ```
18
    linode-cli linodes disks-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
    linodes: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
  linodeId: string,
35
  page: string | undefined,
36
  page_size: string | undefined,
37
) {
38
  const url = new URL(
39
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/disks`,
40
  );
41
  for (const [k, v] of [
42
    ["page", page],
43
    ["page_size", page_size],
44
  ]) {
45
    if (v !== undefined && v !== "" && k !== undefined) {
46
      url.searchParams.append(k, v);
47
    }
48
  }
49
  const response = await fetch(url, {
50
    method: "GET",
51
    headers: {
52
      Authorization: "Bearer " + auth.token,
53
    },
54
    body: undefined,
55
  });
56
  if (!response.ok) {
57
    const text = await response.text();
58
    throw new Error(`${response.status} ${text}`);
59
  }
60
  return await response.json();
61
}
62