VL Group

Rhymba v3.6 Documentation

Search In The Browser

We've developed our own AJAX-based Rhymba Search client as a quick and easy way of accessing the OData search endpoints from the browser, which we'd like to share with you. With your Rhymba Access Token handy, you'll be able to start querying our media catalog in just a few simple steps.

  1. First get yourself a current version of jQuery, because it's great, and also because the Rhymba javascript libraries need it to work.
  2. Second, add the Rhymba Search script at this link to your page. We recommend adding it shortly before your closing </body> tag so that it won't get in the way of your page's content.
  3. In a new <script> tag, use your Access Token to create a Rhymba Search Client, like so:
    	var myClient = rhymba.search.Client("[YourContentToken]");
  4. This is where you might want to have a look at our OData Search introduction, if you haven't already. If you have, the next part is going to look pretty familiar.

    Every Rhymba Search Client has three methods - .media(), .artists(), and .albums() - corresponding to the Rhymba Search endpoints. These methods each return a configurable Search Request object with methods corresponding to the OData Search parameters. You can chain calls to these methods together to configure your search:

    	var myMediaSearch = myClient.media()
    		.filter("[OData Filter String]")
    		.format("[Format String]");
  5. Once you've configured your search, fire it off by calling the search request's .get() method with callbacks for successful and unsuccessful responses:


    That's all it takes! The success callback will receive the same results any other call to its Rhymba Search endpoint, letting you quickly get on with the business of displaying those search results to your users.

The Rhymba Search Client

The Rhymba Search Client lets you quickly create new searches targeting each of the Rhymba Content endpoints - media, artists, and albums. Each of its corresponding methods generates a new Search Request object configuring a search for that endpoint.


Field Name Type Description Example
token string A javascript string containing your Rhymba Access Token. Required.
token: "[YourRhymbaAccessToken]"

Search Methods

Name Arguments Description Returns Example
media   Creates and returns a new Search Request object for the Media search endpoint. Search Request
var mySearch = myClient.media();
artists   Creates and returns a new Search Request object for the Artists search endpoint. Search Request
var mySearch = myClient.artists();
albums   Creates and returns a new Search Request object for the Albums search endpoint. Search Request
var mySearch = myClient.albums();

Search Requests

Search Requests are handy little objects, each of which encapsulates an individual AJAX request to the Rhymba Search API. Each has methods corresponding to the API fields, which you can use to configure the search that the particular Search Request instance will perform. These configuration methods all return the Search Request object itself, making it easy to quickly configure and perform a search by chaining your method calls together. When you've finished configuring a given search, you execute it by calling the Search Request instance's .get() method with callback function arguments for success and error responses.

Configuration Methods

Name Arguments Description Returns Example
keyword string Sets a word or phrase as the keyword for the search. Search Request
mySearch.keyword("Fifth Symphony");
filter string Sets an OData filter for the search. See here for details on constructing an OData filter string for this method. Search Request
mySearch.filter("upc eq 123456");
byIds array[ integer... ] Takes an Array of javascript numbers (or numeric strings) indicating specific media ids to search for details on. Search Request
mySearch.byIds([111, 222, 333]);
skip integer Sets an offset in the number of results to return, measured from the first (likeliest) item in the results. Useful for paging. Search Request
top integer Sets the number of search results to return, counting from the value of 'skip'. Search Request
inlineCount "allpages" Sets the value of the 'inlineCount' parameter for this search. Currently, the only valid values are "allpages" (inlinecount included) or NULL (inlinecount not included). Search Request
getParameter string Gets the current value of a named Search Request configuration parameter. Search Request

REST Methods

Name Arguments Description Returns Example
get function(result), function(error) Executes the Search Request as currently configured. The "get" method takes two callback functions as arguments: the first for successful AJAX responses, and the second for error responses. XHR
   function(result, response, xhr){
      console.log("result:", result);
   function(xhr, response){
      console.log("search error");