AppleMusic
This is a ruby wrapper for the Apple Music API.
Installation
Add this line to your application's Gemfile:
And then execute:
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 |
✅ |
🔗 |
|
Get a Catalog Album's Relationship Directly by Name |
✅ |
🔗 |
|
Get Multiple Catalog Albums |
✅ |
🔗 |
|
Get Multiple Catalog Albums by UPC |
✅ |
🔗 |
|
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 |
✅ |
🔗 |
|
Get Multiple Catalog Artists |
✅ |
🔗 |
|
Get a Catalog Artist's Relationship Directly by Name |
✅ |
🔗 |
|
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 |
✅ |
🔗 |
|
Get Multiple Catalog Songs by ID |
✅ |
🔗 |
|
Get Multiple Catalog Songs by ISRC |
✅ |
🔗 |
|
Get a Catalog Song's Relationship Directly by Name |
✅ |
🔗 |
|
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 |
✅ |
🔗 |
|
Get a Catalog Music Video's Relationship Directly by Name |
✅ |
🔗 |
|
Get Multiple Catalog Music Videos by ID |
✅ |
🔗 |
|
Get Multiple Catalog Music Videos by ISRC |
✅ |
🔗 |
|
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 |
✅ |
🔗 |
|
Get a Catalog Playlist's Relationship Directly by Name |
✅ |
🔗 |
|
Get Multiple Catalog Playlists |
✅ |
🔗 |
|
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 |
✅ |
🔗 |
|
Get Multiple Catalog Stations |
✅ |
🔗 |
|
Search
Feature |
Status |
Docs |
Code |
Search for Catalog Resources |
✅ |
🔗 |
|
Get Catalog Search Hints |
✅ |
🔗 |
|
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 |
✅ |
🔗 |
|
Music Genres
Feature |
Status |
Docs |
Code |
Get a Catalog Genre |
✅ |
🔗 |
|
Get a Catalog Genre's Relationship Directly by Name |
✅ |
🔗 |
|
Get Multiple Catalog Genres |
✅ |
🔗 |
|
Get Catalog Top Charts Genres |
✅ |
🔗 |
|
Curators
Feature |
Status |
Docs |
Code |
Get a Catalog Curator |
✅ |
🔗 |
|
Get a Catalog Curator's Relationship Directly by Name |
✅ |
🔗 |
|
Get Multiple Catalog Curators |
✅ |
🔗 |
|
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 |
✅ |
🔗 |
|
Get a Catalog Activity's Relationship Directly by Name |
✅ |
🔗 |
|
Get Multiple Catalog Activities |
✅ |
🔗 |
|
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 |
✅ |
🔗 |
|
Get a Storefront |
✅ |
🔗 |
|
Get Multiple Storefronts |
✅ |
🔗 |
|
Get All Storefronts |
✅ |
🔗 |
|
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