Google Image Search API

imagesearch
Google image search parameters

Here are some useful documents if, as a developer,  you want to use the Google Image Search API.

I used the Google Image Search API in an earlier piece called dbCinema, but this piece was done in Adobe Director. Since then, I've retooled to HTML5. So I looked into using the Image Search API with HTML5.

First, the official Google documentation of the Google Image Search API is at developers.google.com/image-search/v1/devguide. It's all there. Note that it's "deprecated". It won't be free for very much longer, for developers. Soon they will charge $5/1000 queries. But the documentation I have put together does not use a key of any kind.

Perhaps the main thing to have a look at in the official Google documentation is the sample HTML file. It's in the section titled "The 'Hello World' of Image Search". This automatically does a search for "Subaru STI" and displays the results. But wait. There is a bug in the sample file so that if you copy the code and paste it into a new HTML file, it doesn't work. I expect this is simply to introduce the seemingly mandatory dysfunction almost invariably present in contemporary programming documentation. Unbelievable. I have corrected the bug in vispo.com/typewriter/Google_Image_Search2.htm, which is almost exactly the same as "The 'Hello World' of Image Search" except it gets rid of "/image-search/v1/" in a couple of places.

After you look at that, look at vispo.com/typewriter/Google_Image_Search3.htm. Type something in and then press the Enter or Return key. It will then do a Google image search and display at most 64 images. 64 is the max you can get per query. The source code is very much based on the official Google example. The image size is set to "medium" and the porn filter is turned on. Strange but true.

Finally, have a look at vispo.com/typewriter/Google_Image_Search4.htm. This example shows you how to control Google Image Search parameters. The source code is the same as the previous example except we see a bunch of dropdown menus. Additionally, there is an extra function in the source code named setRestriction which is called when the user selects a new value from the dropdown menus.

There is a dropdown menu for all the controllable Image Search parameters except for the sitesearch restriction, which is simple enough if you understand the others.

Anyway, that ought to give you what you need to get up and running with the Google Image Search API.


One Response to “Google Image Search API”

  • Jim Andrews June 30, 2014 at 10:26 pm

    I got the below from Jeremy Geerdes, an employee of Google, in response to my posting a note about the above tutorial on a Google forum. Thanks, Jeremy.

    “This is an interesting tutorial, Jim. Thanks for providing it. And particularly, thanks for noting the errors which were apparently introduced into the latest version of the documentation. However, I would warn you and anyone else who would utilize this tutorial and/or the Image Search API in an application that the service has been deprecated since late May 2011. Per the deprecation policy, Google was slated to maintain the service for three years after the deprecation date. That three-year period has now passed, so the service’s shutdown is, in all likelihood, imminent.

    Please note that this is in contrast to your assertion in the tutorial that the API will move to a paid model. I am guessing that the confusion is the result of the Custom Search API (CSAPI), which utilizes a paid model and the pricing structure mentioned, supporting image search. However, while the CSAPI is built on a similar REST platform, there are significant differences between the old “AJAX” Image Search API and the CSAPI image search functionality.

    Thanks again, Jim, for taking the time to write this tutorial!

    jg”

    Jeremy’s post can also be read at https://groups.google.com/d/msgid/google-ajax-search-api/CAF4cwg997JPXcdfuQ%2BmeBeLVoE5HjbGX35MgS5c-PeXgsf4OJg%40mail.gmail.com