0

List image categories

by
Published Oct 17, 2025

This endpoint lists the categories (Shutterstock-assigned genres) that images can belong to.

Script shutterstock Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Shutterstock = {
3
  token: string;
4
};
5
/**
6
 * List image categories
7
 * This endpoint lists the categories (Shutterstock-assigned genres) that images can belong to.
8
 */
9
export async function main(
10
  auth: Shutterstock,
11
  language:
12
    | "ar"
13
    | "bg"
14
    | "bn"
15
    | "cs"
16
    | "da"
17
    | "de"
18
    | "el"
19
    | "en"
20
    | "es"
21
    | "fi"
22
    | "fr"
23
    | "gu"
24
    | "he"
25
    | "hi"
26
    | "hr"
27
    | "hu"
28
    | "id"
29
    | "it"
30
    | "ja"
31
    | "kn"
32
    | "ko"
33
    | "ml"
34
    | "mr"
35
    | "nb"
36
    | "nl"
37
    | "or"
38
    | "pl"
39
    | "pt"
40
    | "ro"
41
    | "ru"
42
    | "sk"
43
    | "sl"
44
    | "sv"
45
    | "ta"
46
    | "te"
47
    | "th"
48
    | "tr"
49
    | "uk"
50
    | "ur"
51
    | "vi"
52
    | "zh"
53
    | "zh-Hant"
54
    | undefined,
55
) {
56
  const url = new URL(`https://api.shutterstock.com/v2/images/categories`);
57
  for (const [k, v] of [["language", language]]) {
58
    if (v !== undefined && v !== "" && k !== undefined) {
59
      url.searchParams.append(k, v);
60
    }
61
  }
62
  const response = await fetch(url, {
63
    method: "GET",
64
    headers: {
65
      Authorization: "Bearer " + auth.token,
66
    },
67
    body: undefined,
68
  });
69
  if (!response.ok) {
70
    const text = await response.text();
71
    throw new Error(`${response.status} ${text}`);
72
  }
73
  return await response.json();
74
}
75