What is the AllCDCovers API

The AllCDCovers API has been created to allow our partners to easily add content to their site, by integrating our content into their design.

The API allows full-freedom in how you use the content you retrieve, and is a great way to add that extra something to your site.

To use the API you must apply for an API Developer user name and key. When applying please provide as many details possible about your intended use of the API.

Thank you for trying out the AllCDCovers API.

How to use the API

The API accepts REST requests and returns results as a simple XML file.

To receive an XML file with search results, send a request to a url formatted like this:

http://www.allcdcovers.com/api/search/:user_name:/:query_hash:/:search_phrase:

Let's say, for example, that your username is lennon_22, your secret key is BJz2LYhjOB4grzD8fhrt49rviSW3yvKT and you are searching for "beatles love".

The query_hash for this search is the md5 hash of your user name and the search phrase.

Note that all sample code in this page is written in PHP and uses the SimpleXML functions.

Here is an example of constructing a url for a cover search:

  1. <?php
  2. $user_name = 'lennon_22';
  3. $secret_key = 'BJz2LYhjOB4grzD8fhrt49rviSW3yvKT';
  4. $search_phrase = 'beatles love';
  5. $query_hash = md5($secret_key.$search_phrase);
  6. // $query_hash = 15ebb4f2c2664512db7a2f7f955f2172
  7. $xml_request_url = 'http://www.allcdcovers.com/api/search/'.$user_name.'/'.$query_hash.'/'.urlencode($search_phrase);
  8. ?>

To retrieve the xml results file, simply send a query to the url we constructed in the previous step:

  1. $xml = new SimpleXMLElement($xml_request_url, null, true);

The results you will receive in XML will take this form:

  1. <rsp stat="ok" version="1.0">
  2.   <title>
  3.     <name>Beatles - Love (2006) Retail CD</name>
  4.     <id>3526</id>
  5.     <category>Music</category>
  6.     <subcategory>Albums</subcategory>
  7.     <image>http://www.allcdcovers.com/image_system/images/f/e/fe4872d55f2466abac060bbef03b47df.jpg</image>
  8.     <covers>
  9.       <cover>
  10.         <type>Front</type>
  11.         <width>1438</width>
  12.         <height>1405</height>
  13.         <filesize>388343</filesize>
  14.         <uploaded_at>2007-02-14 20:02:35</uploaded_at>
  15.         <average_rating>4</average_rating>
  16.         <url>http://www.allcdcovers.com/show/3526/beatles_love_2006_retail_cd/front</url>
  17.         <thumbnail>http://www.allcdcovers.com/image_system/covers_th/5/2/5203d85ecdb700645a1232c850139ffa.jpg</thumbnail>
  18.       </cover>
  19.         <cover>
  20.         <type>Back</type>
  21.         <width>1773</width>
  22.         <height>1379</height>
  23.         <filesize>436556</filesize>
  24.         <uploaded_at>2007-02-14 20:02:35</uploaded_at>
  25.         <average_rating>5</average_rating>
  26.         <url>http://www.allcdcovers.com/show/3526/beatles_love_2006_retail_cd/back</url>
  27.         <thumbnail>http://www.allcdcovers.com/image_system/covers_th/c/1/c1d27a022bf1b44349daf5660d969d38.jpg</thumbnail>
  28.       </cover>
  29.     </covers>
  30.   </title>
  31. </rsp>

Now all you have to do is go over the results file and format your output.

  1. foreach ($xml as $title) {
  2.   echo 'Title: '.$title->name;
  3.   echo 'Category: '.$title->category.': '.$title->subcategory;
  4.   echo 'Image: '.$title->image;
  5.   foreach ($title->covers->cover as $cover) {
  6.     echo 'Cover type:'.$cover->type;
  7.     echo 'Resolution:'.$cover->width.' '.$cover->height;
  8.     echo 'Filesize:'.$cover->filesize;
  9.     echo 'Upload date:'.$cover->uploaded_at;
  10.     echo 'Average rating:'.$cover->average_rating;
  11.     echo 'Download page:'.$cover->url;
  12.     echo 'Thumbnail:'.$cover->thumbnail;
  13.   }
  14. }
  15. ?>

Limiting results by category

You can limit the results returned to just one category of titles - such as music, movies or games - by adding the category name to the end of the request url.

For example, a search for Beatles covers:

http://www.allcdcovers.com/api/search/lennon_22/15ebb4f2/beatles

Becomes a search for Beatles movie covers:

http://www.allcdcovers.com/api/search/lennon_22/15ebb4f2/beatles/movies

Complete working example

The following example connects to the site, retrieves all results for "beatles love" and displays them.

  1. <?php
  2. $user_name = 'lennon_22';
  3. $secret_key = 'BJz2LYhjOB4grzD8fhrt49rviSW3yvKTs';
  4. $search_phrase = 'beatles love';
  5. $query_hash = md5($secret_key.$search_phrase);
  6. $xml_request_url = 'http://www.allcdcovers.com/api/search/'.$user_name.'/'.$query_hash.'/'.urlencode($search_phrase);
  7. $xml = new SimpleXMLElement($xml_request_url, null, true);
  8. if (isset($xml->err)) {
  9.   echo $xml->err['msg'];
  10. } else {
  11.   foreach ($xml as $title) {
  12.     echo 'Title: '.$title->name;
  13.     echo 'Category: '.$title->category.': '.$title->subcategory;
  14.     echo 'Image: '.$title->image;
  15.     echo 'Image: '.$title->image;
  16.     foreach ($title->covers->cover as $cover) {
  17.       echo 'Cover type:'.$cover->type;
  18.       echo 'Resolution:'.$cover->width.' '.$cover->height;
  19.       echo 'Filesize:'.$cover->filesize;
  20.       echo 'Upload date:'.$cover->uploaded_at;
  21.       echo 'Average rating:'.$cover->average_rating;
  22.       echo 'Download page:'.$cover->url;
  23.       echo 'Thumbnail:'.$cover->thumbnail;
  24.     }
  25.   }
  26. }
  27. ?>

And that's it… Simple as that.


AllCDCovers API

Developers, check out our new API that lets you integrate album art and content from AllCDCovers into your website, blog, widget and iTunes software.

Upload Contest

Do you have CD/DVD covers that we don't? Upload your album art now and auto enroll in our monthly upload contest. Visit our homepage for more details.

About AllCDCovers

AllCDCovers is a community driven website offering free high quality album art for non commercial use. All the CD and DVD covers are uploaded, approved and ranked by our users. Join AllCDCovers Now!