1

Create a public playlist

by
Published May 19, 2025

Create and return a new public playlist with the given name and description

Script spotify
  • Submitted by alec minchington932 Bun
    Created 473 days ago
    1
    import { Client } from '[email protected]';
    2
    
    
    3
    type Spotify = {
    4
      token: string;
    5
    }
    6
    
    
    7
    export async function main(
    8
      spotifyCredentials: Spotify,
    9
      playlistName: string,
    10
      playlistDescription: string = "Created by windmill",
    11
    ) {
    12
      const client = await Client.create({
    13
        token: spotifyCredentials.token,
    14
        userAuthorizedToken: true
    15
      });
    16
    
    
    17
      console.log(`Creating public playlist with name '${playlistName}'`);
    18
    
    
    19
      const newPlaylist = await client.user.createPlaylist({
    20
        name: playlistName,
    21
        description: playlistDescription
    22
      });
    23
    
    
    24
      if (!newPlaylist) {
    25
        throw new Error(`Failed to create playlist with name '${playlistName}'`);
    26
      }
    27
    
    
    28
      return newPlaylist;
    29
    }