> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sdk.anghami.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Playlists

> Read playlists and the authenticated user's own playlist library.

`PlaylistService` is read-only and exposes two operations:

| RPC                | Auth                 | What it does                                            |
| ------------------ | -------------------- | ------------------------------------------------------- |
| `GetPlaylist`      | API key **or** OAuth | Fetch a playlist by `PlaylistID`, with paginated items. |
| `GetUserPlaylists` | OAuth (`read` scope) | List the authenticated user's playlists.                |

## GetPlaylist

```ts theme={null}
const res = await playlist.getPlaylist({
  id: "abc123",
  pageSize: 50,
});
```

Returns the playlist metadata (title, owner, artwork, item count) and a paginated batch of items. The items list is a slice of [`Content`](/content-model#the-content-wrapper) — playlists may contain songs, podcasts, or other supported entity kinds, so branch on the `oneof id` to render each row correctly.

`GetPlaylist` works with both API keys and OAuth tokens. With an API key you can read **public** playlists; with an OAuth token you can additionally read playlists the authenticated user has access to.

## GetUserPlaylists

```ts theme={null}
const res = await playlist.getUserPlaylists({
  pageSize: 50,
});
```

Returns the authenticated user's own playlists — created and saved. Requires the `read` OAuth scope.

## Mutating playlists

The current SDK exposes **read-only** playlist operations. Creating, editing, reordering, or deleting playlists requires the user to operate inside the Anghami app or web client. A `write`-scoped mutation surface is reserved for a future revision.

## Patterns

* **Mixed-content rendering.** Use the `Content.oneof id` arm to dispatch to the right entity-fetch (e.g. `GetSong`) when you need full detail beyond the wrapper's display fields.
* **Avoid N+1.** When rendering a playlist of N songs and you need song-level data, fetch the playlist first, then use `BatchGetSongs` with the collected IDs — one call instead of N.
* **Pagination.** Long playlists are deeply paginated. Render the first page eagerly and lazy-load on scroll.
