0

List all public integrations

by
Published Oct 17, 2025
Script gitbook Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Gitbook = {
3
  token: string;
4
};
5
/**
6
 * List all public integrations
7
 *
8
 */
9
export async function main(
10
  auth: Gitbook,
11
  page: string | undefined,
12
  limit: string | undefined,
13
  search: string | undefined,
14
  category:
15
    | "analytics"
16
    | "collaboration"
17
    | "content"
18
    | "gitsync"
19
    | "marketing"
20
    | "visitor-auth"
21
    | "other"
22
    | undefined,
23
  blockDomain: string | undefined,
24
  blocks: string | undefined,
25
  contentSources: string | undefined,
26
  owner: string | undefined,
27
  scope:
28
    | "space:views:read"
29
    | "space:content:read"
30
    | "space:content:write"
31
    | "space:metadata:read"
32
    | "space:metadata:write"
33
    | "space:script:inject"
34
    | "space:script:cookies"
35
    | "space:git:sync"
36
    | "space:visitor:auth"
37
    | "site:metadata:read"
38
    | "site:views:read"
39
    | "site:script:inject"
40
    | "site:script:cookies"
41
    | "site:visitor:auth"
42
    | "site:adaptive:read"
43
    | "site:adaptive:write"
44
    | "openapi:read"
45
    | "openapi:write"
46
    | "conversations:ingest"
47
    | undefined,
48
  target: "all" | "site" | "space" | "organization" | undefined,
49
) {
50
  const url = new URL(`https://api.gitbook.com/v1/integrations`);
51
  for (const [k, v] of [
52
    ["page", page],
53
    ["limit", limit],
54
    ["search", search],
55
    ["category", category],
56
    ["blockDomain", blockDomain],
57
    ["blocks", blocks],
58
    ["contentSources", contentSources],
59
    ["owner", owner],
60
    ["scope", scope],
61
    ["target", target],
62
  ]) {
63
    if (v !== undefined && v !== "" && k !== undefined) {
64
      url.searchParams.append(k, v);
65
    }
66
  }
67
  const response = await fetch(url, {
68
    method: "GET",
69
    headers: {
70
      Authorization: "Bearer " + auth.token,
71
    },
72
    body: undefined,
73
  });
74
  if (!response.ok) {
75
    const text = await response.text();
76
    throw new Error(`${response.status} ${text}`);
77
  }
78
  return await response.json();
79
}
80