Exploring Audd.io's Public API

Audd.io is a powerful public API that provides music recognition and search capabilities for a wide array of audio applications. The API makes use of machine learning and deep neural networks to accurately identify song titles, artists, and even release years.

Here, we'll take a closer look at the Audd.io public API documentation and provide some sample JavaScript code snippets to help get you started.

The Basics

Before we dive in, you'll need to sign up for an API key on the Audd.io website. Once you have a key, you can use it to make API requests via HTTP GET requests (or POST requests for the more advanced features).

The base URL for all Audd.io API requests is:

https://api.audd.io/

Song Recognition

One of the key features of the Audd.io API is its ability to recognize songs from an audio file or a URL. To do this, you'll need to send a GET request to the recognize endpoint. Optionally, you can also include additional parameters to narrow down the search, including the music genre, lyrics, and more. Here's some sample code to get you started:

// Set up the request parameters
const fileUrl = 'https://www.example.com/audio.mp3';
const apiKey = 'your_api_key_here';
const recognizeUrl = `https://api.audd.io/recognize?url=${fileUrl}&api_token=${apiKey}&return=lyrics,spotify`;

// Send the request
fetch(recognizeUrl)
   .then(response => response.json())
   .then(data => {
      // Handle the response
      console.log(data);
   }) 

In this example, we've provided the audio URL and our API key to the recognize endpoint, and also indicated that we'd like to receive the lyrics and Spotify ID in the response data.

Lyrics Search

If you already know the lyrics to a song but aren't sure what it's called or who performs it, you can also use the Audd.io API to search for matches. The findLyrics endpoint provides this functionality. Here's some sample code to try it out:

// Set up the request parameters
const lyrics = 'I got sunshine on a cloudy day';
const apiKey = 'your_api_key_here';
const findLyricsUrl = `https://api.audd.io/findLyrics?q=${lyrics}&api_token=${apiKey}`;

// Send the request
fetch(findLyricsUrl)
   .then(response => response.json())
   .then(data => {
      // Handle the response
      console.log(data);
   }) 

In this example, we've provided the lyrics and our API key to the findLyrics endpoint. The response data will include a list of song matches, including the title, artist, and other metadata.

Closing Thoughts

The Audd.io public API is an incredibly powerful tool for anyone working with audio files or music search applications. With its deep neural network-based recognition capabilities and easy-to-use APIs, it's a great choice for developers and hobbyists alike. Remember, these code snippets are just a starting point - be sure to read through the full API documentation for all the details and options available to you.

Related APIs