User avatar
zag
Site Admin
Site Admin
Posts: 1115
Joined: Wed Jun 06, 2012 9:19 am
Country: United Kingdom

API Tutorial

Thu Jul 12, 2012 6:32 pm

TheAudioDB.com has a Free API that provides data in JSON format.

*UPDATE: 2013* - The API (v1) is now stable and is final
*TIP* - If you would like to view the JSON in Google Chrome, check out this JSON Formatter Extension

General search calls
Return Artist details from artist name
http://www.theaudiodb.com/api/v1/json/{APIKEY}/search.php?s={Artist name}
Example - http://www.theaudiodb.com/api/v1/json/1 ... s=coldplay

Return all Album details from artist name
http://www.theaudiodb.com/api/v1/json/{APIKEY}/searchalbum.php?s={Artist name}

Return single album details from artist + album name
http://www.theaudiodb.com/api/v1/json/{APIKEY}/searchalbum.php?s={Artist name}&a={Album name}

Return single album details from album name
http://www.theaudiodb.com/api/v1/json/{APIKEY}/searchalbum.php?a={Album name}

Return track details from artist/track name
http://www.theaudiodb.com/api/v1/json/{APIKEY}/searchtrack.php?s={Artist_Name}&t={Single_Name}

Return Discography for an Artist with Album names and year only
http://www.theaudiodb.com/api/v1/json/{APIKEY}/discography.php?s={Artist_Name}

Return Discography for an Artist with Album names and year only using known MBID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/discography-mb.php?s={Music_Brainz_Artist_ID}



Artist Data
Return individul Artist details using known TADB_Artist_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/artist.php?i={artistid}

Return individual Artist info using a known MusicBrainz_Artist_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/artist-mb.php?i={mb_artist_id}



Album Data
Return All Albums for an Artist using known TADB_Artist_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/album.php?i={artistid}

Return individual Album info using known TADB_Album_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/album.php?m={albumid}

Return individual Album info using a known MusicBrainz_Release-Group_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/album-mb.php?i={mb_release-group_id}



Track Data
Return All Tracks for Album from known TADB_Album_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/track.php?m={albumid}

Return individual track info using a known TADB_Track_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/track.php?h={trackid}

Return individual track info using a known MusicBrainz_Recording_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/track-mb.php?i={mb_recording_id}



Music Videos
Return all the Music videos for a known TADB_Artist_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/mvid.php?i=(artistid}

Return all the Music videos for a known Music_Brainz_ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/mvid-mb.php?i=(MbArtistID}

Return a Music DVD from artist/mdvd name
http://www.theaudiodb.com/api/v1/json/{APIKEY}/searchmdvd.php?s={Artist_Name}&a={Music_Dvd_Name}



Top 10 Tracks
Return The top 10 Most Loved tracks for an Artist Name
http://www.theaudiodb.com/api/v1/json/{APIKEY}/track-top10.php?s=(artistname}

Return The top 10 Most Loved tracks for an Artist Music Brainz ID
http://www.theaudiodb.com/api/v1/json/{APIKEY}/track-top10-mb.php?s=(Music_Brainz_Artist_ID}


Images
Preview Images
Most of the time you won't want to download the original large image, just get a small preview. This is possible simple by adding "/preview" onto the end URL. This will give you a small 200px version. This will work with TheAudioDB.com and Fanart.tv URL's in exactly the same way hopefully :)

Original Image - http://www.theaudiodb.com/images/media/ ... 291734.jpg
Small Image - http://www.theaudiodb.com/images/media/ ... pg/preview

User avatar
zag
Site Admin
Site Admin
Posts: 1115
Joined: Wed Jun 06, 2012 9:19 am
Country: United Kingdom

Re: API Tutorial

Thu Mar 03, 2016 1:26 pm

Listing user ratings via the api

List every rating made by a user
http://www.theaudiodb.com/api/v1/json/{apikey}/ratings-album.php?user={username}
http://www.theaudiodb.com/api/v1/json/{apikey}/ratings-track.php?user={username}

Example
http://www.theaudiodb.com/api/v1/json/1 ... =Arturo007


Submitting user ratings via the api

Submit Rating via API
www.theaudiodb.com/api/v1/json/{apikey}/submit-album.php?user={user}&artist={artist}&album={album}&rating={1-10}&api={apitoken}
www.theaudiodb.com/api/v1/json/{apikey}/submit-track.php?user={user}&artist={artist}&album={album}&track={track}&rating={1-10}&api={apitoken}

Example (with api token removed)
http://www.theaudiodb.com/api/v1/json/1 ... ing=7&api=
http://www.theaudiodb.com/api/v1/json/1 ... ing=7&api=

You can find the API token for on the user page, top right on the menu click on your username (it will only show up if you are logged in as yourself).

http://www.theaudiodb.com/user/username

Image

API also provides a responses in JSON like this:

{"result":"SUCCESS New rating"}
{"result":"SUCCESS Updated rating"}
{"result":"ERROR No item found"}
{"result":"ERROR Missing input"}

User avatar
zag
Site Admin
Site Admin
Posts: 1115
Joined: Wed Jun 06, 2012 9:19 am
Country: United Kingdom

Re: API Tutorial

Thu Apr 14, 2016 2:41 pm

Current Trending Music

http://www.theaudiodb.com/api/v1/json/1/trending.php?country=us&type=itunes&format=albums
http://www.theaudiodb.com/api/v1/json/1/trending.php?country=us&type=itunes&format=singles

Parameters:

type: itunes (only for now but will extend in future to more sources)
country: Imageus Image gb Imagede Image fr Image it
format: albums, singles

User avatar
zag
Site Admin
Site Admin
Posts: 1115
Joined: Wed Jun 06, 2012 9:19 am
Country: United Kingdom

Re: API Tutorial

Tue Feb 28, 2017 4:23 pm

Song Hash Lookup

Code: Select all

http://www.theaudiodb.com/api/v1/json/{APIKEY}/search-hash.php?h1={Hash1}&h2={Hash2}

http://www.theaudiodb.com/api/v1/json/1 ... B8090D16CB

NOTE: At the moment both hashes are required and must each be 16 characters long

Return to “Developers”