0

List audio licenses

by
Published Oct 17, 2025

This endpoint lists existing licenses. You can filter the results according to the track ID to see if you have an existing license for a specific track.

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 audio licenses
7
 * This endpoint lists existing licenses. You can filter the results according to the track ID to see if you have an existing license for a specific track.
8
 */
9
export async function main(
10
  auth: Shutterstock,
11
  audio_id: string | undefined,
12
  license: string | undefined,
13
  page: string | undefined,
14
  per_page: string | undefined,
15
  sort: "newest" | "oldest" | undefined,
16
  username: string | undefined,
17
  start_date: string | undefined,
18
  end_date: string | undefined,
19
  download_availability:
20
    | "all"
21
    | "downloadable"
22
    | "non_downloadable"
23
    | undefined,
24
  team_history: string | undefined,
25
) {
26
  const url = new URL(`https://api.shutterstock.com/v2/audio/licenses`);
27
  for (const [k, v] of [
28
    ["audio_id", audio_id],
29
    ["license", license],
30
    ["page", page],
31
    ["per_page", per_page],
32
    ["sort", sort],
33
    ["username", username],
34
    ["start_date", start_date],
35
    ["end_date", end_date],
36
    ["download_availability", download_availability],
37
    ["team_history", team_history],
38
  ]) {
39
    if (v !== undefined && v !== "" && k !== undefined) {
40
      url.searchParams.append(k, v);
41
    }
42
  }
43
  const response = await fetch(url, {
44
    method: "GET",
45
    headers: {
46
      Authorization: "Bearer " + auth.token,
47
    },
48
    body: undefined,
49
  });
50
  if (!response.ok) {
51
    const text = await response.text();
52
    throw new Error(`${response.status} ${text}`);
53
  }
54
  return await response.json();
55
}
56