3

I am trying to use Google Custom Search API to get URL of images in Google Images. How do I set up my custom search site to use images.google.com as its site to search? I just tried to use the Google Images url (images.google.com) when I sat up my Custom Search, but that does not seem to work.

When I try to do a REST call this is what I get:

{
"title": "Google Custom Search - tomat",
"totalResults": "0",
"searchTerms": "tomat",
"count": 10,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"safe": "off",
"cx": "THIS IS WHERE THE CX NUMBER IS"
}

I am trying to get the image URL of the three first hits on a search query. Any ideas?

6
  • try adding searchType = "image" or searchType:"image" to your parameters Commented Jul 26, 2015 at 13:35
  • @RamRaider I does'nt work. I get : { "title": "Google Custom Search - tomat", "totalResults": "0", "searchTerms": "tomat", "count": 10, "inputEncoding": "utf8", "outputEncoding": "utf8", "safe": "off", "cx": "THIS IS WHERE THE CX NUMBER IS", "searchType": "image" } Commented Jul 26, 2015 at 14:29
  • No examples but got that from the google documentation. When you make your request to the api you must( I would assume ) send a bunch of parameters as part of the request. If you arefetching with cURL over GET then these parameters are appended to the url as a querystring, if you are using POST they are sent as post params as a curl option. Add the searchType parameter with a value of image to these parameters before sending or share you code that you use to make the request so we can see what you are doing. Commented Jul 26, 2015 at 14:33
  • @RamRaider I edited the comment. I had a typo in the parameters and got the searchType to work, but it still returns 0 hits. Commented Jul 26, 2015 at 14:39
  • @RamRaider This is the query string: googleapis.com/customsearch/… Commented Jul 26, 2015 at 14:42

1 Answer 1

1

I figured it out. You have to have Image Search enabled in the control panel and have searchType=image in the query, but what I had to add was *.google.com to sites to search. When I used the wildcard at google.com it worked. :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.