ShazamKit Reference
API reference for ShazamKit — audio recognition against Shazam's music catalog and against custom audio catalogs. Covers the iOS 17+ SHManagedSession path that eliminates AVAudioEngine boilerplate, the iOS 15 SHSession path for buffer-level control, custom catalog construction, signature generation, library management, and the shazam CLI.
When to Use This Reference
Use this reference when:
- Looking up
SHManagedSessioninitializers, methods (prepare(),result(),results,cancel()), or state cases (.idle,.prerecording,.matching) - Working with
SHSessionfor buffer-level matching (iOS 15+ minimum, AVAudioEngine boilerplate required) ormatchStreamingBuffer(_:at:)for streaming audio - Building a custom catalog (
SHCustomCatalog) fromSHMediaItem+SHSignaturepairs, loading a.shazamcatalogfile, or writing a catalog to disk - Generating signatures with
SHSignatureGeneratorfromAVAudioPCMBufferchunks or finishing a signature withsignature() - Defining custom
SHMediaItemPropertykeys for app-specific metadata on matched items - Reading match-specific properties (
matchOffset,predictedCurrentMatchOffset,frequencySkew,confidence) fromSHMatchedMediaItem - Managing the user's Shazam library with
SHLibrary(read-only) orSHMediaLibrary(add) - Looking up
SHErrorcases and their meanings - Using the
shazamcommand-line tool for offline catalog generation at scale
Example Prompts
Questions you can ask Claude that will draw from this reference:
- "What's the API signature for
SHManagedSession.result()and what does the return type look like?" - "How do I use
SHSession.matchStreamingBufferand what's theat:parameter for?" - "What properties does
SHMatchedMediaItemadd on top ofSHMediaItem?" - "How do I define a custom
SHMediaItemPropertyfor my podcast episode number?" - "What's the difference between
SHLibraryandSHMediaLibrary?" - "Which
SHErrorcase do I get when the ShazamKit App Service isn't enabled?" - "How do I generate signatures from audio files at scale with the CLI?"
- "Can I match against both the Shazam catalog and a custom catalog from one session?"
What's Covered
SHManagedSession(iOS 17+) — initializer overloads (default catalog vs custom catalog), single-shotresult() async,ResultsAsyncSequencefor continuous matching,prepare() asyncfor pre-recording,cancel()to stop,stateObservable property with.idle/.prerecording/.matchingcases,Sendableconformance as of iOS 18SHSession(iOS 15+) — initializer overloads,match(_:)for complete signatures,matchStreamingBuffer(_:at:)for streaming audio (with the contiguous-audio validation),delegatefor callback-based delivery,ResultsAsyncSequence(iOS 16+), audio format support differences between iOS 15-16 (specific PCM formats) and iOS 17+ (automatic conversion), multiple-match behavior on iOS 17+SHSession.Result(iOS 16+) —.match(SHMatch)/.noMatch(SHSignature)/.error(any Error, SHSignature)SHSessionDelegate—session(_:didFind:)andsession(_:didNotFindMatchFor:error:)optional methodsSHMatch—mediaItemsarray ofSHMatchedMediaItemandquerySignatureSHMediaItem— properties dictionary keyed bySHMediaItemProperty, predefined keys (.title,.subtitle,.artist,.artworkURL,.videoURL,.genres,.explicitContent,.isrc,.appleMusicID,.appleMusicURL,.webURL,.shazamID,.creationDate), iOS 16+ timed content properties (.timeRanges,.frequencySkewRanges), custom property extension pattern,fetch(shazamID:)class method,Identifiable/SendableconformancesSHMatchedMediaItem— match-only additions:.matchOffset,.predictedCurrentMatchOffset(auto-updating during streaming),.frequencySkew,.confidence(0.0 to 1.0)SHMediaItemProperty—RawRepresentablestruct for predefined and custom property keys, complete list of predefined keys, custom extension patternSHSignature—duration,dataRepresentationfor storage/transmission,init(dataRepresentation:)throwing initializer,slices(from:duration:stride:)for segmentingSHSignatureGenerator—append(_:at:)forAVAudioPCMBufferchunks,signature()to finalize, the streaming-construction patternSHCatalogandSHCustomCatalog— building catalogs in-memory, persisting to.shazamcatalogfiles, loading from URL orData, the matching-many-references modelSHLibrary(read-only) andSHMediaLibrary(additive) — the user's Shazam library access split, why you must opt the user into writesSHErrorcases — the framework's error vocabulary including the silent-failure cases that indicate provisioning problems (no ShazamKit App Service enabled)- Audio format requirements — what formats
SHSessionaccepts on iOS 15-16 vs iOS 17+, format conversion responsibilities shazamCLI —shazam custom-catalog create,shazam custom-catalog add,shazam signaturesubcommands for offline batch signature generation and catalog construction; how it integrates into a build pipeline
Documentation Scope
This page documents the shazamkit-ref skill — the API reference half of the ShazamKit pair.
- For decision discipline (API era choice, use case decision tree, setup checklist, common provisioning mistakes, pressure scenarios), see ShazamKit
- For microphone permission setup (
NSMicrophoneUsageDescriptionInfo.plist key, permission prompt UX), see the privacy-ux reference under axiom-integration - For playing matched results via Now Playing or MusicKit, see Now Playing
Resources
Primary sources (Apple):
- ShazamKit framework documentation — developer.apple.com/documentation/shazamkit
SHManagedSession— developer.apple.com/documentation/shazamkit/shmanagedsessionSHSession— developer.apple.com/documentation/shazamkit/shsessionSHCustomCatalog— developer.apple.com/documentation/shazamkit/shcustomcatalog
WWDC: 2021-10044, 2021-10045, 2022-10028, 2023-10051