Skip to the page

Google Custom Search API in Java

The call that still answers.

The Custom Search JSON API is closed to new customers, and Google ends it on January 1, 2027. A Java service that calls googleapis.com/customsearch/v1 gets no new key and no answer after that date.

SpecStream answers that request at https://api.specstream.ai/customsearch/v1 and returns Google's JSON. In Java the change is the base URI and the key. items, title, link and snippet parse as they did, and any cx is accepted.

A search of up to 10 results costs $0.005, the $5 per 1,000 Google charges, with no 10,000 a day cap. SpecStream scores 97.9 F-score on all 1,000 SimpleQA Verified questions; see the benchmarks.

New accounts get $10 of credit, no card. It covers 2,000 searches.

Custom Search from Java: SpecStream, Google and Vertex AI Search

SpecStreamGoogle Custom Search JSON APIVertex AI Search
The request Java sendsGET https://api.specstream.ai/customsearch/v1 with key, q, num and start. Any cx is acceptedGET https://www.googleapis.com/customsearch/v1 with q, an API key and cx, the ID of the Programmable Search Engine you configuredPOST https://discoveryengine.googleapis.com/v1/{servingConfig}:search, a different request and reply
Open to new customersYes. Create a key in a minute and start with $10 of credit, no cardNo. Closed to new customers; discontinued on January 1, 2027Yes, with a free trial of 10,000 queries per account a month
Search scopeThe whole live web at the time of the call. siteSearch limits a search to one siteOnly the Programmable Search Engine you configuredUp to 50 domains. Full web search means contacting Google
Price$5 per 1,000 searches of up to 10 results. No daily cap$5 per 1,000 queries after 100 free queries a day, up to 10,000 a day, for existing customers$1.50 per 1,000 queries on Search Standard Edition, $4.00 on Search Enterprise Edition
What the JSON holdsGoogle's shape: items with title, link, snippet, displayLink, htmlTitle, htmlSnippet and formattedUrl, searchInformation.totalResults and queries.nextPageAn items array carrying the URL, title and text snippets of each resultA different reply. Generated answers come with Search Enterprise Edition at $4.00 per 1,000 queries
Results a callnum from 1 to 10 and start to page, as on Google1 to 10 results a call, never more than 100 for a queryBilled per query: any API call to Enterprise Search counts
When a call failsA busy call answers 429 with Retry-After in Google's error form and is not chargedIts terms say you may be charged for each successful requestAny API call counts as a request, direct or through an integration or the console

Why Java code that called Custom Search moves to SpecStream

Other options for the Custom Search JSON API in Java

How SpecStream scores

The same numbers as the benchmarks page, from the official tasks and scorers.

How to run the Java example

1. Create a key under Agents & API in the workspace. New accounts get $10 of credit, no card, enough for 2,000 searches.

2. Set the key in the environment and try the route from a shell.

export SPECSTREAM_API_KEY="your key"
curl "https://api.specstream.ai/customsearch/v1?key=$SPECSTREAM_API_KEY&cx=any&q=open+source+vector+databases&num=3"

3. Add Jackson (com.fasterxml.jackson.core:jackson-databind) to the build and run CustomSearch above. In code that already calls Google, change https://www.googleapis.com or https://customsearch.googleapis.com to https://api.specstream.ai and use the SpecStream key. Leave cx in place.

4. With google-api-services-customsearch, add .setRootUrl("https://api.specstream.ai/") to the builder, as shown above.

For the same move in Python, with Google's own client, see the Python page.

When the job is every match rather than a results page, write the request in plain words. SpecStream reads it back as the conditions each row must meet and the facts to return, quotes the most it can cost, and delivers the rows once you approve.

Frequently asked questions

Something we didn't answer? Talk to a human

How do I use the Google Custom Search API in Java?
Send GET /customsearch/v1 with key, cx and q through java.net.http.HttpClient and read items from the JSON. Google closed the API to new customers and ends it on January 1, 2027. The same request answers at https://api.specstream.ai/customsearch/v1 with a SpecStream key.
What is the customsearch Java client's setting for the address?
Builder.setRootUrl, which replaces DEFAULT_ROOT_URL, https://customsearch.googleapis.com/. Set it to https://api.specstream.ai/ and pass a SpecStream key to setKey. Tested on November 10, 2026 with google-api-services-customsearch v1-rev20240821-2.0.0: the client's own cse().list().execute() read 10 results.
When does Google shut down the Custom Search JSON API?
On January 1, 2027. It is already closed to new customers; the shutdown page has Google's words and dates.
How do I get more than 10 results in Java?
Ask again with start at 11, then 21, or take queries.nextPage[0].startIndex from each reply. Every page of up to 10 results is one search at $0.005.
Do I need a Programmable Search Engine ID (cx)?
No. Any cx value is accepted, so a properties file that sets one stays as it is. SpecStream searches the whole live web; siteSearch keeps a search to one site.
What does the Custom Search JSON API cost?
$5 per 1,000 queries after 100 free a day, capped at 10,000 a day, for existing customers until January 1, 2027. SpecStream costs $5 per 1,000 searches with no daily cap. Every rate is on the pricing page.
How should Java handle a 429 from the route?
Read the Retry-After header, wait that many seconds and send the call again. The 429 comes in Google's error form and is not charged.

Sources

SpecStream wrote this page. Each figure about Google comes from Google's own pages, the client setting from the client's own source, and each other figure from that company's own page.

  1. Google Custom Search JSON API overviewdevelopers.google.com/custom-search/v1/overview, read Nov 9, 2026
  2. Google Custom Search JSON API reference, cse.listdevelopers.google.com/custom-search/v1/reference/rest/v1/cse/list, read Nov 9, 2026
  3. Google Custom Search JSON API, using RESTdevelopers.google.com/custom-search/v1/using_rest, read Nov 9, 2026
  4. Google Custom Search terms of servicedevelopers.google.com/custom-search/terms, read Nov 9, 2026
  5. Programmable Search Engine blog: updates to our web search productsprogrammablesearchengine.googleblog.com/2026/01/updates-to-our-web-search-products.html, read Nov 9, 2026
  6. Google Cloud: Agent Search pricingcloud.google.com/generative-ai-app-builder/pricing, read Nov 9, 2026
  7. Google Cloud: servingConfigs.search methodcloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines.servingConfigs/search, read Nov 9, 2026
  8. Gemini API: Grounding with Google Searchai.google.dev/gemini-api/docs/google-search, read Nov 9, 2026
  9. Brave Search APIbrave.com/search/api/, read Nov 9, 2026
  10. Brave, alternatives to the Google Search APIbrave.com/learn/google-api-shutdown/, read Nov 9, 2026
  11. google-api-services-customsearch: CustomSearchAPI.javagithub.com/googleapis/google-api-java-client-services/blob/main/clients/google-api-services-customsearch/v1/2.0.0/com/google/api/services/customsearch/v1/CustomSearchAPI.java, read Nov 10, 2026
  12. SpecStream benchmarksspecstream.ai/benchmarks, read Nov 10, 2026
  13. SpecStream pricingspecstream.ai/pricing, read Nov 10, 2026
  14. SpecStream for agentsspecstream.ai/agents.md, read Nov 10, 2026