Skip to content

Latest commit

 

History

History
executable file
·
108 lines (83 loc) · 3.34 KB

README.md

File metadata and controls

executable file
·
108 lines (83 loc) · 3.34 KB

go-apple-music

GoDoc Continuous Integration Go Report Card

A Go client library for accessing the Apple Music API.

This library is heavily inspired by go-github.

Installation

Use go get.

go get -u github.com/minchao/go-apple-music

Usage

import "github.com/minchao/go-apple-music"

Construct a new API client, then use to access the Apple Music API. For example:

ctx := context.Background()
tp := applemusic.Transport{Token: "APPLE_MUSIC_API_TOKEN"}
client := applemusic.NewClient(tp.Client())

// Fetch all the storefronts in alphabetical order
storefronts, _, err := client.Storefront.GetAll(ctx, nil)

Create a developer token

Use the token generator tool to quickly create a developer token.

$ cd examples/token-genrator
$ go build

Usage:

$ ./generate-toke
Usage: generate-token [options]
  -k string
        MusicKit key
  -l int
        TTL (time-to-live), must not be greater than 15777000 (6 months in seconds) (default 3600)
  -pf string
        MusicKit private key, the path of private key file (.p8)
  -pk string
        MusicKit private key, enter string without BEGIN and END annotations
  -t string
        Team ID

Run:

$ ./generate-toke \
    -k=MUSICKIT_KEY \
    -t=TEAM_ID \
    -pf=MUSICKIT_PRIVATE_KEY_FILE

Create a Music User Token

Use the requestUserToken(forDeveloperToken:completionHandler:) method in the StoreKit framework.

Todo

  • Fetch Recent
    • Get recently played
    • Get recent stations
  • Manage Ratings
    • Get personal album rating
    • Get multiple personal album ratings
    • Add a personal album rating
    • Delete a personal album rating
    • Get personal music video rating
    • Get multiple personal music video ratings
    • Add a personal music video rating
    • Delete a personal music video rating
    • Get personal playlist rating
    • Get multiple personal playlist ratings
    • Add a personal playlist rating
    • Delete a personal playlist rating
    • Get personal song rating
    • Get multiple personal song ratings
    • Add a personal song rating
    • Delete a personal song rating
    • Get personal station rating
    • Get multiple personal station ratings
    • Add a personal station rating
    • Delete a personal station rating
  • Fetch Recommendations
    • Get default recommendations
    • Get album recommendations
    • Get playlist recommendations
    • Get a recommendation
    • Get multiple recommendations

License

See the LICENSE file for license rights and limitations (MIT).