0

List terminals

by
Published Apr 8, 2025

Retrieve a list of all physical point-of-sale devices. The results are paginated. > 🔑 Access with > > API key > > Access token with **terminals.read**

Script mollie Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Mollie = {
3
  token: string;
4
};
5
/**
6
 * List terminals
7
 * Retrieve a list of all physical point-of-sale devices.
8

9
The results are paginated.
10

11
> 🔑 Access with
12
>
13
> API key
14
>
15
> Access token with **terminals.read**
16
 */
17
export async function main(
18
  auth: Mollie,
19
  from: string | undefined,
20
  limit: string | undefined,
21
  sort: string | undefined,
22
  testmode: string | undefined,
23
) {
24
  const url = new URL(`https://api.mollie.com/v2/terminals`);
25
  for (const [k, v] of [
26
    ["from", from],
27
    ["limit", limit],
28
    ["sort", sort],
29
    ["testmode", testmode],
30
  ]) {
31
    if (v !== undefined && v !== "" && k !== undefined) {
32
      url.searchParams.append(k, v);
33
    }
34
  }
35
  const response = await fetch(url, {
36
    method: "GET",
37
    headers: {
38
      Authorization: "Bearer " + auth.token,
39
    },
40
    body: undefined,
41
  });
42
  if (!response.ok) {
43
    const text = await response.text();
44
    throw new Error(`${response.status} ${text}`);
45
  }
46
  return await response.text();
47
}
48