December 2, 2008, Tuesday, 336

BTPWS-Search

From DBWiki

Jump to: navigation, search

Search for Song Example

Performing a Search

To perform a search you must have already retrieved an API key. Searches are helpful when you want to find out if something is available for sale via Bitmunk. To perform a search, you must do the following:

http://www.sandbox.bitmunk.com:9080/api/xml/search

Your GET request should contain the following URL-encoded parameters:

  • apiKey - The API key that was given to you. (required)
  • query - This should be the search string. (required)
  • mediaType - The media type that you want to search in. As of June 2007 this includes 'audio_album', 'audio_song', 'video_music', 'video_clip', 'video_episode', and 'video_movie'. (optional. default: 'audio_song')
  • sellable - Whether or not you want to also display items that are not sellable. 'true' if you want to display only sellable items, 'false' if you want to display sellable AND non-sellable items. (optional. default: 'true')
  • sortField - The field the results will be sorted on. Either 'title' or 'creator'. (optional. default: 'title')
  • sortDirection - The direction to sort the results. Either 'ascending' or 'decending'. (optional. default: 'ascending')

The formatted GET request should look like this:

GET /api/xml/search?apiKey=416a&mediaType=audio_song&sellable=true&query=bitmunk+squad HTTP/1.1
Host: www.sandbox.bitmunk.com:9080
User-Agent: MySoftware/1.2

The following XML will be returned to you:

<?xml version="1.0" encoding="UTF-8"?>
<xml_response version="1.0">
 <search_result version="2.0">
  <time>48</time>
  <result type="media_id">
   <list>6491443,6491444,6491445,6491446</list>
  </result>
  <media type="audio_song">
   <searched_term>bitmunk</searched_term>
   <searched_term>squad</searched_term>
  </media>
 </search_result>
</xml_response>

Populating Search Data

You can retrieve full media information for any digital work available on Bitmunk. Typically, the first two steps are retrieving an API key and making a search call. You will receive a list of media info IDs. You can then take these media info IDs and fill out the information for each media info ID by hitting the following URL:

http://www.sandbox.bitmunk.com:9080/api/xml/mediainfo/populate

Your GET request should contain the following URL-encoded parameters:

  • apiKey - The API key that was given to you.
  • mediaIds - This should be a comma-separated list of all of the media info IDs.

The formatted GET request should look like this:

GET /api/xml/mediainfo/populate?apiKey=416a&mediaIds=6491443,6491444 HTTP/1.1
Host: www.sandbox.bitmunk.com:9080
User-Agent: MySoftware/1.2

The following XML will be returned to you:

<?xml version="1.0" encoding="UTF-8"?>
<xml_response version="1.0">
 <media_info_set version="2.0">
  <media_info version="2.0" id="6491443" type="audio_song">
   <owner_id>32073</owner_id>
   <sellable>1</sellable>
   <status>claimed</status>
   <creator>Bitmunk Squad</creator>
   <title>Bitmunk Squad Theme Song</title>
   <sample_range>10:40</sample_range>
   <parent_media_ids/>
   <child_media_ids/>
   <details>
    <release_date>2007-01-12</release_date>
    <category>audio</category>
    <distribution_formats>mp3-bmwm</distribution_formats>
    <banned_countries/>
    <isrc/>
    <creator_description_id>0</creator_description_id>
    <artist>Bitmunk Squad</artist>
    <track>1</track>
    <length>0</length>
    <genre/>
    <publisher>Bitmunk Industrial Recording
1 Bitmunk Offices
Blacksburg VA, 24060</publisher>
    <publisher_description_id>0</publisher_description_id>
    <composer/>
    <composer_description_id>0</composer_description_id>
    <content_rating>not_rated</content_rating>
    <audio_albums/>
    <mixed_albums/>
    <cover_song>0</cover_song>
    <licenses>sc,sc-p2p,sc-wb</licenses>
    <picture_id>0</picture_id>
    <short_description>This song is a test song for purchase.</short_description>
    <long_description>This song is a test song for purchase on our sandbox open source
server.</long_description>
   </details>
   <royalties>
    <payee version="2.0" id="41067">
     <amount version="2.0" currency="usd">0.496</amount>
     <source>sva</source>
     <reason>Bitmunk Squad Artist Royalty</reason>
     <media_id>6491443</media_id>
    </payee>
    <payee version="2.0" id="1032">
     <amount version="2.0" currency="usd">0.0535</amount>
     <source>Bitmunk Records</source>
     <reason>Music Label Digital Distribution Fee</reason>
     <media_id>6491443</media_id>
    </payee>
   </royalties>
  </media_info>
  <media_info version="2.0" id="6491444" type="audio_song">
   <owner_id>32073</owner_id>
   <sellable>1</sellable>
   <status>claimed</status>
   <creator>Bitmunk Squad</creator>
   <title>Bitmunk Love Ballad</title>
   <sample_range>10:40</sample_range>
   <parent_media_ids/>
   <child_media_ids/>
   <details>
    <release_date>2007-01-12</release_date>
    <category>audio</category>
    <distribution_formats>mp3-bmwm</distribution_formats>
    <banned_countries/>
    <irc/>
    <creator_description_id>0</creator_description_id>
    <artist>Bitmunk Squad</artist>
    <track>1</track>
    <length>0</length>
    <genre/>
    <publisher>Bitmunk Industrial Recording
1 Bitmunk Offices
Blacksburg VA, 24060</publisher>
    <publisher_description_id>0</publisher_description_id>
    <composer/>
    <composer_description_id>0</composer_description_id>
    <content_rating>not_rated</content_rating>
    <audio_albums/>
    <mixed_albums/>
    <cover_song>0</cover_song>
    <licenses>sc,sc-p2p,sc-wb</licenses>
    <picture_id>0</picture_id>
    <short_description>This song is a test song for purchase.</short_description>
    <long_description>This song is a test song for purchase on our sandbox open source
server.</long_description>
   </details>
   <royalties>
    <payee version="2.0" id="41067">
     <amount version="2.0" currency="usd">0.465</amount>
     <source>sva</source>
     <reason>Bitmunk Squad Artist Royalty</reason>
     <media_id>6491444</media_id>
    </payee>
    <payee version="2.0" id="1032">
     <amount version="2.0" currency="usd">0.0535</amount>
     <source>Bitmunk Records</source>
     <reason>Music Label Digital Distribution Fee</reason>
     <media_id>6491444</media_id>
    </payee>
   </royalties>
  </media_info>
 </media_info_set>
</xml_response>