Skip to the page

Google Custom Search API in PHP

The call that still answers.

Google closed the Custom Search JSON API to new customers and ends it on January 1, 2027. A new PHP project gets no key, and code that calls googleapis.com/customsearch/v1 stops answering on that day.

SpecStream answers the same request at https://api.specstream.ai/customsearch/v1 in Google's JSON. In PHP you change the host in the URL and the key; items, title, link and snippet read as before, and any cx is accepted.

Searches cost $5 per 1,000 of up to 10 results, Google's own rate, with no 10,000 a day cap. SpecStream scores 97.9 F-score on all 1,000 SimpleQA Verified questions, on the benchmarks page.

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

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

SpecStreamGoogle Custom Search JSON APIVertex AI Search
The URL PHP callsGET https://api.specstream.ai/customsearch/v1 with key, q, num and start. Any cx is acceptedGET https://www.googleapis.com/customsearch/v1 with an API key, q and cx, the ID of a Programmable Search Engine you set upPOST https://discoveryengine.googleapis.com/v1/{servingConfig}:search, with its own request body and reply
New keysYes. A key takes a minute and comes with $10 of credit, no cardNo. Closed to new customers, and discontinued on January 1, 2027Yes. A free trial covers 10,000 queries per account a month
What it searchesThe whole live web, read at the moment of the call. siteSearch keeps a search to one siteThe Programmable Search Engine that cx namesUp to 50 domains. For full web search, Google asks you to contact it
Price$5 per 1,000 searches of up to 10 results, with no daily cap$5 per 1,000 queries after 100 free 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 json_decode returnsGoogle's JSON: items with title, link, snippet, displayLink, htmlTitle, htmlSnippet and formattedUrl, plus searchInformation.totalResults and queries.nextPageAn items array with the URL, title and text snippets of each resultIts own reply shape. Search Enterprise Edition adds generated answers at $4.00 per 1,000 queries
Results a callnum from 1 to 10, with start for the next page, as on Google1 to 10 a call, and never more than 100 for one queryBilled per query: every API call to Enterprise Search counts as one
A busy or failed call429 in Google's error form with Retry-After, and not chargedIts terms say you may be charged for each successful requestA request is any API call, made directly, through an integration or in the console

Why PHP code that called Custom Search moves to SpecStream

Other options for the Custom Search JSON API in PHP

How SpecStream scores

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

How to run the PHP example

1. Create a key under Agents & API in the workspace. A new account gets $10 of credit, no card, which covers 2,000 searches.

2. Put the key in the environment and check the route from the 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. Run the curl example above with php search.php. In code that already calls Google, replace https://www.googleapis.com or https://customsearch.googleapis.com with https://api.specstream.ai and the key with the SpecStream key. cx can stay.

4. With google/apiclient, pass 'https://api.specstream.ai/' as the second argument of new Google\Service\CustomSearchAPI(...), as shown above.

The same move in Python, with Google's own Python client, is on the Python page.

When your product needs every match instead of a page of links, write the request in plain words. SpecStream reads it back as the conditions every row must meet and the facts to bring back, quotes the most it can cost, and delivers the rows after you approve.

Frequently asked questions

Something we didn't answer? Talk to a human

How do I call the Google Custom Search API from PHP?
Send a GET to /customsearch/v1 with key, cx and q using curl or file_get_contents, then json_decode the reply and read items. 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.
Can I keep google/apiclient?
The client's documented setting for the address is $rootUrl, the second argument of the CustomSearchAPI constructor, which defaults to https://customsearch.googleapis.com/. Set it to https://api.specstream.ai/ and use a SpecStream key with setDeveloperKey. Tested on November 10, 2026 with google/apiclient 2.20.1: the client's own listCse call read 10 results.
When does the Custom Search JSON API stop working?
On January 1, 2027, and it is already closed to new customers. The shutdown page has Google's own words and dates.
How do I get more than 10 results in PHP?
Send the call again with start set to 11, then 21, or read queries.nextPage[0].startIndex from each reply. Each page of up to 10 results is one search at $0.005.
Do I still need a search engine ID (cx)?
No. Any cx value is accepted, so a config that sends one runs unchanged. SpecStream searches the whole live web, and siteSearch keeps a search to one site.
How much does the Custom Search API cost from PHP?
Google charges existing customers $5 per 1,000 queries after 100 free a day, up to 10,000 a day. SpecStream charges $5 per 1,000 searches of up to 10 results with no daily cap, and new accounts get $10 of credit, no card. Every rate is on the pricing page.
What happens when the API is busy?
It answers 429 in Google's error form with a Retry-After header, and the call is not charged. Wait that many seconds and send it again, as the paging example does.

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/apiclient services: CustomSearchAPI.phpgithub.com/googleapis/google-api-php-client-services/blob/main/src/CustomSearchAPI.php, 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