---
title: "AudD for hardware and IoT makers"
description: "How a speaker, car unit, display or kiosk can name the song playing near it with AudD: the device records a clip, your server sends it to AudD with your token, and the device shows the song. With the C and C++ SDKs, clip sizes, and what a device that listens all day costs."
slug: "/resources/for/hardware-and-iot-makers"
section: "for"
keywords: [audd, hardware, iot, embedded, c sdk, c++ sdk, cmake, libcurl, smart speaker, car audio, kiosk, display, microphone, line input]
---

# AudD for hardware and IoT makers

If you're building a device that plays or hears music, like a speaker, a car unit or a kiosk, you can use our API to show the song that's playing. The device records 10 seconds of audio and sends the recording to your server. Your server sends the recording to AudD's Music Recognition API with your token. AudD's response will contain the title and artist of the song, and a link to the song's lis.tn page, and the device shows them. We recognize the music on our servers, so the device has to be online.

Your server sends the clip to our standard endpoint like this:

```bash
curl https://api.audd.io/ \
    -F api_token='your-api-token' \
    -F file=@clip.wav
```

```json
{
  "status": "success",
  "result": {
    "artist": "Tears For Fears",
    "title": "Everybody Wants To Rule The World",
    "album": "Songs From The Big Chair",
    "release_date": "2014-11-10",
    "label": "UMC (Universal Music Catalogue)",
    "timecode": "00:56",
    "song_link": "https://lis.tn/NbkVb"
  }
}
```

You can get a token from our [API Dashboard](https://dashboard.audd.io). The API itself is so simple that it can easily be used even without an SDK, and if your code is in C or C++, our C and C++ SDKs make the same call.

## What you can build

### Show the song that's playing

The device sends a clip when someone presses a button, and shows the song we found. We add the URL of a song page with links to the streaming platforms to every result, in `song_link`, so the device can show it as a QR code. And `timecode` is the time in the recognized song when the fragment you sent is played, so the device knows how far into the song it is.

### Keep a log of what a device hears

A device in a bar, a shop or a gym can keep a log of the songs played there, from a microphone or from a line input from the amplifier. [AudD for venues and background music suppliers](/resources/for/venues-and-background-music) shows how to do so.

### Follow an internet radio station

If the device plays internet radio, you don't have to send clips at all. We wanted to make the API as simple as possible: you send us the URLs of radio streams, and we send you the recognition results in real time. The music recognition costs $45 per audio stream per month, however many devices play the station, and your server passes each song on to them. As the URL of the audio stream, you can simply send the URL the devices play: see [Icecast, SHOUTcast and AzuraCast](/resources/integrations/internet-radio-servers).

## Keep the token on your server

All the API requests require the `api_token` from the Dashboard, but please don't include your API tokens in the software that ships with your devices. If you put your token in a device, anyone who has the device can use the token to access the AudD API with your account. Once a token has shipped in a device, you should consider the token compromised.

So the device sends the clip to your server, and your server calls us with the token. Your server checks the request, sends the clip to AudD, and sends back only the fields the device shows. If there are no matches, the device asks the user to try again.

There are no rate limits on the standard endpoint: you can send requests in parallel, as many as you need, and so can anyone with your token. Your server should limit how often a device can call it, since the standard endpoint won't. [Keeping your API token on the server](/resources/concepts/keeping-your-token-server-side) has a complete server with a size cap and a per-client limit, and the device can post the clip to it in the `file` field.

Devices that you run yourself are a different case, since the token never leaves your hands: a prototype on your desk, or the [Raspberry Pi next to your turntable](/resources/recipes/vinyl-scrobbler-raspberry-pi). A device in which each owner enters their own AudD token is fine too.

## Record a clip

The standard endpoint analyzes up to the first 12 seconds of audio, so the device records 10 seconds. A 16-bit stereo WAV file of 10 seconds takes about 1.8 MB at 44,100 Hz, and the standard endpoint accepts files up to 10 MB. If the device is on a cellular connection, send MP3 or AAC instead: it's smaller. [Audio formats and quality](/resources/concepts/audio-format-and-quality) lists the formats we accept, and [Cut and convert clips with ffmpeg](/resources/recipes/ffmpeg-clips-for-recognition) has the commands to convert a recording.

The device can record from a microphone or from a line input. With a line input, we only get the music; with a microphone, we also get the room and the people in it. Before you ship, test the device with the audio it will hear in use. If you want to record the clips on a Raspberry Pi, follow the steps in the [vinyl scrobbler recipe](/resources/recipes/vinyl-scrobbler-raspberry-pi): it records them with `arecord` and skips the quiet ones.

## The C and C++ SDKs

Our [C SDK](https://docs.audd.io/sdks/c) needs a C99 compiler, CMake 3.16 or later, and libcurl with its development headers:

```bash
sudo apt-get install libcurl4-openssl-dev cmake   # Debian, Ubuntu
brew install curl cmake                           # macOS
```

Our [C++ SDK](https://docs.audd.io/sdks/cpp) requires a C++17 compiler and libcurl. The C SDK uses POSIX threads. Both SDKs are built and tested on Ubuntu and macOS. If your device runs another system, build the SDK there with `-DAUDD_BUILD_TESTS=ON` and run `ctest` before you rely on it.

You can add the C SDK to your CMake project with `FetchContent`:

```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)
```

The following example from the SDK identifies the song in a local file:

```c
/* recognize_file.c — identify a song from a local file path.
 *
 * Run:
 *   ./recognize_file /path/to/clip.mp3
 */
#include <audd.h>

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    if (argc < 2) {
        fprintf(stderr, "usage: %s <file.mp3>\n", argv[0]);
        return 2;
    }
    /* Token from AUDD_API_TOKEN if set, else built-in "test" demo. */
    audd_client_t *client = audd_client_new(NULL, NULL);
    if (audd_client_api_token(client) == NULL) {
        audd_client_set_api_token(client, "test");
    }
    audd_recognition_t *r = NULL;
    audd_error_t e = audd_recognize(client, argv[1], NULL, &r);
    if (e != AUDD_OK) {
        fprintf(stderr, "%s\n", audd_last_error_message(client));
        audd_client_free(client);
        return 1;
    }
    if (r == NULL) {
        printf("no match\n");
    } else {
        printf("matched: %s — %s\n",
               audd_recognition_get_artist(r),
               audd_recognition_get_title(r));
        if (audd_recognition_get_album(r))
            printf("album:    %s\n", audd_recognition_get_album(r));
        if (audd_recognition_get_release_date(r))
            printf("released: %s\n", audd_recognition_get_release_date(r));
        if (audd_recognition_get_label(r))
            printf("label:    %s\n", audd_recognition_get_label(r));
        if (audd_recognition_get_song_link(r))
            printf("link:     %s\n", audd_recognition_get_song_link(r));
        audd_recognition_free(r);
    }
    audd_client_free(client);
    return 0;
}
```

To build the examples and run this one, use the following commands:

```bash
git clone --branch v1.5.18 --depth 1 https://github.com/AudDMusic/audd-c
cmake -S audd-c -B audd-c/build -DCMAKE_BUILD_TYPE=Release -DAUDD_BUILD_EXAMPLES=ON
cmake --build audd-c/build -j
AUDD_API_TOKEN=your-api-token ./audd-c/build/examples/recognize_file clip.wav
```

```text
matched: Tears For Fears — Everybody Wants To Rule The World
album:    Songs From The Big Chair
released: 2014-11-10
label:    UMC (Universal Music Catalogue)
link:     https://lis.tn/NbkVb
```

Without `AUDD_API_TOKEN`, the example uses the public `test` token, which allows 10 requests a day. If the device has the clip in memory and not in a file, call `audd_recognize_bytes(client, data, size, NULL, &r)` instead. Each recognition call returns an `audd_error_t`: `audd_last_error_message(client)` has the message, and `audd_last_error_code(client)` has our error code.

In C++, `client.recognize()` takes a URL or a file path as a string, or `audd::SourceBytes` for audio in memory, and every blocking method has an `_async` twin that returns a `std::future`. The C++ SDK's README shows how to link it with `find_package(audd CONFIG REQUIRED)` and `audd::audd`.

## What it costs

Every clip you send to the standard endpoint counts as one request. Normally, our plans include as-you-go pricing: some number of requests is included with your monthly bill, but you can send requests on top of what's included and will be charged for those separately. The requests from all your devices add up. In a 30-day month:

```text
1 device, a clip every minute, 12 hours a day:  21,600 requests   $5 + 20.6 × $5.00 = $108  (Indie)
1 device, a clip every minute, 24 hours a day:  43,200 requests   $5 + 42.2 × $5.00 = $216  (Indie)
100 devices, 1,000 clips a month each:         100,000 requests   $450                      (Startup)
```

Indie is $5 per month with 1,000 requests, then $5.00 per 1,000, and Startup is $450 per month with 100,000 requests, then $4.50 per 1,000. A clip every minute also uploads about 1.3 GB of CD-quality WAV in 12 hours. From about 188,900 requests a month, the Pro plan is the cheapest, and for higher volumes, pricing is custom, going down to about $2 per 1,000 at very large volumes. If you want a hard monthly cap on requests, email [api@audd.io](mailto:api@audd.io) and we'll set one on your account. The prices are from our [pricing page](https://audd.io/pricing/).

### Send fewer clips

If you don't want every clip to be recognized and counted as a request, don't send the quiet ones: the device can measure how loud each clip is before it sends it. After we recognize the song, the device can stop sending clips until the song ends. To know when that is, ask for the Spotify metadata (`return=spotify`): the Spotify block has the length of the track, and the `timecode` is the time in the song when the clip you sent is played. And after a clip that didn't match, the device can wait 30 seconds, like the [vinyl scrobbler](/resources/recipes/vinyl-scrobbler-raspberry-pi) does.

## When `result` is null

If the server has successfully processed the request, but there are no matches, the `result` field is `null`. In the C SDK, the call returns `AUDD_OK` and the result stays `NULL`, and the example prints `no match`. It's not an error, so there's nothing to retry automatically: let the user press the button again. If the music was quiet, or the recording was mostly talking, try again when the music is louder.

## When the network fails

If the device can't connect to your server, it should show a message and try again later. We don't recommend retrying in a tight loop: a cancelled request might still consume requests. On your server, the C SDK retries a recognition that failed before the upload, or that got an HTTP 5xx response, up to 3 attempts by default. The C++ SDK retries only the failures that happened before the upload. Neither of them retries a request that timed out or lost its connection after the upload, because that request might still be counted. The [Error codes](/resources/reference/errors) page explains what our errors mean.

## What happens to the audio

A request carries only the audio, your token, and the recognition settings, with no user identifiers. All API calls use HTTPS, and the audio is fingerprinted and then discarded. If a microphone recording must never leave your own infrastructure, we can deploy our recognition on your servers: email [api@audd.io](mailto:api@audd.io).

---

**Related**

- [Keeping your API token on the server](/resources/concepts/keeping-your-token-server-side)
- [Scrobble your vinyl to Last.fm with a Raspberry Pi](/resources/recipes/vinyl-scrobbler-raspberry-pi)
- [Icecast, SHOUTcast and AzuraCast: the stream URL to give AudD](/resources/integrations/internet-radio-servers)
- [AudD for venues and background music suppliers](/resources/for/venues-and-background-music)
- [Limits](/resources/reference/limits)
- [C SDK docs](https://docs.audd.io/sdks/c)

## Sitemap

See the [resources sitemap](https://audd.io/resources/sitemap.md) for every guide and the [glossary](https://audd.io/resources/reference/glossary.md) for AudD terms.
