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

Im using the google APIs ajax below to get images for particular search terms. This is being done in a WinForms app.

The below link seems to work, but it only returns 4 results (via JSON)

Anyone know how to coax more out of it?

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

Obviously there has to be another parameter to request more or page through the results, but I can't seem to figure it out? Anyone know?


Solution 1:

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

Solution 2:

You can use "&rsz=8", refer below...

http://ajax.googleapis.com/ajax/services/search/video?q=SpongeBob%20Full&v=1.0&start=8&rsz=8

Solution 3:

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.

Solution 4:

Google Feed provides an optional method, where you can specify the no. of results that you want to get. If you don't specify this method the default no. of results you get is 4, however to get more no. of feeds you can specify this optional method as follows;

feed.setNumEntries(int);

e-g: feed.setNumEntries(16); // will return 16 results.

.setNumEntries(num) sets the number of feed entries loaded by this feed to num. By default, the Feed class loads four entries.

.setNumEntries() has no return value.

https://developers.google.com/feed/v1/reference#setNumEntries