Reference / @open-music-sdk/types
@open-music-sdk/types
You probably don't want this package. Most apps install one integration and import everything from it: see Which package to install in the repository's README.
TypeScript types for every object in the Apple Music API, generated from Apple's documentation. The package has no dependencies and no runtime: it ships type declarations and nothing that runs.
Most apps install server, browser or react instead, which re-export every type. Use this one to build your own client, or to type code that holds Apple's objects.
Installation
pnpm add -D @open-music-sdk/typesDocumentation
- The documentation site: guides for each client and server, concepts, and the reference
- Reference for this package
- Validate Apple's responses, for checking a value against its type at runtime
- Differences from Apple's documentation
- Which package to install
Example
Anywhere, since it's types only:
import type { tAnyResource } from "@open-music-sdk/types";
function title(resource: tAnyResource): string {
switch (resource.type) {
case "songs":
case "albums":
return resource.attributes?.name ?? "";
// ...every other resource type is a member of the union
default:
return "";
}
}What's in it
| Export | What it is |
|---|---|
tSong, tAlbum, ... | Resource objects: id, type, href, attributes, relationships |
tSongAttributes, ... | Each resource's attributes |
tSongRelationships, ... | Each resource's relationships, and each relationship's envelope |
tArtwork, tPlayParameters, tPreview, ... | Shared dictionaries |
tSongsResponse, tErrorsResponse, ... | Response envelopes |
tAnyResource | The union of every resource, told apart by type |
tResourceType | tAnyResource["type"], the union of every resource's type |
Each property keeps Apple's description as its doc comment, so your editor shows Apple's wording. Where the type differs from it, as below, the comment says so after Apple's words.
exports points at dist/index.d.ts: every type in one declaration file that imports nothing, so it reads the same whether your moduleResolution is bundler, node16 or nodenext. The dist/index.js beside it is empty. To check a value at runtime, use @open-music-sdk/validate.
The source is written by codegen, which says how to regenerate it.
Names
A name is Apple's dictionary name with the dots removed and a t in front, in the singular where the object is a single thing. Apple documents one song as Songs, the value of its type, so the page Songs.Attributes is tSongAttributes here. A collection keeps the plural: tSongsResponse wraps data: tSong[].
How Apple's types map
integerandnumberarenumber;objectisRecord<string, unknown>.- A property with an
allowedValueslist is a union of string literals, such as"clean" | "explicit". - A property Apple marks as not required is optional. Extended attributes are always optional, since they arrive only when you ask for them with
extend. - Four that Apple marks as required are optional, because Apple left them out against the live API on 18 October 2026:
- a view's own
attributes, which come only when asked for, and only on the first page; durationInMillisof a song and of a music video;artistNameof an album in the listener's library;artworkof an album in the listener's library.
- a view's own
- A dictionary Apple documents with no properties is
Record<string, unknown>.
Interfaces
- tActivitiesResponse
- tActivity
- tActivityAttributes
- tActivityRelationships
- tActivityRelationshipsActivityPlaylistsRelationship
- tAlbum
- tAlbumAttributes
- tAlbumPeriodSummary
- tAlbumPeriodSummaryRelationships
- tAlbumPeriodSummaryRelationshipsAlbumPeriodSummaryAlbumRelationship
- tAlbumRelationships
- tAlbumRelationshipsAlbumArtistsRelationship
- tAlbumRelationshipsAlbumGenresRelationship
- tAlbumRelationshipsAlbumLibraryRelationship
- tAlbumRelationshipsAlbumRecordLabelsRelationship
- tAlbumRelationshipsAlbumTracksRelationship
- tAlbumsResponse
- tAlbumViews
- tAlbumViewsAlbumAppearsOnView
- tAlbumViewsAlbumAppearsOnViewAttributes
- tAlbumViewsAlbumOtherVersionsView
- tAlbumViewsAlbumOtherVersionsViewAttributes
- tAlbumViewsAlbumRelatedAlbumsView
- tAlbumViewsAlbumRelatedAlbumsViewAttributes
- tAlbumViewsAlbumRelatedVideosView
- tAlbumViewsAlbumRelatedVideosViewAttributes
- tAppleCurator
- tAppleCuratorAttributes
- tAppleCuratorRelationships
- tAppleCuratorRelationshipsAppleCuratorPlaylistsRelationship
- tAppleCuratorsResponse
- tArtist
- tArtistAttributes
- tArtistPeriodSummary
- tArtistPeriodSummaryRelationships
- tArtistPeriodSummaryRelationshipsArtistPeriodSummaryArtistRelationship
- tArtistRelationships
- tArtistRelationshipsArtistAlbumsRelationship
- tArtistRelationshipsArtistGenresRelationship
- tArtistRelationshipsArtistMusicVideosRelationship
- tArtistRelationshipsArtistPlaylistsRelationship
- tArtistRelationshipsArtistStationRelationship
- tArtistsResponse
- tArtistViews
- tArtistViewsArtistAppearsOnAlbumsView
- tArtistViewsArtistAppearsOnAlbumsViewAttributes
- tArtistViewsArtistCompilationAlbumsView
- tArtistViewsArtistCompilationAlbumsViewAttributes
- tArtistViewsArtistFeaturedAlbumsView
- tArtistViewsArtistFeaturedAlbumsViewAttributes
- tArtistViewsArtistFeaturedMusicVideosView
- tArtistViewsArtistFeaturedMusicVideosViewAttributes
- tArtistViewsArtistFeaturedPlaylistsView
- tArtistViewsArtistFeaturedPlaylistsViewAttributes
- tArtistViewsArtistFullAlbumsView
- tArtistViewsArtistFullAlbumsViewAttributes
- tArtistViewsArtistLatestReleaseView
- tArtistViewsArtistLatestReleaseViewAttributes
- tArtistViewsArtistLiveAlbumsView
- tArtistViewsArtistLiveAlbumsViewAttributes
- tArtistViewsArtistSimilarArtistsView
- tArtistViewsArtistSimilarArtistsViewAttributes
- tArtistViewsArtistSinglesView
- tArtistViewsArtistSinglesViewAttributes
- tArtistViewsArtistTopMusicVideosView
- tArtistViewsArtistTopMusicVideosViewAttributes
- tArtistViewsArtistTopSongsView
- tArtistViewsArtistTopSongsViewAttributes
- tArtwork
- tChartResponse
- tChartResponseResults
- tChartResponseResultsAlbumsChart
- tChartResponseResultsMusicVideosChart
- tChartResponseResultsPlaylistsChart
- tChartResponseResultsSongsChart
- tCurator
- tCuratorAttributes
- tCuratorRelationships
- tCuratorRelationshipsCuratorPlaylistsRelationship
- tCuratorsResponse
- tDescriptionAttribute
- tEditorialNotes
- tError
- tErrorSource
- tErrorsResponse
- tForbiddenResponse
- tGenre
- tGenreAttributes
- tGenresResponse
- tLangageTagResponse
- tLangageTagResponseResults
- tLibraryAlbum
- tLibraryAlbumAttributes
- tLibraryAlbumRelationships
- tLibraryAlbumRelationshipsLibraryAlbumArtistsRelationship
- tLibraryAlbumRelationshipsLibraryAlbumCatalogRelationship
- tLibraryAlbumRelationshipsLibraryAlbumTracksRelationship
- tLibraryAlbumsResponse
- tLibraryArtist
- tLibraryArtistAttributes
- tLibraryArtistRelationships
- tLibraryArtistRelationshipsLibraryArtistAlbumsRelationship
- tLibraryArtistRelationshipsLibraryArtistCatalogRelationship
- tLibraryArtistsResponse
- tLibraryMusicVideo
- tLibraryMusicVideoAttributes
- tLibraryMusicVideoRelationships
- tLibraryMusicVideoRelationshipsLibraryMusicVideoAlbumsRelationship
- tLibraryMusicVideoRelationshipsLibraryMusicVideoArtistsRelationship
- tLibraryMusicVideoRelationshipsLibraryMusicVideoCatalogRelationship
- tLibraryMusicVideosResponse
- tLibraryPlaylist
- tLibraryPlaylistAttributes
- tLibraryPlaylistCreationRequest
- tLibraryPlaylistCreationRequestAttributes
- tLibraryPlaylistCreationRequestRelationships
- tLibraryPlaylistCreationRequestRelationshipsParent
- tLibraryPlaylistCreationRequestRelationshipsParentData
- tLibraryPlaylistCreationRequestRelationshipsTracks
- tLibraryPlaylistCreationRequestRelationshipsTracksData
- tLibraryPlaylistFolder
- tLibraryPlaylistFolderAttributes
- tLibraryPlaylistFolderCreationRequest
- tLibraryPlaylistFolderCreationRequestAttributes
- tLibraryPlaylistFolderCreationRequestRelationships
- tLibraryPlaylistFolderCreationRequestRelationshipsParent
- tLibraryPlaylistFolderCreationRequestRelationshipsParentData
- tLibraryPlaylistFolderRelationships
- tLibraryPlaylistFolderRelationshipsLibraryPlaylistFolderChildrenRelationship
- tLibraryPlaylistFolderRelationshipsLibraryPlaylistFolderParentRelationship
- tLibraryPlaylistFoldersResponse
- tLibraryPlaylistRelationships
- tLibraryPlaylistRelationshipsLibraryPlaylistCatalogRelationship
- tLibraryPlaylistRelationshipsLibraryPlaylistTracksRelationship
- tLibraryPlaylistsResponse
- tLibraryPlaylistsTracksRelationshipResponse
- tLibraryPlaylistTracksRequest
- tLibraryPlaylistTracksRequestData
- tLibrarySearchResponse
- tLibrarySearchResponseResults
- tLibrarySearchResponseResultsLibraryAlbumsSearchResult
- tLibrarySearchResponseResultsLibraryArtistsSearchResult
- tLibrarySearchResponseResultsLibraryMusicVideosSearchResult
- tLibrarySearchResponseResultsLibraryPlaylistsSearchResult
- tLibrarySearchResponseResultsLibrarySongsSearchResult
- tLibrarySong
- tLibrarySongAttributes
- tLibrarySongRelationships
- tLibrarySongRelationshipsLibrarySongAlbumsRelationship
- tLibrarySongRelationshipsLibrarySongArtistsRelationship
- tLibrarySongRelationshipsLibrarySongCatalogRelationship
- tLibrarySongsResponse
- tMusicSummariesResponse
- tMusicSummary
- tMusicSummaryAttributes
- tMusicSummaryViews
- tMusicSummaryViewsTopAlbumsView
- tMusicSummaryViewsTopArtistsView
- tMusicSummaryViewsTopSongsView
- tMusicVideo
- tMusicVideoAttributes
- tMusicVideoRelationships
- tMusicVideoRelationshipsMusicVideoAlbumsRelationship
- tMusicVideoRelationshipsMusicVideoArtistsRelationship
- tMusicVideoRelationshipsMusicVideoGenresRelationship
- tMusicVideoRelationshipsMusicVideoLibraryRelationship
- tMusicVideoRelationshipsMusicVideoSongsRelationship
- tMusicVideosResponse
- tMusicVideoViews
- tMusicVideoViewsMusicVideoMoreByArtistView
- tMusicVideoViewsMusicVideoMoreByArtistViewAttributes
- tMusicVideoViewsMusicVideoMoreInGenreView
- tMusicVideoViewsMusicVideoMoreInGenreViewAttributes
- tPaginatedResourceCollectionResponse
- tPersonalRecommendation
- tPersonalRecommendationAttributes
- tPersonalRecommendationAttributesReason
- tPersonalRecommendationAttributesTitle
- tPersonalRecommendationRelationships
- tPersonalRecommendationRelationshipsPersonalRecommendationContentsRelationship
- tPersonalRecommendationResponse
- tPlaylist
- tPlaylistAttributes
- tPlaylistRelationships
- tPlaylistRelationshipsPlaylistCuratorRelationship
- tPlaylistRelationshipsPlaylistLibraryRelationship
- tPlaylistRelationshipsPlaylistTracksRelationship
- tPlaylistsResponse
- tPlaylistViews
- tPlaylistViewsPlaylistFeaturedArtistsView
- tPlaylistViewsPlaylistFeaturedArtistsViewAttributes
- tPlaylistViewsPlaylistMoreByCuratorView
- tPlaylistViewsPlaylistMoreByCuratorViewAttributes
- tPlayParameters
- tPreview
- tRating
- tRatingAttributes
- tRatingRelationships
- tRatingRelationshipsRatingContentRelationship
- tRatingRequest
- tRatingRequestAttributes
- tRatingsResponse
- tRecordLabel
- tRecordLabelAttributes
- tRecordLabelsResponse
- tRecordLabelViews
- tRecordLabelViewsRecordLabelLatestReleasesView
- tRecordLabelViewsRecordLabelLatestReleasesViewAttributes
- tRecordLabelViewsRecordLabelTopReleasesView
- tRecordLabelViewsRecordLabelTopReleasesViewAttributes
- tRelationship
- tRelationshipResponse
- tRelationshipViewResponse
- tResource
- tResourceCollectionResponse
- tResourceRelationships
- tResourceViews
- tSearchHintsResponse
- tSearchHintsResponseResults
- tSearchResponse
- tSearchResponseResults
- tSearchResponseResultsActivitiesSearchResult
- tSearchResponseResultsAlbumsSearchResult
- tSearchResponseResultsAppleCuratorsSearchResult
- tSearchResponseResultsArtistsSearchResult
- tSearchResponseResultsCuratorsSearchResult
- tSearchResponseResultsMusicVideosSearchResult
- tSearchResponseResultsPlaylistsSearchResult
- tSearchResponseResultsRecordLabelsSearchResult
- tSearchResponseResultsSongsSearchResult
- tSearchResponseResultsStationsSearchResult
- tSearchResponseResultsTopResultsSearchResult
- tSearchSuggestionsResponse
- tSearchSuggestionsResponseResults
- tSearchSuggestionsResponseResultsTermSuggestion
- tSearchSuggestionsResponseResultsTopResultSuggestion
- tSong
- tSongAttributes
- tSongPeriodSummary
- tSongPeriodSummaryRelationships
- tSongPeriodSummaryRelationshipsSongPeriodSummarySongRelationship
- tSongRelationships
- tSongRelationshipsSongAlbumsRelationship
- tSongRelationshipsSongArtistsRelationship
- tSongRelationshipsSongComposersRelationship
- tSongRelationshipsSongGenresRelationship
- tSongRelationshipsSongLibraryRelationship
- tSongRelationshipsSongMusicVideosRelationship
- tSongRelationshipsSongStationRelationship
- tSongsResponse
- tStation
- tStationAttributes
- tStationGenre
- tStationGenreAttributes
- tStationGenreRelationships
- tStationGenreRelationshipsStationGenreStationsRelationship
- tStationGenresResponse
- tStationRelationships
- tStationRelationshipsStationRadioShowRelationship
- tStationsResponse
- tStorefront
- tStorefrontAttributes
- tStorefrontsResponse
- tView