/apple_music

A ruby wrapper for the Apple Music API

Primary LanguageRubyMIT LicenseMIT

AppleMusic

This is a ruby wrapper for the Apple Music API.

Installation

Add this line to your application's Gemfile:

gem 'apple_music'

And then execute:

$ bundle

Or install it yourself as:

$ gem install apple_music

Usage

AppleMusic gem was designed with usability as its primary goal:

e.g. Search Artists

artist = AppleMusic::Artist.search('Men I Trust').first # AppleMusic::Artist object
artist.genre_names # ['Electronic']
artist.id # "886240553"
albums = AppleMusic::Artist.related_albums(886240553).map(&:name) # ["Oncle Jazz", "Headroom"...

e.g. Search Albums

albums = AppleMusic::Album.search('BILL EVANS') # AppleMusic::Album object
tracks = AppleMusic::Album.related_tracks(albums[0].id)
tracks.first.name # "Waltz for Debby"

e.g. Search Songs

songs = AppleMusic::Song.search('Document', storefront: :jp) # AppleMusic::Song object
songs[0].artist_name # "TENDRE"
songs[0].album_name # "NOT IN ALMIGHTY"

Features

Currently, it work in progress, so it can use apis which does not need user token.

Albums

Feature Status Docs Code
Get a Catalog Album ✅ 🔗 :octocat:
Get a Catalog Album's Relationship Directly by Name ✅ 🔗 :octocat:
Get Multiple Catalog Albums ✅ 🔗 :octocat:
Get a Library Album ⛔ 🔗
Get a Library Album's Relationship Directly by Name ⛔ 🔗
Get Multiple Library Albums ⛔ 🔗
Get All Library Albums ⛔ 🔗

Artists

Feature Status Docs Code
Get a Catalog Artist ✅ 🔗 :octocat:
Get Multiple Catalog Artists ✅ 🔗 :octocat:
Get a Catalog Artist's Relationship Directly by Name ✅ 🔗 :octocat:
Get a Library Artist ⛔ 🔗
Get All Library Artists ⛔ 🔗
Get Multiple Library Artists ⛔ 🔗
Get a Library Artist's Relationship Directly by Name ⛔ 🔗

Songs

Feature Status Docs Code
Get a Catalog Song ✅ 🔗 :octocat:
Get Multiple Catalog Songs by ID ✅ 🔗 :octocat:
Get Multiple Catalog Songs by ISRC ✅ 🔗 :octocat:
Get a Catalog Song's Relationship Directly by Name ✅ 🔗 :octocat:
Get a Library Song ⛔ 🔗
Get All Library Songs ⛔ 🔗
Get Multiple Library Songs ⛔ 🔗
Get a Library Song's Relationship Directly by Name ⛔ 🔗

Music Videos

Feature Status Docs Code
Get a Catalog Music Video ✅ 🔗 :octocat:
Get a Catalog Music Video's Relationship Directly by Name ✅ 🔗 :octocat:
Get Multiple Catalog Music Videos by ID ✅ 🔗 :octocat:
Get Multiple Catalog Music Videos by ISRC ✅ 🔗 :octocat:
Get a Library Music Video ⛔ 🔗
Get a Library Music Video's Relationship Directly by Name ⛔ 🔗
Get Multiple Library Music Videos ⛔ 🔗
Get All Library Music Videos ⛔ 🔗

Playlists

Feature Status Docs Code
Get a Catalog Playlist ✅ 🔗 :octocat:
Get a Catalog Playlist's Relationship Directly by Name ✅ 🔗 :octocat:
Get Multiple Catalog Playlists ✅ 🔗 :octocat:
Get a Library Playlist ⛔ 🔗
Get a Library Playlist's Relationship Directly by Name ⛔ 🔗
Get Multiple Library Playlists ⛔ 🔗
Get All Library Playlists ⛔ 🔗

Apple Music Stations

Feature Status Docs Code
Get a Catalog Station ✅ 🔗 :octocat:
Get Multiple Catalog Stations ✅ 🔗 :octocat:

Search

Feature Status Docs Code
Search for Catalog Resources ✅ 🔗 :octocat:
Get Catalog Search Hints ✅ 🔗 :octocat:
Search for Library Resources ⛔ 🔗

Ratings

Feature Status Docs Code
Get a Personal Album Rating ⛔ 🔗
Get a Personal Music Video Rating ⛔ 🔗
Get a Personal Playlist Rating ⛔ 🔗
Get a Personal Song Rating ⛔ 🔗
Get a Personal Station Rating ⛔ 🔗
Get Multiple Personal Album Ratings ⛔ 🔗
Get Multiple Personal Music Video Ratings ⛔ 🔗
Get Multiple Personal Playlist Ratings ⛔ 🔗
Get Multiple Personal Song Ratings ⛔ 🔗
Get Multiple Personal Station Ratings ⛔ 🔗
Add a Personal Album Rating ⛔ 🔗
Add a Personal Music Video Rating ⛔ 🔗
Add a Personal Playlist Rating ⛔ 🔗
Add a Personal Song Rating ⛔ 🔗
Add a Personal Station Rating ⛔ 🔗
Delete a Personal Album Rating ⛔ 🔗
Delete a Personal Music Video Rating ⛔ 🔗
Delete a Personal Playlist Rating ⛔ 🔗
Delete a Personal Song Rating ⛔ 🔗
Delete a Personal Station Rating ⛔ 🔗
Get a Personal Library Music Video Rating ⛔ 🔗
Get a Personal Library Playlist Rating ⛔ 🔗
Get a Personal Library Song Rating ⛔ 🔗
Get Multiple Personal Library Music Video Ratings ⛔ 🔗
Get Multiple Personal Library Playlist Ratings ⛔ 🔗
Get Multiple Personal Library Songs Ratings ⛔ 🔗
Add a Personal Library Music Video Rating ⛔ 🔗
Add a Personal Library Playlist Rating ⛔ 🔗
Add a Personal Library Song Rating ⛔ 🔗
Delete a Personal Library Music Video Rating ⛔ 🔗
Delete a Personal Library Playlist Rating ⛔ 🔗
Delete a Personal Library Song Rating ⛔ 🔗

Charts

Feature Status Docs Code
Get Catalog Charts ✅ 🔗 :octocat:

Music Genres

Feature Status Docs Code
Get a Catalog Genre ✅ 🔗 :octocat:
Get a Catalog Genre's Relationship Directly by Name ✅ 🔗 :octocat:
Get Multiple Catalog Genres ✅ 🔗 :octocat:
Get Catalog Top Charts Genres ✅ 🔗 :octocat:

Curators

Feature Status Docs Code
Get a Catalog Curator ✅ 🔗 :octocat:
Get a Catalog Curator's Relationship Directly by Name ✅ 🔗 :octocat:
Get Multiple Catalog Curators ✅ 🔗 :octocat:
Get a Catalog Apple Curator ⛔ 🔗
Get a Catalog Apple Curator's Relationship Directly by Name ⛔ 🔗
Get Multiple Catalog Apple Curators ⛔ 🔗

Recommendations

Feature Status Docs Code
Get a Recommendation ⛔ 🔗
Get Multiple Recommendations ⛔ 🔗
Get Default Recommendations ⛔ 🔗

Activities

Feature Status Docs Code
Get a Catalog Activity ✅ 🔗 :octocat:
Get a Catalog Activity's Relationship Directly by Name ✅ 🔗 :octocat:
Get Multiple Catalog Activities ✅ 🔗 :octocat:

History

Feature Status Docs Code
Get Heavy Rotation Content ⛔ 🔗
Get Recently Played Resources ⛔ 🔗
Get Recently Played Stations ⛔ 🔗
Get Recently Added Resources ⛔ 🔗

Storefronts and Localization

Feature Status Docs Code
Get a User's Storefront ✅ 🔗 :octocat:
Get a Storefront ✅ 🔗 :octocat:
Get Multiple Storefronts ✅ 🔗 :octocat:
Get All Storefronts ✅ 🔗 :octocat:

Configuration

NOTE It's necessary to prepare an TEAM_ID, MUSIC_ID, and a secret file in advance. Please confirm Apple Developer Website.

It can be set by either an ENV variable or an config/initializers/apple_music.rb:

AppleMusic.configure do |config|
  config.secret_key_path = './AuthKey_MUSIC_ID.p8' # or ENV['APPLE_MUSIC_SECRET_KEY_PATH']
  config.team_id         = 'YOUR TEAM_ID'          # or ENV['APPLE_MUSIC_TEAM_ID']
  config.music_id        = 'YOUR MUSIC_ID'         # or ENV['APPLE_MUSIC_MUSIC_ID']
  config.storefront      = 'jp'                    # or ENV['APPLE_MUSIC_STOREFRONT'] ('us' by default)
end

License

MIT