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.
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
| SDK | Package | Install |
|---|---|---|
| Python | audd on PyPI | pip install audd |
| Node.js | @audd/sdk on npm | npm install @audd/sdk |
| Go | github.com/AudDMusic/audd-go | go get github.com/AudDMusic/audd-go |
| Rust | audd on crates.io | cargo add audd |
| PHP | audd/audd on Packagist | composer require audd/audd |
| Swift | product 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") |
| Kotlin | io.audd:audd-kotlin on Maven Central | implementation("io.audd:audd-kotlin:1.5.18") |
| C# (.NET) | AudD on NuGet | dotnet add package AudD |
| Java | io.audd:audd on Maven Central | implementation("io.audd:audd:1.5.19") |
| C | CMake target audd; needs libcurl | CMake, below |
| C++ | CMake target audd::audd; needs libcurl | CMake, 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.
| SDK | Import | Create a client | Token from AUDD_API_TOKEN |
|---|---|---|---|
| Python | from audd import AudD | audd = AudD("your-api-token") | AudD() |
| Node.js | import { AudD } from "@audd/sdk"; | const audd = new AudD("your-api-token"); | new AudD() |
| Go | import "github.com/AudDMusic/audd-go" | client := audd.NewClient("your-api-token") | audd.NewClient("") |
| Rust | use audd::AudD; | let audd = AudD::new("your-api-token"); | AudD::from_env()? |
| PHP | use AudD\AudD; | $audd = new AudD('your-api-token'); | AudD::fromEnvironment() |
| Swift | import AudD | let audd = try AudD(apiToken: "your-api-token") | try AudD.fromEnvironment() |
| Kotlin | import io.audd.AudD | val audd = AudD("your-api-token") | AudD.fromEnvironment() |
| C# | using AudD; | var audd = new AudD.AudD("your-api-token"); | AudD.AudD.FromEnvironment() |
| Java | import 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. Afterusing AudD;, writeAudD.AudDfor 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.
| SDK | Recognize | No match | return option |
|---|---|---|---|
| Python | result = audd.recognize(source) | None | return_metadata= |
| Node.js | const result = await audd.recognize(source); | null | { returnMetadata } |
| Go | result, err := client.Recognize(source, nil) | nil, nil | RecognizeOptions.ReturnMetadata |
| Rust | let result = audd.recognize(source).await?; | None | audd::client::RecognizeOptions with recognize_with |
| PHP | $result = $audd->recognize($source); | null | return_metadata: |
| Swift | let result = try await audd.recognize(source) | nil | returnMetadata: |
| Kotlin | val result = audd.recognize(source) | null | returnMetadata = |
| C# | var result = await audd.RecognizeAsync(source); | null | returnMetadata: |
| Java | RecognitionResult result = audd.recognize(source); | null | RecognizeOptions.builder().returnMetadata(...) |
| C | audd_recognize(client, source, NULL, &result) | AUDD_OK with result == NULL | audd_recognize_options_t.return_metadata |
| C++ | auto result = client.recognize(source); | std::nullopt | RecognizeOptions::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.
| SDK | URL | File | Bytes |
|---|---|---|---|
| Python | str | path str, pathlib.Path, a file object | bytes |
| Node.js | string, URL | path string (Node.js only) | Uint8Array, Buffer, Blob |
| Go | string | path string, io.Reader | []byte |
| Rust | &str, String | path string, PathBuf | Vec<u8> |
| PHP | string | path string, a resource, a PSR-7 stream | AudD::bytes($bytes) |
| Swift | String (always a URL), .url(url) | .file(fileURL), .stream(inputStream) | .data(data) |
| Kotlin | String (always a URL), Source.Url(url) | Source.FilePath(file), Source.Stream(stream) | Source.Bytes(bytes) |
| C# | string | path string, FileInfo, System.IO.Stream | byte[] |
| Java | String | path String, Path, File, InputStream | byte[] |
| C | const char * | path const char * | audd_recognize_bytes(client, data, size, NULL, &result) |
| C++ | std::string, audd::SourceUrl | std::string, audd::SourceFilePath | audd::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.
| SDK | Recognize with a limit | Returns |
|---|---|---|
| Python | audd.recognize_enterprise(source, limit=1) | list[EnterpriseMatch] |
| Node.js | await audd.recognizeEnterprise(source, { limit: 1 }) | EnterpriseMatch[] |
| Go | limit := 1, then client.RecognizeEnterprise(source, &audd.EnterpriseOptions{Limit: &limit}) | []EnterpriseMatch |
| Rust | audd.recognize_enterprise(source, EnterpriseOptions { limit: Some(1), ..Default::default() }).await? | Vec<EnterpriseMatch> |
| PHP | $audd->recognizeEnterprise($source, limit: 1) | list<EnterpriseMatch> |
| Swift | try await audd.recognizeEnterprise(.url(url), limit: 1) | [EnterpriseMatch] |
| Kotlin | audd.recognizeEnterprise(Source.Url(url), limit = 1) | List<EnterpriseMatch> |
| C# | await audd.RecognizeEnterpriseAsync(source, limit: 1) | IReadOnlyList<EnterpriseMatch> |
| Java | audd.recognizeEnterprise(source, EnterpriseOptions.builder().limit(1).build()) | List<EnterpriseMatch> |
| C | opts.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.
| SDK | Set | Get | return option |
|---|---|---|---|
| Python | audd.streams.set_callback_url(url) | audd.streams.get_callback_url() | return_metadata= |
| Node.js | await audd.streams.setCallbackUrl(url) | await audd.streams.getCallbackUrl() | { returnMetadata } |
| Go | client.Streams().SetCallbackUrl(url, nil) | client.Streams().GetCallbackUrl() | SetCallbackUrlOptions.ReturnMetadata |
| Rust | audd.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 |
| Swift | try await audd.streams.setCallbackURL(url) | try await audd.streams.getCallbackURL() | returnMetadata: |
| Kotlin | audd.streams.setCallbackUrl(url) | audd.streams.getCallbackUrl() | returnMetadata = |
| C# | await audd.Streams.SetCallbackUrlAsync(url) | await audd.Streams.GetCallbackUrlAsync() | returnMetadata: |
| Java | audd.streams().setCallbackUrl(url) | audd.streams().getCallbackUrl() | second argument |
| C | audd_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.
| SDK | Add | Change the URL | Delete | List |
|---|---|---|---|---|
| Python | audd.streams.add(url, radio_id) | audd.streams.set_url(radio_id, url) | audd.streams.delete(radio_id) | audd.streams.list() |
| Node.js | await audd.streams.add({ url, radioId }) | await audd.streams.setUrl(radioId, url) | await audd.streams.delete(radioId) | await audd.streams.list() |
| Go | client.Streams().Add(audd.AddStreamRequest{URL: url, RadioID: id}) | client.Streams().SetURL(id, url) | client.Streams().Delete(id) | client.Streams().List() |
| Rust | audd.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() |
| Swift | try 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() |
| Kotlin | audd.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() |
| Java | audd.streams().add(new io.audd.streams.AddStreamRequest(url, radioId)) | audd.streams().setUrl(radioId, url) | audd.streams().delete(radioId) | audd.streams().list() |
| C | audd_streams_add(client, &req) with an audd_add_stream_request_t | audd_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::AddStreamRequest | client.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
902fromaddStream, 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.
| SDK | Parse the body | Takes | From a request | Returns |
|---|---|---|---|---|
| Python | audd.streams.parse_callback(body) | bytes, str, dict | audd.streams.handle_callback(request) (Flask, Django) | (match, notification) |
| Node.js | parseCallback(body) from @audd/sdk | parsed JSON, a string | await handleCallback(req) (Node.js, Web, Express) | { match, notification } |
| Go | audd.ParseCallback(body) | []byte | audd.HandleCallback(r) (*http.Request) | match, notification, err |
| Rust | audd::handle_callback(&body) | bytes | none | audd::CallbackEvent |
| PHP | \AudD\Streams::handleCallback($body) | a string, an array | the same, with a PSR-7 request | CallbackEvent |
| Swift | try await audd.streams.parseCallback(data) | Data | none | CallbackEvent |
| Kotlin | parseCallback(body) from io.audd | String, ByteArray, JsonObject | none | CallbackEvent |
| C# | AudDHelpers.ParseCallback(body) | string, JsonElement | await AudDHelpers.HandleCallbackAsync(Request.Body) | CallbackEvent |
| Java | io.audd.streams.Streams.parseCallback(body) | byte[], JsonNode | the same, with an InputStream | CallbackEvent |
| C | audd_parse_callback(body, size, &match, ¬ification, &error_message) | a buffer and its size | none | match or notification |
| C++ | audd::parse_callback(body) | std::string | none | audd::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.
| SDK | Upload a song |
|---|---|
| Python | audd.custom_catalog.add(audio_id, source) |
| Node.js | await audd.customCatalog.add({ audioId, source }) |
| Go | client.CustomCatalog().Add(audioID, source) |
| Rust | audd.custom_catalog().add(audio_id, source).await? |
| PHP | $audd->customCatalog()->add($audioId, $source) |
| Swift | try await audd.customCatalog.add(audioID: id, source: source) |
| Kotlin | audd.customCatalog.add(audioId, source) |
| C# | await audd.CustomCatalog.AddAsync(audioId, source) |
| Java | audd.customCatalog().add(audioId, source) |
| C | audd_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.
| SDK | Fields outside the typed surface | Value type |
|---|---|---|
| Python | result.model_extra | dict |
| Node.js | result.extras | Record<string, unknown> |
| Go | result.Extras | map[string]json.RawMessage |
| Rust | result.extras | HashMap<String, serde_json::Value> |
| PHP | $result->extras | array |
| Swift | result.extras | [String: AnyCodable] |
| Kotlin | result.extras | Map<String, JsonElement> |
| C# | result.Extras | Dictionary<string, JsonElement> |
| Java | result.extras() | Map<String, Object> |
| C | audd_recognition_extra(result, "key") | the field’s JSON text |
| C++ | result.extras | std::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.
| SDK | Change the token |
|---|---|
| Python | audd.set_api_token("new-token") |
| Node.js | audd.setApiToken("new-token") |
| Go | err := client.SetAPIToken("new-token") |
| Rust | audd.set_api_token("new-token")? |
| PHP | $audd->setApiToken('new-token') |
| Swift | try await audd.setApiToken("new-token") |
| Kotlin | audd.setApiToken("new-token") |
| C# | audd.SetApiToken("new-token") |
| Java | audd.setApiToken("new-token") |
| C | audd_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
| SDK | Any SDK error | An error from the server | Its code |
|---|---|---|---|
| Python | AudDError | AudDAPIError | e.error_code |
| Node.js | AudDError | AudDAPIError | e.errorCode |
| Go | error | *audd.AudDAPIError, with errors.As | apiErr.ErrorCode |
| Rust | audd::AudDError | AudDError::Api { .. } | e.error_code() |
| PHP | AudD\Errors\AudDException | AudD\Errors\AudDApiException | $e->errorCode |
| Swift | AudDError | AudDError.api(detail) | detail.errorCode |
| Kotlin | io.audd.AudDException | io.audd.AudDApiException | e.errorCode |
| C# | AudDException | AudDApiException | e.ErrorCode |
| Java | io.audd.errors.AudDException | io.audd.errors.AudDApiError | e.errorCode() |
| C | audd_error_t, returned by each call that can fail | any value but AUDD_OK | audd_last_error_code(client), audd_last_error_message(client) |
| C++ | audd::AudDError | audd::AudDApiError | e.error_code |
Classes: Python, Node.js, Java, PHP, Kotlin, C#
| Category | Python, Node.js, Java | PHP, Kotlin, C# |
|---|---|---|
| Authentication | AudDAuthenticationError | AudDAuthenticationException |
| Quota | AudDQuotaError | AudDQuotaException |
| Subscription | AudDSubscriptionError | AudDSubscriptionException |
| Custom catalog access | AudDCustomCatalogAccessError | AudDCustomCatalogAccessException |
| Invalid request | AudDInvalidRequestError | AudDInvalidRequestException |
| Invalid audio | AudDInvalidAudioError | AudDInvalidAudioException |
| Stream limit | AudDStreamLimitError | AudDStreamLimitException |
| Rate limit | AudDRateLimitError | AudDRateLimitException |
| Blocked | AudDBlockedError | AudDBlockedException |
| Server | AudDServerError | AudDServerException |
| Connection | AudDConnectionError | AudDConnectionException |
| Serialization | AudDSerializationError | AudDSerializationException |
Categories: Go, Rust, Swift, C++, C
| Category | Go (errors.Is) | Rust (kind) | Swift (detail.kind) | C++ (e.category()) | C (return value) |
|---|---|---|---|---|---|
| Authentication | audd.ErrAuthentication | ErrorKind::Authentication | .authentication | ErrorCategory::Authentication | AUDD_ERR_AUTHENTICATION |
| Quota | audd.ErrQuota | ErrorKind::Quota | .quota | ErrorCategory::Quota | AUDD_ERR_QUOTA |
| Subscription | audd.ErrSubscription | ErrorKind::Subscription | .subscription | ErrorCategory::Subscription | AUDD_ERR_SUBSCRIPTION |
| Custom catalog access | audd.ErrCustomCatalogAccess | ErrorKind::CustomCatalogAccess | .customCatalogAccess | ErrorCategory::CustomCatalogAccess | AUDD_ERR_CUSTOM_CATALOG_ACCESS |
| Invalid request | audd.ErrInvalidRequest | ErrorKind::InvalidRequest | .invalidRequest | ErrorCategory::InvalidRequest | AUDD_ERR_INVALID_REQUEST |
| Invalid audio | audd.ErrInvalidAudio | ErrorKind::InvalidAudio | .invalidAudio | ErrorCategory::InvalidAudio | AUDD_ERR_INVALID_AUDIO |
| Stream limit | audd.ErrStreamLimit | ErrorKind::StreamLimit | .streamLimit | ErrorCategory::StreamLimit | AUDD_ERR_STREAM_LIMIT |
| Rate limit | audd.ErrRateLimit | ErrorKind::RateLimit | .rateLimit | ErrorCategory::RateLimit | AUDD_ERR_RATE_LIMIT |
| Blocked | audd.ErrBlocked | ErrorKind::Blocked | .blocked | ErrorCategory::Blocked | AUDD_ERR_BLOCKED |
| Server | audd.ErrServer | ErrorKind::ServerError | .server | ErrorCategory::Server | AUDD_ERR_SERVER |
| Server, no JSON body | audd.ErrServer | AudDError::Server | AudDError.serverError | ErrorCategory::Server | AUDD_ERR_SERVER |
| Connection | audd.ErrConnection | AudDError::Connection | AudDError.connection | ErrorCategory::Connection | AUDD_ERR_CONNECTION |
| Serialization | audd.ErrSerialization | AudDError::Serialization | AudDError.serializationError | ErrorCategory::Serialization | AUDD_ERR_SERIALIZATION |
Blocking and asynchronous calls
| SDK | Blocking | Asynchronous |
|---|---|---|
| Python | AudD | AsyncAudD, with the same methods, awaited |
| Node.js | none | every API call returns a Promise |
| Go | every method; each one that calls the API has a Context twin, such as RecognizeContext(ctx, source, nil) | none |
| Rust | none | every API call is async |
| PHP | every method | none |
| Swift | none | every API call is async; AudD is an actor |
| Kotlin | none | every API call is a suspend function |
| C# | none | API calls return a Task, and their names end in Async |
| Java | AudD | AsyncAudD, which returns a CompletableFuture |
| C | every function | none |
| 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.
