0

Search for sound effects

by
Published Oct 17, 2025

This endpoint searches for sound effects. If you specify more than one search parameter, the API uses an AND condition.

Script shutterstock Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Shutterstock = {
3
  token: string;
4
};
5
/**
6
 * Search for sound effects
7
 * This endpoint searches for sound effects. If you specify more than one search parameter, the API uses an AND condition.
8
 */
9
export async function main(
10
  auth: Shutterstock,
11
  added_date: string | undefined,
12
  added_date_start: string | undefined,
13
  added_date_end: string | undefined,
14
  duration: string | undefined,
15
  duration_from: string | undefined,
16
  duration_to: string | undefined,
17
  page: string | undefined,
18
  per_page: string | undefined,
19
  query: string | undefined,
20
  safe: string | undefined,
21
  sort: "popular" | "newest" | "relevance" | "random" | "oldest" | undefined,
22
  view: "minimal" | "full" | undefined,
23
  language:
24
    | "ar"
25
    | "bg"
26
    | "bn"
27
    | "cs"
28
    | "da"
29
    | "de"
30
    | "el"
31
    | "en"
32
    | "es"
33
    | "fi"
34
    | "fr"
35
    | "gu"
36
    | "he"
37
    | "hi"
38
    | "hr"
39
    | "hu"
40
    | "id"
41
    | "it"
42
    | "ja"
43
    | "kn"
44
    | "ko"
45
    | "ml"
46
    | "mr"
47
    | "nb"
48
    | "nl"
49
    | "or"
50
    | "pl"
51
    | "pt"
52
    | "ro"
53
    | "ru"
54
    | "sk"
55
    | "sl"
56
    | "sv"
57
    | "ta"
58
    | "te"
59
    | "th"
60
    | "tr"
61
    | "uk"
62
    | "ur"
63
    | "vi"
64
    | "zh"
65
    | "zh-Hant"
66
    | undefined,
67
) {
68
  const url = new URL(`https://api.shutterstock.com/v2/sfx/search`);
69
  for (const [k, v] of [
70
    ["added_date", added_date],
71
    ["added_date_start", added_date_start],
72
    ["added_date_end", added_date_end],
73
    ["duration", duration],
74
    ["duration_from", duration_from],
75
    ["duration_to", duration_to],
76
    ["page", page],
77
    ["per_page", per_page],
78
    ["query", query],
79
    ["safe", safe],
80
    ["sort", sort],
81
    ["view", view],
82
    ["language", language],
83
  ]) {
84
    if (v !== undefined && v !== "" && k !== undefined) {
85
      url.searchParams.append(k, v);
86
    }
87
  }
88
  const response = await fetch(url, {
89
    method: "GET",
90
    headers: {
91
      Authorization: "Bearer " + auth.token,
92
    },
93
    body: undefined,
94
  });
95
  if (!response.ok) {
96
    const text = await response.text();
97
    throw new Error(`${response.status} ${text}`);
98
  }
99
  return await response.json();
100
}
101