# AppleMusicFeed
Elixir client for the editorial and catalog discovery portions of the [Apple Music API](https://developer.apple.com/documentation/applemusicapi).
This package is centered around chart and storefront browsing, plus fetching known Apple Music resources by ID.
## Installation
Add to your `mix.exs`:
```elixir
defp deps do
[
{:apple_music_feed, "~> 0.1.0"}
]
end
```
## Configuration
```elixir
config :apple_music_feed,
team_id: System.get_env("APPLE_TEAM_ID"),
key_id: System.get_env("APPLE_MUSIC_FEED_KEY_ID"),
private_key_path: System.get_env("APPLE_MUSIC_FEED_PRIVATE_KEY_PATH"),
storefront: "us"
```
Supported options:
- `team_id` - Apple Developer Team ID
- `key_id` - Maps/Media services key ID with Music access
- `private_key` - inline `.p8` contents
- `private_key_path` - path to the `.p8` file
- `base_url` - defaults to `https://api.music.apple.com`
- `storefront` - defaults to `us`
- `token_ttl_seconds` - defaults to package setting
## Quick Start
```elixir
# Charts by storefront
{:ok, charts} = AppleMusicFeed.get_charts(storefront: "us", types: ["songs", "albums"])
# Genres
{:ok, genres} = AppleMusicFeed.get_genres()
# Editorial mixes / stations
{:ok, mixes} = AppleMusicFeed.get_editorial_mixes(limit: 10)
# Recommendations
{:ok, recs} = AppleMusicFeed.get_recommendations(limit: 10)
```
## Fetching Known IDs
Some Apple Music feed-style operations are fetch-by-ID, not list-all endpoints.
```elixir
AppleMusicFeed.get_featured_playlists(["pl.5ee8333dbe944d9f9f9c49b8de10d6c5"])
AppleMusicFeed.get_new_releases(["310730204"])
AppleMusicFeed.get_top_songs(["900083885"])
AppleMusicFeed.get_playlist("pl.123456789")
AppleMusicFeed.get_playlist_tracks("pl.123456789", limit: 25)
```
## Live Testing
The shared media integration script covers this package too:
```bash
cd apple_music_api
source .env && elixir test_media_apis.exs
```
## Notes
- Use `get_charts/1` for discovery.
- Use the ID-based helpers when you already know the playlist, album, or song IDs.
- Tokens are cached in `AppleMusicFeed.TokenCache`.
## License
MIT