Documentation Index
Fetch the complete documentation index at: https://mintlify.com/hitenpatel/songprint/llms.txt
Use this file to discover all available pages before exploring further.
RecognitionClient is a thin, dependency-free HTTP client that POSTs a binary signature to the public Shazam discovery endpoint and returns the raw JSON response. It deliberately carries no JSON parsing dependency — use whatever JSON library your project already uses to decode the response. The entire implementation relies only on java.net.HttpURLConnection, making it compatible with any JVM or Android project without additional transitive dependencies.
Class declaration
Constructor parameters
The discovery endpoint URL. Defaults to
DEFAULT_ENDPOINT. Override this when writing tests against a local stub server, or if the default URL changes.Connection timeout in milliseconds passed to
HttpURLConnection. Default: 10_000 (10 seconds). Increase on flaky or high-latency networks.Read timeout in milliseconds passed to
HttpURLConnection. Default: 10_000 (10 seconds). The Shazam endpoint typically responds in under two seconds on a good connection.Methods
recognise
The binary fingerprint produced by
SignatureGenerator.generateSignature. It is base64-encoded and embedded in the JSON request body as a data URI.The number of 16kHz mono samples the signature was generated from — i.e.
mono16k.size. Used to compute the samplems field in the request body, which tells the endpoint how much audio was analysed.String? — the raw JSON response body when the server responds with HTTP 200. Returns null on any non-200 status code. Network errors (connection timeout, read timeout, DNS failure, etc.) propagate as thrown IOException exceptions — they are not silently converted to null.
Request body structure
The client constructs the following JSON payload. The signature bytes are base64-encoded and embedded as adata: URI; samplems is derived from numSamples / SAMPLE_RATE * 1000.
Response structure
The endpoint returns a JSON object. The key fields you will typically read are:| Field | Type | Description |
|---|---|---|
matches | array | List of match objects. An empty array means no song was identified. |
track.title | string | Song title. |
track.subtitle | string | Artist name. |
track.images.coverart | string | URL of the album cover art image. |
track.share.href | string | Link to the track on Shazam / Apple Music. |
matches is empty and the track key is absent.
Usage example
Companion object
| Constant | Value |
|---|---|
DEFAULT_ENDPOINT | "https://amp.shazam.com/discovery/v5/en/GB/android/-/tag" |
$DEFAULT_ENDPOINT/{uuid1}/{uuid2}?sync=true&webv3=true&...
recognise makes a blocking network call using java.net.HttpURLConnection. On Android, always call it from a coroutine with Dispatchers.IO or from a background thread — never from the main thread.