A long-lived project that still receives updates
DEPRECATED: Google has announced the Custom Search JSON API will be shut down on January 1, 2027. This gem will raise a DeprecatedError on instantiation. Please migrate to one of these alternatives before the shutdown date: - Algolia (https://www.algolia.com/) — hosted search with a generous free tier - Meilisearch (https://www.meilisearch.com/) — fast, open-source, self-hostable - Typesense (https://typesense.org/) — open-source, typo-tolerant search Original purpose: Ruby interface for the Google Custom Search JSON API, allowing Rails applications to add Google-powered site search using a Custom Search Engine ID.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.12
 Project Readme

google_search_cse

Gem Version Gem Downloads

A Ruby library to integrate Google Custom Search Engine (CSE) into Rails applications. Lets you add Google-powered search to your site using your own custom search engine ID.

Tags: google-custom-search, custom-search-engine, site-search, google-api, rails, deprecated

Installation

Add this line to your Gemfile:

gem 'google_search_cse'

Then run:

bundle install

Setup

  1. Create a Custom Search Engine at programmablesearchengine.google.com
  2. Note your Search Engine ID (cx)
  3. Enable the Custom Search JSON API in Google Cloud Console and grab an API key

Usage

search = GoogleSearchCse.new
results = search.query("YOUR_API_KEY", "YOUR_CX_ID", "ruby on rails")

Links

Contributing

Since this gem is deprecated, open issues are mostly focused on smoothing the migration path (Algolia/Meilisearch/Typesense examples) rather than new features — see the open issues list. Some are tagged good first issue if you'd like to help.