0

Get details about sound effects

by
Published Oct 17, 2025

This endpoint shows information about a sound effect.

Script shutterstock Verified

The script

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