---
layout: "layouts/DocLayout.astro"
title: The PlaylistEndpoint
description: ""
order: 8
---

The PlaylistEndpoint is used to fetch playlist information and do track-related actions. In the `src/segments/playlist.ht` file you can find all the
required method definitions.

```hetu_script
class PlaylistEndpoint {
  var client: HttpClient

  construct (this.client)

  fun getPlaylist(id: string) {
    // TODO: Implement method
  }

  fun tracks(id: string, { offset: int, limit: int }) {
    // TODO: Implement method
  }

  fun create(userId: string, {
    name: string,
    description: string,
    public: bool,
    collaborative: bool
  }) {
    // TODO: Implement method
  }

  fun update(playlistId: string, {
    name: string,
    description: string,
    public: bool,
    collaborative: bool
  }) {
    // TODO: Implement method
  }

  fun deletePlaylist(playlistId: string) {
    // TODO: Implement method
  }

  fun addTracks(playlistId: string, { trackIds: List, position: int }) {
    // TODO: Implement method
  }


  fun removeTracks(playlistId: string, { trackIds: List }) {
    // TODO: Implement method
  }

  fun save(playlistId: string) {
    // TODO: Implement method
  }

  fun unsave(playlistId: string) {
    // TODO: Implement method
  }
}
```

| Method           | Description                                 | Returns                                                                                                                    |
| ---------------- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `getPlaylist`    | Fetches a playlist by its ID.               | [`SpotubeFullPlaylistObject`][SpotubeFullPlaylistObject]                                                                   |
| `tracks`         | Fetches tracks in a playlist.               | [`SpotubePaginationResponseObject`][SpotubePaginationResponseObject] of [`SpotubeFullTrackObject`][SpotubeFullTrackObject] |
| `create`         | Creates a new playlist and returns          | [`SpotubeFullPlaylistObject`][SpotubeFullPlaylistObject]                                                                   |
| `update`         | Updates an existing playlist.               | `void`                                                                                                                     |
| `deletePlaylist` | Deletes a playlist.                         | `void`                                                                                                                     |
| `addTracks`      | Adds tracks to a playlist.                  | `void`                                                                                                                     |
| `removeTracks`   | Removes tracks from a playlist.             | `void`                                                                                                                     |
| `save`           | Saves a playlist to the user's library.     | `void`                                                                                                                     |
| `unsave`         | Removes a playlist from the user's library. | `void`                                                                                                                     |

{/* Urls */}
[SpotubePaginationResponseObject]: /docs/models/spotube-pagination-response-object
[SpotubeFullPlaylistObject]: /docs/models/spotube-playlist-object#spotubefullplaylistobject
[SpotubeFullTrackObject]: /docs/models/spotube-track-object
