CiderClient

public struct CiderClient

A client for submitting requests to the Apple Music API.

  • Initialize a CiderClient

    Declaration

    Swift

    public init(storefront: Storefront, developerToken: String, urlFetcher: UrlFetcher = CiderClient.defaultURLFetcher)

    Parameters

    storefront

    The Storefront to submit requests to.

    developerToken

    The Apple Music developer token to use in requests.

    urlFetcher

    The UrlFetcher to use for processing requests. Defaults to a URLSession with the default URLSessionConfiguration.

  • Search the Apple Music catalog.

    Declaration

    Swift

    public func search(term: String, limit: Int? = nil, offset: Int? = nil, types: [MediaType]? = nil, completion: ((SearchResults?, Error?) -> Void)?)

    Parameters

    term

    The term to search for.

    limit

    The amount of results to return.

    offset

    The offset to use for paginating results.

    types

    The MediaTypes to limit the search to.

    completion

    The completion handler to call with the results of the search.

  • Get hints for search terms to use searching the Apple Music catalog.

    Declaration

    Swift

    public func searchHints(term: String, limit: Int? = nil, types: [MediaType]? = nil, completion: ((SearchHints?, Error?) -> Void)?)

    Parameters

    term

    The term to search for.

    limit

    The amount of results to return.

    types

    The MediaTypes to limit the search to.

    completion

    The completion handler to call with the results of the search hints.

  • Lookup an artist by id.

    Declaration

    Swift

    public func artist(id: String, include: [Include]? = nil, completion: ((Artist?, Error?) -> Void)?)

    Parameters

    id

    The id of the artist to lookup.

    include

    The relationships to include in the lookup.

    completion

    The handler to call with the results.

  • Lookup an album by id.

    Declaration

    Swift

    public func album(id: String, include: [Include]? = nil, completion: ((Album?, Error?) -> Void)?)

    Parameters

    id

    The id of the album to lookup.

    include

    The relationships to include in the lookup.

    completion

    The handler to call with the results.

  • Lookup a song by id.

    Declaration

    Swift

    public func song(id: String, include: [Include]? = nil, completion: ((Track?, Error?) -> Void)?)

    Parameters

    id

    The id of the song to lookup.

    include

    The relationships to include in the lookup.

    completion

    The handler to call with the results.

  • Lookup a playlist by id.

    Declaration

    Swift

    public func playlist(id: String, include: [Include]? = nil, completion: ((Playlist?, Error?) -> Void)?)

    Parameters

    id

    The id of the playlist to lookup.

    include

    The relationships to include in the lookup.

    completion

    The handler to call with the results.

  • Lookup a music video by id.

    Declaration

    Swift

    public func musicVideo(id: String, include: [Include]? = nil, completion: ((MusicVideo?, Error?) -> Void)?)

    Parameters

    id

    The id of the music video to lookup.

    include

    The relationships to include in the lookup.

    completion

    The handler to call with the results.

  • Lookup a curator by id.

    Declaration

    Swift

    public func curator(id: String, include: [Include]? = nil, completion: ((Curator?, Error?) -> Void)?)

    Parameters

    id

    The id of the curator to lookup.

    include

    The relationships to include in the lookup.

    completion

    The handler to call with the results.

  • Get the related resources for a Relationship.

    Declaration

    Swift

    public func get<T>(related: Relationship<T>, limit: Int? = nil, offset: Int? = nil, completion: (([T]?, Error?) -> Void)?)

    Parameters

    related

    The relationship to get.

    limit

    The maximum amount of results to return.

    offset

    The offset to use for pagination.

    completion

    The handler to call with the results.