Restricting by licenses now available in the Image Search API

April 12, 2010

I'm always amazed at the creative ways developers use Google's APIs. I'm always pleased when we are able to add a new feature to the API, as I know that someone, somewhere will do something cool and unexpected with it. The latest addition is to the Image Search API. You can now restrict results by various licenses applied to each image.

There are two different ways to use this feature. In the JavaScript API, you can restrict your results to one of four common licenses (just like on Google Image Search). This is done using the setRestriction method, after creating your Image Search searcher. Here's how to restrict to images which have been labeled for reuse with modification:

var searcher = new google.search.ImageSearch();
searcher.setRestriction(google.search.ImageSearch.RESTRICT_RIGHTS,
google.search.ImageSearch.RIGHTS_MODIFICATION);
You can experiment with a live example of this in our Code Playground.

If you're using the JSON API, you can use the as_rights optional parameter to tell the API to include or exclude certain attributions. To perform the same restriction as above, try adding this to your requests:
&as_rights=
(cc_publicdomain|cc_attribute|cc_sharealike|cc_noncommercial).-(cc_nonderived)
For a full list of the attribute combinations for each type of license, perform an appropriately restricted search on Google Image Search's advanced search and take a look at the as_rights parameter in the URL on the results page.

Note: Images returned with this filter may still have conditions on the license for use. Please remember that violating copyright is strictly prohibited by the API Terms of Use. For more details, see this article.

Please come visit our IRC channel and support forum and let us know how you've used this feature in your site or app!