AppleMusicFeed (apple_music_feed v0.3.0)

Copy Markdown View Source

Elixir client for the Apple Music Feed API.

Access Apple Music's editorial content including:

  • Curated playlists and charts
  • Editorial stories and featured content
  • Genre-specific recommendations
  • New releases and top charts

Quick Start

AppleMusicFeed.get_charts(storefront: "us", types: ["songs", "playlists"])
AppleMusicFeed.get_featured_playlists(storefront: "us")
AppleMusicFeed.get_new_releases(storefront: "us")

Configuration

config :apple_music_feed,
  team_id: System.get_env("APPLE_TEAM_ID"),
  key_id: System.get_env("MUSIC_KEY_ID"),
  private_key: System.get_env("MUSIC_PRIVATE_KEY"),
  base_url: "https://api.music.apple.com",
  storefront: "us"

Every function also accepts per-call opts that override the application config.

Summary

Functions

Get Apple Music charts for a storefront.

Get editorial mixes/curated stations for a storefront.

Get featured playlists by their IDs.

Get all available genres.

Get new releases albums by their IDs.

Get a specific playlist by ID.

Get tracks from a specific playlist.

Get Apple Music recommendations for a storefront.

Get top songs by their IDs or use get_charts/1 for chart listings.

Return a cached Apple Music Feed access token (after JWT generation).

Types

opts()

@type opts() :: keyword()

response()

@type response() :: {:ok, map()} | {:error, term()}

Functions

get_charts(opts \\ [])

@spec get_charts(opts()) :: response()

Get Apple Music charts for a storefront.

Parameters

  • opts:
    • :storefront - Storefront code (e.g., "us", "gb", "jp")
    • :types - Chart types to retrieve ("songs", "albums", "playlists", "music-videos")
    • :genre - Optional genre ID for genre-specific charts
    • :limit - Maximum results per type (1-100)

Examples

AppleMusicFeed.get_charts(types: ["songs", "albums"])
AppleMusicFeed.get_charts(storefront: "gb", types: ["playlists"], limit: 20)

get_editorial_mixes(opts \\ [])

@spec get_editorial_mixes(opts()) :: response()

Get editorial mixes/curated stations for a storefront.

Parameters

  • opts:
    • :storefront - Storefront code
    • :limit - Maximum results (1-100, default 10)

Examples

AppleMusicFeed.get_editorial_mixes()
AppleMusicFeed.get_editorial_mixes(storefront: "us", limit: 20)

get_genres(opts \\ [])

@spec get_genres(opts()) :: response()

Get all available genres.

Parameters

  • opts:
    • :storefront - Storefront code

Examples

AppleMusicFeed.get_genres()

get_new_releases(album_ids, opts \\ [])

@spec get_new_releases([String.t()], opts()) :: response()

Get new releases albums by their IDs.

Apple Music doesn't have a "list all new releases" endpoint. Instead, you fetch specific albums by their IDs. Use charts to discover new music.

Parameters

  • album_ids - List of album IDs to fetch (required)
  • opts:
    • :storefront - Storefront code (default from config or "us")

Examples

AppleMusicFeed.get_new_releases(["310730204", "1587056230"])

get_playlist(id, opts \\ [])

@spec get_playlist(String.t(), opts()) :: response()

Get a specific playlist by ID.

Parameters

  • id - Playlist ID
  • opts:
    • :storefront - Storefront code

Examples

AppleMusicFeed.get_playlist("pl.123456789")

get_playlist_tracks(id, opts \\ [])

@spec get_playlist_tracks(String.t(), opts()) :: response()

Get tracks from a specific playlist.

Parameters

  • id - Playlist ID
  • opts:
    • :storefront - Storefront code
    • :limit - Maximum results (1-100)
    • :offset - Pagination offset

Examples

AppleMusicFeed.get_playlist_tracks("pl.123456789")

get_recommendations(opts \\ [])

@spec get_recommendations(opts()) :: response()

Get Apple Music recommendations for a storefront.

Parameters

  • opts:
    • :storefront - Storefront code
    • :limit - Maximum results (1-100, default 10)
    • :user_token - User token for personalized recommendations (optional)

Examples

AppleMusicFeed.get_recommendations()
AppleMusicFeed.get_recommendations(storefront: "us", limit: 25)

get_top_songs(song_ids, opts \\ [])

@spec get_top_songs([String.t()], opts()) :: response()

Get top songs by their IDs or use get_charts/1 for chart listings.

Apple Music doesn't have a "list all songs" endpoint. To get top songs, either fetch specific songs by ID or use the charts endpoint.

Parameters

  • song_ids - List of song IDs to fetch (required)
  • opts:
    • :storefront - Storefront code (default from config or "us")

Examples

AppleMusicFeed.get_top_songs(["900083885", "1586110551"])

See Also

`get_charts/1` - For chart-based song discovery

token(opts \\ [])

@spec token(opts()) :: {:ok, String.t()} | {:error, term()}

Return a cached Apple Music Feed access token (after JWT generation).