Google AJAX API - How do I get more than 4 Results? Google AJAX API - How do I get more than 4 Results? json json

Google AJAX API - How do I get more than 4 Results?


I believe the only way to do that is to make multiple calls to the webservice specifying the 'start' parameter.

http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=Apple+Cake&start=4

The start parameter is the 0-based index into the search results. So in this example, it would return images 4..7.

You can also add the parameter rsz=[1-8]. The default value is 4. That's why you're getting 4 results per request. Here's a link:
http://code.google.com/apis/imagesearch/v1/jsondevguide.html#basic_query


For those of you wondering how to do this, there are quite a few ways. One would be to run a looping query based on a certain event. So, for instance...

var biebresults = [], start = 0;function getBieb(startNumber){    $.getJSON("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=Justin%20Bieber&start="+startNumber+"&callback=?", function(results){        biebresults.push(results.responseData.results);        if(biebresults.length < 538){            start = start + 4;            getBieb(start);        } else {            // Do something with your billion bieb images.        }    });}getBieb(start);

This particular bit of code (using jQuery, btw) will go and grab the first four images of your favorite pop star. From here it counts the number of results and if it isn't enough, it will run getBieb again, except this time with the startNumber argument increased.