# AGENTS.md: AudD music recognition API

Guide for AI coding agents adding AudD to a project. AudD is an HTTP API that identifies songs in audio: send a clip (URL, file, or bytes), a long file, or a live stream, and get back the artist, title, album, release date, label, and a universal `song_link` on lis.tn. Full reference: https://docs.audd.io/.md

## Installation

Use the official SDK for the project's language. Each one wraps the same HTTP API.

| Language | Install |
|---|---|
| Python | `pip install audd` |
| Node.js / TypeScript | `npm install @audd/sdk` |
| Go | `go get github.com/AudDMusic/audd-go` |
| Rust | `cargo add audd` |
| PHP | `composer require audd/audd` |
| Swift | `.package(url: "https://github.com/AudDMusic/audd-swift", from: "1.5.21")` |
| Kotlin | `implementation("io.audd:audd-kotlin:1.5.18")` |
| .NET / C# | `dotnet add package AudD` |
| Java | Maven Central `io.audd:audd:1.5.19` |
| C | CMake `FetchContent_Declare(audd GIT_REPOSITORY https://github.com/AudDMusic/audd-c.git GIT_TAG v1.5.18)` |
| C++ | CMake `find_package(audd CONFIG REQUIRED)`, link `audd::audd` |

Per-language docs: https://docs.audd.io/sdks.md (each SDK page also has a `.md` twin, e.g. https://docs.audd.io/sdks/python.md). With no SDK for the language, call the HTTP API directly: a `multipart/form-data` POST to `https://api.audd.io/`.

For shell scripts and terminal work, install the `audd` CLI:

```sh
npm install -g @audd/cli                 # Node.js
pipx install audd-cli                    # Python (or: uv tool install audd-cli)
brew install auddmusic/tap/audd          # macOS
go install github.com/AudDMusic/audd-cli/cmd/audd@latest
npx @audd/cli recognize song.mp3         # run without installing
```

Other install methods (Scoop, Windows installer, install script, Docker): https://docs.audd.io/cli.md

## Configuration

- Every request needs an API token, sent as the `api_token` form field. The user gets one at https://dashboard.audd.io. Don't invent or hard-code a token; use the placeholder `your-api-token` in examples and ask the user for theirs.
- The SDKs and the CLI read the token from the `AUDD_API_TOKEN` environment variable when it isn't passed to the constructor:

  ```sh
  export AUDD_API_TOKEN=your-api-token
  ```

- The public `test` token is for hello-worlds only: 10 requests/day, standard endpoint only. It does not work on the enterprise endpoint or streams. Don't ship it in production code.
- CLI: `audd login` signs in and fetches the token; `audd auth status` shows which token is in use.
- The standard endpoint has no rate limits: send requests in parallel, up to millions per hour. For a large volume, ask the user to tell AudD in advance at api@audd.io. The enterprise endpoint has a default limit on concurrent requests that AudD can raise on request.

## Usage

### Standard recognition (a short clip, one song)

```sh
curl https://api.audd.io/ \
  -F api_token=your-api-token \
  -F url=https://audd.tech/example.mp3
```

```python
from audd import AudD

audd = AudD()  # reads AUDD_API_TOKEN
result = audd.recognize("https://audd.tech/example.mp3")
if result:
    print(f"{result.artist} — {result.title}")
```

- `status == "success"` with `result == null` means the audio was processed and no song matched. Handle it as a normal outcome, not an error.
- Provider metadata is opt-in: pass `return=apple_music,spotify,deezer,musicbrainz` (SDKs: `return_metadata` / `returnMetadata` / `ReturnMetadata`). Each provider adds latency. `song_link` is always present.
- The standard endpoint has a 10 MB file-size cap.
- Errors return `status == "error"` with `error_code` and `error_message`; the SDKs raise typed exceptions grouped by category (authentication, quota, subscription, invalid request, server, connection, serialization).

### Enterprise endpoint (long files, video, multiple songs)

Use `https://enterprise.audd.io/` for full-length songs, short-form videos, podcasts, broadcasts, DJ sets, and any file with more than one song. It splits the file into chunks server-side and returns every match.

Enterprise bills 1 request per 12 seconds of audio. **Always set `limit`.** The unbounded default can process many hours of audio in one call. Use `limit=1` while developing.

```sh
curl https://enterprise.audd.io/ \
  -F api_token=your-api-token \
  -F url=https://audd.tech/djatwork_example.mp3 \
  -F limit=1
```

```python
matches = audd.recognize_enterprise("/path/to/broadcast.mp3", limit=1)
for m in matches:
    print(f"{m.timecode}  {m.artist} — {m.title}")
```

CLI: `audd recognize mix.mp3 --enterprise --limit 1` (`--limit` is required with `--enterprise`).

Reference: https://docs.audd.io/enterprise.md

### Streams and callbacks

To monitor live audio (radio, HLS, Icecast, Twitch, YouTube):

1. Set the account callback URL once with `POST https://api.audd.io/setCallbackUrl/` (`url=`). One callback URL per account, used by every stream.
2. Add each stream with `POST https://api.audd.io/addStream/` (`url=`, `radio_id=` any integer you pick). Shortcuts: `twitch:<channel>`, `youtube:<video_id>`, `youtube-ch:<channel_id>`.
3. AudD POSTs each match (a `result` block) and each lifecycle event (a `notification` block) to the callback URL. Set `callbacks=before` on `addStream` to get matches when a song starts instead of when it ends.

Other methods: `getStreams`, `setStreamUrl`, `deleteStream`, `getCallbackUrl`.

**Longpoll** (part of streams): when the code can't expose a public callback URL (browser, mobile, scripts behind NAT), receive stream events with `GET https://api.audd.io/longpoll/`. The account still needs a callback URL configured, or longpoll may never return events. With no real receiver, set it to `https://audd.tech/empty/`, which discards incoming POSTs. The SDKs wrap longpoll, for example `audd.streams.longpoll(radio_id=1)` in Python.

Reference: https://docs.audd.io/streams.md

## Links

- llms.txt (index of the docs as markdown): https://docs.audd.io/llms.txt
- Agent guide with the response schema and common mistakes: https://docs.audd.io/skill.md
- Markdown sitemap of every docs page: https://docs.audd.io/sitemap.md
- MCP server for account management (usage, token, plans): https://docs.audd.io/mcp.md
- CLI reference: https://docs.audd.io/cli.md
- SDK index: https://docs.audd.io/sdks.md
- Worked guides and recipes: https://audd.io/resources/llms.txt
- Glossary of AudD terms (endpoints, result fields, billing, streams): https://audd.io/resources/reference/glossary.md
- Dashboard (token, plans, usage): https://dashboard.audd.io
- Questions: api@audd.io
