Replace the Google Custom Search JSON API in Ruby
Google ends the Custom Search JSON API on January 1, 2027. Move your Ruby code to SpecStream today: the same search in one call, $1 per 1,000 searches against $5, and no daily limit.
A new account gets $2 of credit, no card: 2,000 free test searches. Start the Starter plan at $49 a month for 49,000 searches.
- $1
- per 1,000 searches on SpecStream, fast tier
- $5
- per 1,000 queries on Google Custom Search, until it closes
- 80%
- lower search cost from the first call
- Jan 1, 2027
- the day Google ends the Custom Search JSON API
Before and after in Ruby
GitHub counted 155 Ruby files that contain the address of the Custom Search JSON API on November 20, 2026. net/http and json cover the call with no gem. The switch adds one header and reads sources under data.
require "json" require "net/http" uri = URI("https://www.googleapis.com/customsearch/v1") uri.query = URI.encode_www_form( key: ENV.fetch("GOOGLE_API_KEY"), cx: ENV.fetch("GOOGLE_CSE_ID"), q: "open source vector databases", num: 10 ) body = JSON.parse(Net::HTTP.get(uri)) body.fetch("items", []).each do |item| puts [item["title"], item["link"], item["snippet"]].join(" ") end
require "json" require "net/http" uri = URI("https://api.specstream.ai/v1/web-search") uri.query = URI.encode_www_form(q: "open source vector databases", num: 10, speed: "fast") request = Net::HTTP::Get.new(uri) request["Authorization"] = "Bearer " + ENV.fetch("SPECSTREAM_API_KEY") response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) } JSON.parse(response.body).dig("data", "sources").each do |source| puts [source["title"], source["url"], source["snippet"]].join(" ") end
The shortest path: keep your code
Change the URI to https://api.specstream.ai/customsearch/v1 and set key to a SpecStream key. Net::HTTP.get and the items loop stay as they are.
# was https://www.googleapis.com/customsearch/v1 uri = URI("https://api.specstream.ai/customsearch/v1") uri.query = URI.encode_www_form( key: ENV.fetch("SPECSTREAM_API_KEY"), q: "open source vector databases", num: 10 ) body = JSON.parse(Net::HTTP.get(uri)) body.fetch("items", []).each { |item| puts item["link"] }
$1 per 1,000 searches against $5
SpecStream costs 80% less than Google Custom Search from the first call, with no daily limit and no plan to choose.
What changes in the request and the reply
Each Google field, where it goes on the Search API, and what the Google compatible address keeps.
Move Ruby code in five steps
About ten minutes for one call site.
- Create a SpecStream keySign up with no card. A new account gets $2 of credit, which covers 2,000 fast searches.
- Store the keySet
SPECSTREAM_API_KEYwhere your Ruby code runs. KeepGOOGLE_API_KEYuntil the switch is live, then remove it together withGOOGLE_CSE_ID. - Change the requestBuild a
Net::HTTP::Getforhttps://api.specstream.ai/v1/web-search, setAuthorization, addspeed: "fast", and readdig("data", "sources"). - Read the replyRead
data.sourcesin place ofitems.linkbecomesurl, andtitleandsnippetkeep their names. - Test before January 1, 2027Run your own queries in the Google CSE migrator and compare both replies before you remove the Google key.
Start now
Test your own query, start on free credit, or prepay for production.
- Google CSE migratorRun a query and see the Google shaped reply beside the SpecStream reply, with the code for your call.
- Start with $2 of creditNo card. It covers 2,000 fast searches, and the key works on the API and over MCP.
- $1,000 prepay packPay once by card and get $1,200 of credit. It does not expire.
- $5,000 prepay packFor production volume. Pay once by card and search from the same balance.
The same move in other stacks
Questions
Something we didn't answer? Talk to a human
When does the Google Custom Search JSON API shut down?
What is the fastest way to replace Google Custom Search in Ruby?
URI to https://api.specstream.ai/customsearch/v1 and set key to a SpecStream key. Net::HTTP.get and the items loop stay as they are.What does SpecStream cost against Google Custom Search?
Do I need a Programmable Search Engine ID?
/v1/web-search you leave cx out, and on the Google compatible address it is accepted and not used. To keep a search inside one site, write site:example.com in q.Is the reply the same as Google's?
https://api.specstream.ai/customsearch/v1 the reply keeps Google's JSON: items with title, link, snippet and displayLink, searchInformation.totalResults and queries.nextPage. On /v1/web-search each result is in data.sources with title, url, site and snippet, and passages=true adds the best passages of each page.How accurate is SpecStream search?
Can an agent pay per call with no account?
What is the best alternative to the Google Custom Search JSON API?
customsearch/v1 request with Google's JSON reply, costs $1 per 1,000 searches against Google's $5, has no daily limit, and is #1 across 15 public web search and extraction benchmarks.Is there a drop in replacement for customsearch.googleapis.com?
https://www.googleapis.com/customsearch/v1 or https://customsearch.googleapis.com/customsearch/v1 to https://api.specstream.ai/customsearch/v1, with a SpecStream key in key. q, num, start, siteSearch, exactTerms, excludeTerms, orTerms, dateRestrict, fileType, lr, gl, safe and searchType=image carry over, and cx is accepted and not used.Is there a cheaper API than Google Custom Search?
What happens to my code on January 1, 2027?
Does this run inside a Rails app?
ENV. Wrap it in Rails.cache.fetch if the same query repeats within a request cycle.Keep your search working after January 1
One call changed. $1 per 1,000 searches, no daily limit, and $2 of credit to start.