2. API Usage

Calling the API

You can extend the carquery javascript object by writing your own API calls. Here’s how:
//NOTE: Inside the carquery object, this.base_url will contain the location of the current version of the CarQuery API

$.getJSON(this.base_url+"?callback=?", {cmd:"getMakes", year:"2009"}, function(data) {

   //The 'data' variable contains all response data.
   var makes = data.Makes;
   for (var i = 0; i < makes.length; i++)
   {
       //You can now do what you like with the response data
       alert(makes[i].make_display);
   }
});
$.getJSON is a jQuery method with asynchronously retrieves data from a remote API. When the API response is received, the code inside the provided function is executed. Please see the jQuery.getJSON() documentation for more information. In this example the following parameters are passed to the CarQuery api:

cmd: specifies the API function. For information on the available functions see the API Functions section below.
year: specifies the year filter. The API will return all makes which produced a model in this year.

API Functions

Click a function name to display documentation.

GetYears

GetMakes

GetModels

GetTrims

GetModel