3

Currently, I'm using Google Custom Search API, to perform image searching using REST

https://developers.google.com/custom-search/json-api/v1/reference/cse/list#request

I was wondering, what is the correct way, to specific multiple file type?

fileType is being mentioned briefly in the API document.

For instance, the following is the GET request, to search only BMP type image.

https://www.googleapis.com/customsearch/v1?key=GOOGLE_API_KEY&cx=GOOGLE_SEARCH_ENGINE_ID&q=picasso&searchType=image&fileType=bmp

However, what if I want to search both PNG and BMP image?

At first, I thought

fileType=png,bmp

might work as mentioned in http://codigogenerativo.com/code/google-custom-search-api/

However, if I test using

https://www.googleapis.com/customsearch/v1?key=GOOGLE_API_KEY&cx=GOOGLE_SEARCH_ENGINE_ID&q=picasso&searchType=image&fileType=png,bmp

JPEG images are being returned.

Seem like my assumption is wrong. Does anyone know how to have multiple fileType for Google Custom Search API during image searching?

p/s Similar question had been raised before few years ago but no concrete answer yet : Multiple file types search using Google Custom Search API

ZR87
  • 1,463
  • 16
  • 27
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875

1 Answers1

1
https://www.googleapis.com/customsearch/v1?fileType=jpg,png,AND OTHER TYPES YOU NEED&key=GOOGLE_API_KEY&cx=GOOGLE_SEARCH_ENGINE_ID&q=picasso&searchType=image
  • I think it's correct but can you give source of this answer? – Fabian Dec 20 '20 at 22:44
  • 1
    This is not working for me. Getting other types as well – Biboswan Feb 11 '21 at 09:20
  • Can confirm that the OP is correct. I am querying for fileType=jpg,png and getting gifs in the returned result. Here's what I have tested - 1. Using one filetype e.g. `fileType=png` works perfectly. 2. Since the rights parameter uses brackets around its values and a vertical bar to separate them, I tried that. It does not work. 3. Using `jpg,png` as the value in the console on the developer site works perfectly. Typing your query directly into the browser url returns gifs again. Conclusion: there seem to be two code bases and the one publicly accessible has this bug. – garrettlynchirl Apr 28 '21 at 14:19
  • im not sure why it doesn't work for you guys but it's working for me. – Tickle Me Teemo May 09 '21 at 23:14