0

List orders

by
Published Apr 8, 2025

**⚠️ We no longer recommend implementing the Orders API. Please refer to the Payments API instead. We are actively working on adding support for Klarna, Billie, in3 and Vouchers to the Payments API later this year.** Retrieve all orders. The results are paginated. > 🔑 Access with > > API key > > Access token with **orders.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 orders
7
 * **⚠️ We no longer recommend implementing the Orders API. Please refer to the Payments API instead. We are actively working on adding support for Klarna, Billie, in3 and Vouchers to the Payments API later this year.**
8

9
Retrieve all orders.
10

11
The results are paginated.
12

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