Google Image Search API, does anyone have an example that works?
Asked Answered
H

1

6

Trying to find out how to do Google image searches via an API / REST call. Apparently the image search API is deprecated and directs us to the Custom Search API.

But my first experiments with the Custom Search API, return results from my own website !!&*%%%$@@!, which is not helpful in the slightest.

I need image results from Google images. Anyone have an example query that works?

Hoem answered 4/10, 2013 at 23:22 Comment(0)
P
10

You will basically want to generate a URL like this. Note the search type parameter at the end.

https://www.googleapis.com/customsearch/v1?key=YOUR API KEY&cx=YOUR CUSTOM SEARCH ENGINE IDENTIFIER&q=your query&searchType=image

You can read more here https://developers.google.com/custom-search/json-api/v1/using_rest

edit: changed searchType to lowercase based on comment below

Polyandrist answered 6/12, 2013 at 13:13 Comment(4)
{ "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "Invalid Value" } ], "code": 400, "message": "Invalid Value" } }Brose
It should be &searchType=image lowercase iGulgee
Anyone looking to get their custom search engine id (cx) should go to here: cse.google.com/cse/allDelectate
as advised by Marc, "To do this you need to click "Enable image search" in your CSE console!" #8449288 ... I spent a whole hour troubleshooting til i found his comment on a related thread.Shores

© 2022 - 2024 — McMap. All rights reserved.