Reputation: 350
A friend and I are trying to create a Photomosaic generator in Processing. We want to be able to pull 100 images from Google using the Custom Search API, restricting the image size and dominant color, along with few other things. We want to save these images so that we can process them in our program. We also want to use data that will come from the GUI to be used to build the API call, i.e the search keyword.
The following code snippet shows what parameters we want to constrain our image search with:
var searcher = new google.search.customSearchControl.getImageSearcher();
searcher.setRestriction(
google.search.Search.RESTRICT_SAFESEARCH,
google.search.Search.SAFESEARCH_STRICT
);
searcher.setRestriction(
google.search.customSearchControl.getImageSearcher.RESTRICT_IMAGESIZE,
google.search.customSearchControl.getImageSearcher.IMAGESIZE_MEDUIM
);
searcher.setRestriction(
google.search.customSearchControl.getImageSearcher.RESTRICT_COLORFILTER,
google.search.customSearchControl.getImageSearcher.COLOR_RED
);
searcher.execute(keyword);
We just aren't sure how to restrict the number of search results or what format the data returns in. Is it JSON?
Upvotes: 2
Views: 2349
Reputation: 927
This is if you are building a URL, and not doing it programatically.
JSON
as the return value, append &alt=json
to the end of your request URL.num=50
as one of the parametersSource: https://developers.google.com/custom-search/v1/using_rest#query-params
Upvotes: 1
Reputation: 28747
The following page has all the documentation for the Google custom search API:
https://developers.google.com/custom-search/v1/overview
At a first glance I can see it's a JSON / atom api. So I guess probably the default return format is JSON and through content negotation you can also request atom (but again, please read the documentation to be sure).
Upvotes: 0