<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ShazamKit",
  "identifier" : "/documentation/ShazamKit/SHMediaItem/fetch(shazamID:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "ShazamKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SHMediaItem(cm)fetchMediaItemWithShazamID:completionHandler:"
  },
  "title" : "fetch(shazamID:completionHandler:)"
}
-->

# fetch(shazamID:completionHandler:)

Requests the media item for the song with the specified Shazam ID.

```
class func fetch(shazamID: String, completionHandler: @escaping @Sendable (SHMediaItem?, (any Error)?) -> Void)
```

```
class func fetch(shazamID: String) async throws -> SHMediaItem
```

## Parameters

`shazamID`

The Shazam ID of the song.

`completionHandler`

The completion handler that the system calls with the result of the request.

    This block takes the following parameters:

- `mediaItem`: A media item.
- `error`: An error object if a problem occurs when fetching the media item; otherwise, `nil`.

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> class func fetch(shazamID: String) async throws -> SHMediaItem
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)