> ## 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.

# Library

> The authenticated user's liked songs/albums, saved movies/shows, followed artists, and playback history.

`LibraryService` is read-only and operates on the authenticated user's personal library. **All operations require an OAuth access token with the `read` scope** — there is no API-key access.

## Operations

| RPC                    | Returns                                                                            |
| ---------------------- | ---------------------------------------------------------------------------------- |
| `GetLikedItems`        | Liked **songs and albums** (filterable by content type, paginated).                |
| `CheckLikedItems`      | For a given list of IDs, whether each is liked. Use this for like-toggle UI state. |
| `GetSavedItems`        | Saved **movies and shows** (filterable, paginated).                                |
| `CheckSavedItems`      | Whether each of a list of IDs is saved.                                            |
| `GetFollowedArtists`   | Artists the user follows.                                                          |
| `CheckFollowedArtists` | Whether each of a list of artist IDs is followed.                                  |
| `GetHistory`           | Playback history (mixed content types, paginated).                                 |

## Liked vs Saved — why two verbs

Anghami uses two distinct user-intent verbs, mirrored in the API:

* **Liked** applies to **music** (songs and albums).
* **Saved** applies to **video** (movies and shows).

Calling `GetLikedItems` for a movie ID, or `GetSavedItems` for a song ID, will return nothing — the verbs and the content classes are intentionally separate. Followed artists are a third bucket.

## Toggle-state pattern

For a list view (e.g. an album's track list), don't call `GetLikedItems` and intersect — that's expensive. Use the matching `Check*` RPC instead:

```ts theme={null}
const res = await library.checkLikedItems({
  songIds: { values: trackList.map(value => ({ value })) },
});
// res.results: { [songId]: boolean }
```

`Check*` takes a typed list of IDs (`song_ids` or `album_ids` for likes; `show_ids` or `movie_ids` for saves; `artist_ids` for follows) and returns a `results` map of ID → boolean. Use it on every page render where toggle state matters.

## History

`GetHistory` returns a paginated list of [`Content`](/content-model#the-content-wrapper) wrappers — songs, episodes, movies, etc. — in reverse-chronological order of last play. Filter with `content_types` to scope to e.g. "songs only" or "shows only".

Note that history reflects what the user **acquired streams for** (per [Streaming & Billing](/streaming-billing)) — there is no separate playback report. Treat each entry as "the user started this stream at time T".

## Mutating library state

Today, **liking/unliking, saving/unsaving, and following/unfollowing happen inside the Anghami client, not via this SDK.** The library service is read-only. A `write`-scoped mutation surface is reserved for a future revision.
