<!--
{
  "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/SHSession",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "ShazamKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SHSession"
  },
  "title" : "SHSession"
}
-->

# SHSession

An object that matches a specific audio recording when a segment of that recording is part of captured sound in the Shazam catalog or your custom catalog.

```
class SHSession
```

## Overview

Prepare to make matches by:

- Creating a session for the catalog that contains the reference signatures
- Adding your delegate that receives the match results

Search for a match in one of two ways:

- Generate a signature for the captured audio and call [`match(_:)`](/documentation/ShazamKit/SHSession/match(_:))
- Call [`matchStreamingBuffer(_:at:)`](/documentation/ShazamKit/SHSession/matchStreamingBuffer(_:at:)) with a streaming audio buffer, and ShazamKit generates the signature for you

Searching the catalog is asynchronous. The session calls your delegate methods with the result.

Matching audio against the Shazam catalog requires enabling your app to access the catalog. If you are
using a custom catalog, you don’t need to enable ShazamKit. For more information on enabling your app,
see [Enable ShazamKit for an App ID](https://developer.apple.com/help/account/configure-app-services/shazamkit).

The code below shows searching for a match in the Shazam catalog using an existing audio buffer:

```swift
// Set up the session.
let session = SHSession()

// Create a signature from the captured audio buffer.
let signatureGenerator = SHSignatureGenerator()
try signatureGenerator.append(buffer, at: audioTime)
let signature = signatureGenerator.signature()

// Check for a match.
let result = await session.result(from: signature)

// Use the result.
switch result {
 case .match(let match):
      // Match found.
 case .noMatch(let signature):
      // No match found.
 case .error(let error, let signature):
      // An error occurred.
}
```

## Topics

### Creating a session object

[`-  init`](/documentation/ShazamKit/SHSession/init())

Creates a new session object for matching songs in the Shazam Music catalog.

[`-  initWithCatalog:`](/documentation/ShazamKit/SHSession/init(catalog:))

Creates a new session object for matching audio in a custom catalog.

### Making a match

[`-  matchSignature:`](/documentation/ShazamKit/SHSession/match(_:))

Searches for the query signature in the reference signatures that the session catalog contains.

[`-  matchStreamingBuffer:atTime:`](/documentation/ShazamKit/SHSession/matchStreamingBuffer(_:at:))

Converts the audio in the buffer to a signature, and searches the reference signatures in the session catalog.

[Matching audio using the built-in microphone](/documentation/ShazamKit/matching-audio-using-the-built-in-microphone)

Use the audio stream from the microphone as the source for a ShazamKit session.

### Reading the session properties

[`delegate`](/documentation/ShazamKit/SHSession/delegate)

The object that the session calls with the result of a match request.

[`catalog`](/documentation/ShazamKit/SHSession/catalog)

The catalog object containing the reference signatures and their associated metadata that the session uses to perform matches.

[`results`](/documentation/ShazamKit/SHSession/results-swift.property)

The results as an asynchronous sequence of matches.

[`Results`](/documentation/ShazamKit/SHSession/Results-swift.struct)

An asynchronous sequence that emits updates from a session object query.

### Returning queries

[`result(from:)`](/documentation/ShazamKit/SHSession/result(from:))

Performs an asynchronous match with a signature you specify.

[`Result`](/documentation/ShazamKit/SHSession/Result)

Identifies the result from an asynchronous sequence result.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)