One Logo Pool Ball
MusicKit · IOS API REFERENCE

MusicDataRequest

struct · iOS 15.0+ · SDK 27.1

struct MusicDataRequest

A request for loading data from an arbitrary Apple Music API endpoint.

Members (7)

get · iOS 15.0+

urlRequest

TypeScript
get urlRequest(): _Foundation_URLRequest
Swift declaration
let urlRequest: URLRequest

The URL request for the data request.

init · iOS 15.0+

init

TypeScript
static init(urlRequest: _Foundation_URLRequest): MusicDataRequest
Swift declaration
init(urlRequest: URLRequest)

Creates a data request with a URL request.

get · iOS 15.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.

get · iOS 15.0+

tokenProvider

TypeScript
static get tokenProvider(): (MusicUserTokenProvider) & (SDKHandle)
Swift declaration
static var tokenProvider: any MusicUserTokenProvider & MusicDeveloperTokenProvider

The shared token provider for fetching tokens that Apple Music API requires.

set · iOS 15.0+

tokenProvider

TypeScript
static set tokenProvider(value: (MusicUserTokenProvider) & (Implements<MusicDeveloperTokenProvider> | SDKHandle))
Swift declaration
static var tokenProvider: any MusicUserTokenProvider & MusicDeveloperTokenProvider

The shared token provider for fetching tokens that Apple Music API requires.

get · iOS 15.0+

currentCountryCode

TypeScript
static get currentCountryCode(): Promise<string>
Swift declaration
static var currentCountryCode: String { get async throws }

Fetches the current country code for the user’s Apple Music account. The current country code may be useful to construct the URL for a ``MusicDataRequest`` because a typical catalog endpoint for Apple Music API requires the inclusion of a country code in the path of the corresponding URL.

method · iOS 15.0+

response

TypeScript
response(): Promise<MusicDataResponse>
Swift declaration
func response() async throws -> MusicDataResponse

Fetches data from the Apple Music API endpoint that the URL request defines.

Skipped declarations

No declarations were skipped in this snapshot.

All MusicKit types →