Skip to main content
Google Search API
calendar
June 12, 2023
chat
0 Comments
A client asked us to fetch Google search results via API for their project. The docs here:

Custom Search JSON API

have the code ready for Javascript. You must of course enter your API key.

The only other point they don’t mention is the parameters for the search call. The ‘q’ parameter is the standard search text. Then the ‘cx’ parameter is required, and that’s the ID of your Google Custom Search Engine. So this line:

return gapi.client.search.cse.list({})

must look more like this:

return gapi.client.search.cse.list({
“cx”: “XXXXXXX”,
“q”: “My Search Text”
})

With that, it works very well. 🙂

No Comments yet!


Warning: Undefined array key "comment_author_url_web" in /home/galleryr/www/www/wp-content/themes/civihosting/functions.php on line 555

Leave a Reply

Your email address will not be published. Required fields are marked *