Reference

SDK method map

The exact name of every common AudD operation in the 11 official SDKs: install, the client, standard and enterprise recognition, streams, callbacks, the custom catalog, fields outside the typed surface, the token and the error types.

view .md auddsdkmethod namespython

This page shows you how to make the same calls in each of the 11 official AudD SDKs. Each SDK exports a set of methods corresponding to the methods of the AudD API.

Install

SDKPackageInstall
Pythonaudd on PyPIpip install audd
Node.js@audd/sdk on npmnpm install @audd/sdk
Gogithub.com/AudDMusic/audd-gogo get github.com/AudDMusic/audd-go
Rustaudd on crates.iocargo add audd
PHPaudd/audd on Packagistcomposer require audd/audd
Swiftproduct AudD; add .product(name: "AudD", package: "audd-swift") to your target’s dependencies.package(url: "https://github.com/AudDMusic/audd-swift", from: "1.5.21")
Kotlinio.audd:audd-kotlin on Maven Centralimplementation("io.audd:audd-kotlin:1.5.18")
C# (.NET)AudD on NuGetdotnet add package AudD
Javaio.audd:audd on Maven Centralimplementation("io.audd:audd:1.5.19")
CCMake target audd; needs libcurlCMake, below
C++CMake target audd::audd; needs libcurlCMake, below

C with CMake

include(FetchContent)
FetchContent_Declare(audd
    GIT_REPOSITORY https://github.com/AudDMusic/audd-c.git
    GIT_TAG        v1.5.18
)
FetchContent_MakeAvailable(audd)

target_link_libraries(your_app PRIVATE audd)

C++ with CMake

find_package(audd CONFIG REQUIRED)
target_link_libraries(your_app PRIVATE audd::audd)

Create a client

Pass your API token to the constructor. Without one, the SDK reads the AUDD_API_TOKEN environment variable. Get your own token at dashboard.audd.io.

SDKImportCreate a clientToken from AUDD_API_TOKEN
Pythonfrom audd import AudDaudd = AudD("your-api-token")AudD()
Node.jsimport { AudD } from "@audd/sdk";const audd = new AudD("your-api-token");new AudD()
Goimport "github.com/AudDMusic/audd-go"client := audd.NewClient("your-api-token")audd.NewClient("")
Rustuse audd::AudD;let audd = AudD::new("your-api-token");AudD::from_env()?
PHPuse AudD\AudD;$audd = new AudD('your-api-token');AudD::fromEnvironment()
Swiftimport AudDlet audd = try AudD(apiToken: "your-api-token")try AudD.fromEnvironment()
Kotlinimport io.audd.AudDval audd = AudD("your-api-token")AudD.fromEnvironment()
C#using AudD;var audd = new AudD.AudD("your-api-token");AudD.AudD.FromEnvironment()
Javaimport io.audd.AudD;AudD audd = new AudD("your-api-token");AudD.fromEnvironment()
C#include <audd.h>audd_client_t *client = audd_client_new("your-api-token", NULL);audd_client_new(NULL, NULL)
C++#include <audd/audd.hpp>audd::AudD client("your-api-token");audd::AudD client;

Note. In C#, the class and the namespace are both called AudD. After using AudD;, write AudD.AudD for the class: new AudD("your-api-token") doesn’t compile.

Recognize a short clip

This is the default API method: it identifies the song in a short audio clip. If the server has successfully processed the request, but there are no matches, the result is the value in the “No match” column, not an error.

SDKRecognizeNo matchreturn option
Pythonresult = audd.recognize(source)Nonereturn_metadata=
Node.jsconst result = await audd.recognize(source);null{ returnMetadata }
Goresult, err := client.Recognize(source, nil)nil, nilRecognizeOptions.ReturnMetadata
Rustlet result = audd.recognize(source).await?;Noneaudd::client::RecognizeOptions with recognize_with
PHP$result = $audd->recognize($source);nullreturn_metadata:
Swiftlet result = try await audd.recognize(source)nilreturnMetadata:
Kotlinval result = audd.recognize(source)nullreturnMetadata =
C#var result = await audd.RecognizeAsync(source);nullreturnMetadata:
JavaRecognitionResult result = audd.recognize(source);nullRecognizeOptions.builder().returnMetadata(...)
Caudd_recognize(client, source, NULL, &result)AUDD_OK with result == NULLaudd_recognize_options_t.return_metadata
C++auto result = client.recognize(source);std::nulloptRecognizeOptions::return_metadata

The return option asks for the metadata blocks (Apple Music, Spotify and others); without it, the result has the core fields and song_link.

What source can be

If the string is an HTTP URL, our server will download the file and identify the music. Otherwise the SDK reads the string as a file path and uploads the file.

SDKURLFileBytes
Pythonstrpath str, pathlib.Path, a file objectbytes
Node.jsstring, URLpath string (Node.js only)Uint8Array, Buffer, Blob
Gostringpath string, io.Reader[]byte
Rust&str, Stringpath string, PathBufVec<u8>
PHPstringpath string, a resource, a PSR-7 streamAudD::bytes($bytes)
SwiftString (always a URL), .url(url).file(fileURL), .stream(inputStream).data(data)
KotlinString (always a URL), Source.Url(url)Source.FilePath(file), Source.Stream(stream)Source.Bytes(bytes)
C#stringpath string, FileInfo, System.IO.Streambyte[]
JavaStringpath String, Path, File, InputStreambyte[]
Cconst char *path const char *audd_recognize_bytes(client, data, size, NULL, &result)
C++std::string, audd::SourceUrlstd::string, audd::SourceFilePathaudd::SourceBytes

Recognize a long file

We count requests to the enterprise endpoint as 1 request per 12 seconds of audio. If you don’t want every one of these chunks to be recognized and counted as the requests, set limit: it’s the upper bound for the number of chunks the server will recognize. Always set it while you develop. The SDKs return one list of matches for the whole file.

SDKRecognize with a limitReturns
Pythonaudd.recognize_enterprise(source, limit=1)list[EnterpriseMatch]
Node.jsawait audd.recognizeEnterprise(source, { limit: 1 })EnterpriseMatch[]
Golimit := 1, then client.RecognizeEnterprise(source, &audd.EnterpriseOptions{Limit: &limit})[]EnterpriseMatch
Rustaudd.recognize_enterprise(source, EnterpriseOptions { limit: Some(1), ..Default::default() }).await?Vec<EnterpriseMatch>
PHP$audd->recognizeEnterprise($source, limit: 1)list<EnterpriseMatch>
Swifttry await audd.recognizeEnterprise(.url(url), limit: 1)[EnterpriseMatch]
Kotlinaudd.recognizeEnterprise(Source.Url(url), limit = 1)List<EnterpriseMatch>
C#await audd.RecognizeEnterpriseAsync(source, limit: 1)IReadOnlyList<EnterpriseMatch>
Javaaudd.recognizeEnterprise(source, EnterpriseOptions.builder().limit(1).build())List<EnterpriseMatch>
Copts.limit = 1 on audd_enterprise_options_default(), then audd_recognize_enterprise(client, source, &opts, &result)audd_enterprise_result_t *
C++opts.limit = 1 on an audd::EnterpriseOptions, then client.recognize_enterprise(source, opts)std::vector<EnterpriseMatch>

In Swift, the default limit is 1. The other SDKs don’t send a limit unless you set one. For skip, every and the other parameters that decide how much of a file is scanned, see enterprise endpoint cost control.

Streams

The callback URL

Set the URL for callbacks using the setCallbackUrl API method. You can change the URL at any time using this method. The return option adds ?return= to the URL you set, and the server reads it from the callback URL.

SDKSetGetreturn option
Pythonaudd.streams.set_callback_url(url)audd.streams.get_callback_url()return_metadata=
Node.jsawait audd.streams.setCallbackUrl(url)await audd.streams.getCallbackUrl(){ returnMetadata }
Goclient.Streams().SetCallbackUrl(url, nil)client.Streams().GetCallbackUrl()SetCallbackUrlOptions.ReturnMetadata
Rustaudd.streams().set_callback_url(url, None, None).await?audd.streams().get_callback_url().await?second argument
PHP$audd->streams()->setCallbackUrl($url)$audd->streams()->getCallbackUrl()$returnMetadata
Swifttry await audd.streams.setCallbackURL(url)try await audd.streams.getCallbackURL()returnMetadata:
Kotlinaudd.streams.setCallbackUrl(url)audd.streams.getCallbackUrl()returnMetadata =
C#await audd.Streams.SetCallbackUrlAsync(url)await audd.Streams.GetCallbackUrlAsync()returnMetadata:
Javaaudd.streams().setCallbackUrl(url)audd.streams().getCallbackUrl()second argument
Caudd_streams_set_callback_url(client, url, NULL)audd_streams_get_callback_url(client, &url)audd_streams_set_callback_url_options_t.return_metadata
C++client.streams().set_callback_url(url)client.streams().get_callback_url()SetCallbackUrlOptions::return_metadata

Add, change and delete streams

Add the streams using the addStream API method. Use setStreamUrl to update the URL of a stream, deleteStream to delete a stream, and getStreams to get all the streams. By default, we send new results after songs end playing; pass callbacks set to "before" to add if you want to get the results when songs start playing.

SDKAddChange the URLDeleteList
Pythonaudd.streams.add(url, radio_id)audd.streams.set_url(radio_id, url)audd.streams.delete(radio_id)audd.streams.list()
Node.jsawait audd.streams.add({ url, radioId })await audd.streams.setUrl(radioId, url)await audd.streams.delete(radioId)await audd.streams.list()
Goclient.Streams().Add(audd.AddStreamRequest{URL: url, RadioID: id})client.Streams().SetURL(id, url)client.Streams().Delete(id)client.Streams().List()
Rustaudd.streams().add(url, radio_id, None, None).await?audd.streams().set_url(radio_id, url).await?audd.streams().delete(radio_id).await?audd.streams().list().await?
PHP$audd->streams()->add($url, $radioId)$audd->streams()->setUrl($radioId, $url)$audd->streams()->delete($radioId)$audd->streams()->list()
Swifttry await audd.streams.add(url: url, radioID: id)try await audd.streams.setURL(radioID: id, url: url)try await audd.streams.delete(radioID: id)try await audd.streams.list()
Kotlinaudd.streams.add(url, radioId)audd.streams.setUrl(radioId, url)audd.streams.delete(radioId)audd.streams.list()
C#await audd.Streams.AddAsync(url, radioId)await audd.Streams.SetUrlAsync(radioId, url)await audd.Streams.DeleteAsync(radioId)await audd.Streams.ListAsync()
Javaaudd.streams().add(new io.audd.streams.AddStreamRequest(url, radioId))audd.streams().setUrl(radioId, url)audd.streams().delete(radioId)audd.streams().list()
Caudd_streams_add(client, &req) with an audd_add_stream_request_taudd_streams_set_url(client, radio_id, url)audd_streams_delete(client, radio_id)audd_streams_list(client, &list)
C++client.streams().add(req) with an audd::AddStreamRequestclient.streams().set_url(radio_id, url)client.streams().del(radio_id)client.streams().list()

Note. If the limit of streams is reached, you’ll get the error 902 from addStream, and the SDKs raise it as the quota error. Handle the stream-limit error (610) there as well. The other stream limits are on the limits page.

Parse a callback

The callbacks will be sent to the specified URL as a JSON structure in the POST payload. You’ll receive callbacks with results and notifications.

SDKParse the bodyTakesFrom a requestReturns
Pythonaudd.streams.parse_callback(body)bytes, str, dictaudd.streams.handle_callback(request) (Flask, Django)(match, notification)
Node.jsparseCallback(body) from @audd/sdkparsed JSON, a stringawait handleCallback(req) (Node.js, Web, Express){ match, notification }
Goaudd.ParseCallback(body)[]byteaudd.HandleCallback(r) (*http.Request)match, notification, err
Rustaudd::handle_callback(&body)bytesnoneaudd::CallbackEvent
PHP\AudD\Streams::handleCallback($body)a string, an arraythe same, with a PSR-7 requestCallbackEvent
Swifttry await audd.streams.parseCallback(data)DatanoneCallbackEvent
KotlinparseCallback(body) from io.auddString, ByteArray, JsonObjectnoneCallbackEvent
C#AudDHelpers.ParseCallback(body)string, JsonElementawait AudDHelpers.HandleCallbackAsync(Request.Body)CallbackEvent
Javaio.audd.streams.Streams.parseCallback(body)byte[], JsonNodethe same, with an InputStreamCallbackEvent
Caudd_parse_callback(body, size, &match, &notification, &error_message)a buffer and its sizenonematch or notification
C++audd::parse_callback(body)std::stringnoneaudd::CallbackEvent

Upload to a custom catalog

If you want to recognize music among the songs you’ve uploaded, this is the method you use for uploading your songs. Access to this endpoint isn’t available by default. The songs uploaded via this endpoint will be available for recognition only to you. A token without access to the endpoint gets the custom-catalog access error.

SDKUpload a song
Pythonaudd.custom_catalog.add(audio_id, source)
Node.jsawait audd.customCatalog.add({ audioId, source })
Goclient.CustomCatalog().Add(audioID, source)
Rustaudd.custom_catalog().add(audio_id, source).await?
PHP$audd->customCatalog()->add($audioId, $source)
Swifttry await audd.customCatalog.add(audioID: id, source: source)
Kotlinaudd.customCatalog.add(audioId, source)
C#await audd.CustomCatalog.AddAsync(audioId, source)
Javaaudd.customCatalog().add(audioId, source)
Caudd_custom_catalog_add(client, audio_id, source), or audd_custom_catalog_add_bytes(client, audio_id, data, size)
C++client.custom_catalog().add(audio_id, source)

The SDKs do not retry a custom-catalog upload automatically. If an upload fails, check the error before you send it again: uploading to an audio_id that already holds a song replaces it.

Read fields outside the typed surface

The other fields the server returns are in the extras of the result.

SDKFields outside the typed surfaceValue type
Pythonresult.model_extradict
Node.jsresult.extrasRecord<string, unknown>
Goresult.Extrasmap[string]json.RawMessage
Rustresult.extrasHashMap<String, serde_json::Value>
PHP$result->extrasarray
Swiftresult.extras[String: AnyCodable]
Kotlinresult.extrasMap<String, JsonElement>
C#result.ExtrasDictionary<string, JsonElement>
Javaresult.extras()Map<String, Object>
Caudd_recognition_extra(result, "key")the field’s JSON text
C++result.extrasstd::map<std::string, nlohmann::json>

Change the token

You can rotate the token without making a new client. Requests already in flight finish with the old token.

SDKChange the token
Pythonaudd.set_api_token("new-token")
Node.jsaudd.setApiToken("new-token")
Goerr := client.SetAPIToken("new-token")
Rustaudd.set_api_token("new-token")?
PHP$audd->setApiToken('new-token')
Swifttry await audd.setApiToken("new-token")
Kotlinaudd.setApiToken("new-token")
C#audd.SetApiToken("new-token")
Javaaudd.setApiToken("new-token")
Caudd_client_set_api_token(client, "new-token")
C++client.set_api_token("new-token")

Errors

The SDKs define the following error types. Their names follow each language’s conventions; the categories are the same in every SDK.

Base types

SDKAny SDK errorAn error from the serverIts code
PythonAudDErrorAudDAPIErrore.error_code
Node.jsAudDErrorAudDAPIErrore.errorCode
Goerror*audd.AudDAPIError, with errors.AsapiErr.ErrorCode
Rustaudd::AudDErrorAudDError::Api { .. }e.error_code()
PHPAudD\Errors\AudDExceptionAudD\Errors\AudDApiException$e->errorCode
SwiftAudDErrorAudDError.api(detail)detail.errorCode
Kotlinio.audd.AudDExceptionio.audd.AudDApiExceptione.errorCode
C#AudDExceptionAudDApiExceptione.ErrorCode
Javaio.audd.errors.AudDExceptionio.audd.errors.AudDApiErrore.errorCode()
Caudd_error_t, returned by each call that can failany value but AUDD_OKaudd_last_error_code(client), audd_last_error_message(client)
C++audd::AudDErroraudd::AudDApiErrore.error_code

Classes: Python, Node.js, Java, PHP, Kotlin, C#

CategoryPython, Node.js, JavaPHP, Kotlin, C#
AuthenticationAudDAuthenticationErrorAudDAuthenticationException
QuotaAudDQuotaErrorAudDQuotaException
SubscriptionAudDSubscriptionErrorAudDSubscriptionException
Custom catalog accessAudDCustomCatalogAccessErrorAudDCustomCatalogAccessException
Invalid requestAudDInvalidRequestErrorAudDInvalidRequestException
Invalid audioAudDInvalidAudioErrorAudDInvalidAudioException
Stream limitAudDStreamLimitErrorAudDStreamLimitException
Rate limitAudDRateLimitErrorAudDRateLimitException
BlockedAudDBlockedErrorAudDBlockedException
ServerAudDServerErrorAudDServerException
ConnectionAudDConnectionErrorAudDConnectionException
SerializationAudDSerializationErrorAudDSerializationException

Categories: Go, Rust, Swift, C++, C

CategoryGo (errors.Is)Rust (kind)Swift (detail.kind)C++ (e.category())C (return value)
Authenticationaudd.ErrAuthenticationErrorKind::Authentication.authenticationErrorCategory::AuthenticationAUDD_ERR_AUTHENTICATION
Quotaaudd.ErrQuotaErrorKind::Quota.quotaErrorCategory::QuotaAUDD_ERR_QUOTA
Subscriptionaudd.ErrSubscriptionErrorKind::Subscription.subscriptionErrorCategory::SubscriptionAUDD_ERR_SUBSCRIPTION
Custom catalog accessaudd.ErrCustomCatalogAccessErrorKind::CustomCatalogAccess.customCatalogAccessErrorCategory::CustomCatalogAccessAUDD_ERR_CUSTOM_CATALOG_ACCESS
Invalid requestaudd.ErrInvalidRequestErrorKind::InvalidRequest.invalidRequestErrorCategory::InvalidRequestAUDD_ERR_INVALID_REQUEST
Invalid audioaudd.ErrInvalidAudioErrorKind::InvalidAudio.invalidAudioErrorCategory::InvalidAudioAUDD_ERR_INVALID_AUDIO
Stream limitaudd.ErrStreamLimitErrorKind::StreamLimit.streamLimitErrorCategory::StreamLimitAUDD_ERR_STREAM_LIMIT
Rate limitaudd.ErrRateLimitErrorKind::RateLimit.rateLimitErrorCategory::RateLimitAUDD_ERR_RATE_LIMIT
Blockedaudd.ErrBlockedErrorKind::Blocked.blockedErrorCategory::BlockedAUDD_ERR_BLOCKED
Serveraudd.ErrServerErrorKind::ServerError.serverErrorCategory::ServerAUDD_ERR_SERVER
Server, no JSON bodyaudd.ErrServerAudDError::ServerAudDError.serverErrorErrorCategory::ServerAUDD_ERR_SERVER
Connectionaudd.ErrConnectionAudDError::ConnectionAudDError.connectionErrorCategory::ConnectionAUDD_ERR_CONNECTION
Serializationaudd.ErrSerializationAudDError::SerializationAudDError.serializationErrorErrorCategory::SerializationAUDD_ERR_SERIALIZATION

Blocking and asynchronous calls

SDKBlockingAsynchronous
PythonAudDAsyncAudD, with the same methods, awaited
Node.jsnoneevery API call returns a Promise
Goevery method; each one that calls the API has a Context twin, such as RecognizeContext(ctx, source, nil)none
Rustnoneevery API call is async
PHPevery methodnone
Swiftnoneevery API call is async; AudD is an actor
Kotlinnoneevery API call is a suspend function
C#noneAPI calls return a Task, and their names end in Async
JavaAudDAsyncAudD, which returns a CompletableFuture
Cevery functionnone
C++every method_async twins that return a std::future, such as recognize_async

Related

Reading this as an AI agent? The raw Markdown is at reference/sdk-method-map.md, and the full index is /resources/llms.txt.