0

Get monthly network transfer stats

by
Published Oct 17, 2025

Returns a Linode's network transfer statistics for a specific month. The year/month values must be either a date in the past, or the current month. > --- - __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
 * Get monthly network transfer stats
7
 * Returns a Linode's network transfer statistics for a specific month. The year/month values must be either a date in the past, or the current month.
8

9

10
>
11

12
---
13

14

15
- __OAuth scopes__.
16

17
    ```
18
    linodes:read_only
19
    ```
20

21
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
22
 */
23
export async function main(
24
  auth: Linode,
25
  apiVersion: "v4" | "v4beta",
26
  linodeId: string,
27
  year: string,
28
  month: string,
29
) {
30
  const url = new URL(
31
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/transfer/${year}/${month}`,
32
  );
33

34
  const response = await fetch(url, {
35
    method: "GET",
36
    headers: {
37
      Authorization: "Bearer " + auth.token,
38
    },
39
    body: undefined,
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47