# Google Custom Search JSON API Alternative (`roomy_tweet/google-custom-search-api`) Actor

Replacement for Google's Custom Search JSON API, which Google discontinues on January 1, 2027. Same /customsearch/v1 endpoint, same parameters, same JSON response, with live Google web results. Change the base URL and the key and keep your code.

- **URL**: https://apify.com/roomy_tweet/google-custom-search-api.md
- **Developed by:** [roomy_tweet](https://apify.com/roomy_tweet) (community)
- **Categories:** SEO tools, Developer tools, AI
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 searches

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### Google Custom Search JSON API alternative

Google is discontinuing the **Custom Search JSON API** on **January 1, 2027**. It is already closed to new customers, and Google's suggested replacement only covers search over up to 50 of your own domains.

This Actor answers the **same endpoint, with the same parameters and the same JSON response**, using live Google web results. Existing code keeps working after two changes: the base URL and the key.

It is an independent tool and is not affiliated with or endorsed by Google.

### What changes in your code

Before:

```
GET https://www.googleapis.com/customsearch/v1?key=GOOGLE_API_KEY&cx=ENGINE_ID&q=web+scraping+tools
```

After:

```
GET https://roomy-tweet--google-custom-search-api.apify.actor/customsearch/v1?token=APIFY_TOKEN&cx=ENGINE_ID&q=web+scraping+tools
```

- **Base URL**: copy it from this Actor's **Server** tab.
- **Key**: send your [Apify API token](https://console.apify.com/settings/integrations) as `token=` in place of `key=`, or better, as an `Authorization: Bearer <token>` header. A leftover `key=` parameter is ignored.
- **Everything else stays**: `q`, `num`, `start`, `gl`, `hl`, `lr`, `cr`, `safe`, `siteSearch`, `dateRestrict`, `exactTerms`, `fileType` and the rest, plus the response fields your code already reads (`items[].title`, `link`, `snippet`, `displayLink`, `searchInformation.totalResults`, `queries.nextPage`).

```bash
curl -H "Authorization: Bearer $APIFY_TOKEN" \
  "https://roomy-tweet--google-custom-search-api.apify.actor/customsearch/v1?q=web+scraping+tools&num=5&gl=us"
```

```python
import requests

response = requests.get(
    "https://roomy-tweet--google-custom-search-api.apify.actor/customsearch/v1",
    params={"q": "web scraping tools", "num": 5},
    headers={"Authorization": f"Bearer {APIFY_TOKEN}"},
)
for item in response.json().get("items", []):
    print(item["title"], item["link"])
```

`/customsearch/v1/siterestrict` is answered the same way, for code that called the Site Restricted API.

### If your search engine was restricted to certain sites

A Programmable Search Engine kept its list of sites inside Google, under the `cx` ID. That list cannot be read from outside, so send the sites with the request:

```
/customsearch/v1?q=pricing&sites=example.com,docs.example.com,blog.example.com
```

`sites` takes up to 20 sites (hosts or paths such as `example.com/blog`). For a single site the API's own `siteSearch=example.com` also works, and `siteSearchFilter=e` excludes that site instead.

### Response

```json
{
  "kind": "customsearch#search",
  "queries": {
    "request": [{ "title": "Google Custom Search - web scraping tools", "totalResults": "126", "searchTerms": "web scraping tools", "count": 10, "startIndex": 1, "inputEncoding": "utf8", "outputEncoding": "utf8", "safe": "off", "cx": "ENGINE_ID" }],
    "nextPage": [{ "title": "Google Custom Search - web scraping tools", "totalResults": "126", "searchTerms": "web scraping tools", "count": 10, "startIndex": 11, "inputEncoding": "utf8", "outputEncoding": "utf8", "safe": "off", "cx": "ENGINE_ID" }]
  },
  "context": { "title": "Google" },
  "searchInformation": { "searchTime": 0.18, "formattedSearchTime": "0.18", "totalResults": "126", "formattedTotalResults": "126" },
  "items": [
    {
      "kind": "customsearch#result",
      "title": "Scrapy — open source web scraping framework for Python",
      "htmlTitle": "Scrapy — open source web scraping framework for Python",
      "link": "https://www.scrapy.org/",
      "displayLink": "www.scrapy.org",
      "snippet": "An open source and collaborative framework for extracting the data you need from websites.",
      "htmlSnippet": "An open source and collaborative framework for <b>extracting the data</b> you need from websites.",
      "formattedUrl": "https://www.scrapy.org/",
      "htmlFormattedUrl": "https://www.scrapy.org/"
    }
  ]
}
```

Errors use the API's format too, so existing error handling keeps working:

```json
{ "error": { "code": 400, "message": "'num' must be between 1 and 10.", "errors": [{ "message": "'num' must be between 1 and 10.", "domain": "global", "reason": "badRequest" }], "status": "INVALID_ARGUMENT" } }
```

| Status | Meaning | Charged |
|---|---|---|
| 200 | Results, or a valid answer with no results (no `items` key, as in the API) | Yes |
| 400 | Invalid parameter (`badRequest`) | No |
| 429 | Your Apify account could not be charged, for example its spending limit was reached | No |
| 503 | Google did not return a readable page after three attempts; try again | No |

### Supported parameters

| Parameter | Support |
|---|---|
| `q` | Yes. Google operators work (`"phrase"`, `-word`, `site:`, `filetype:`) |
| `num` | 1 to 10 |
| `start` | 1 to 100; `start + num` cannot pass 100, as in the API |
| `gl`, `hl`, `lr`, `cr`, `safe`, `filter`, `googlehost` | Yes |
| `siteSearch`, `siteSearchFilter` | Yes |
| `sites` | Extension: up to 20 sites, replaces the engine's site list |
| `dateRestrict` | `d[n]`, `w[n]`, `m[n]`, `y[n]` |
| `sort` | `date` and `date:r:YYYYMMDD:YYYYMMDD` |
| `exactTerms`, `excludeTerms`, `orTerms`, `hq`, `fileType` | Yes |
| `cx` | Accepted and echoed back; the engine's settings are not read |
| `key` | Ignored; authentication is your Apify token |
| `prettyPrint` | Yes |
| `searchType=image` | Not supported: web results only (returns 400) |
| `fields`, `callback`, `c2coff`, `lowRange`, `highRange`, `linkSite`, `rights`, `img*` | Ignored |

### What is different from Google's API

Read this before you switch, so nothing surprises you in production.

- **Results are Google web search results.** A Programmable Search Engine ranked a little differently from google.com, and engine settings stored under `cx` (site list, promotions, synonyms, refinements) are not applied. Use `sites` for the site list.
- **`items` carry the core fields**: `title`, `htmlTitle`, `link`, `displayLink`, `snippet`, `htmlSnippet`, `formattedUrl`, `htmlFormattedUrl`, plus `mime` and `fileFormat` for documents such as PDFs. There is no `pagemap` (page metadata and thumbnails) and no `cacheId`. `htmlTitle` has no bold marks.
- **`totalResults` is the number Google shows on the page** ("About 126 results"). Google's page estimates are often much smaller than the API's used to be. When Google shows no number, the field holds the count of results seen so far, plus one while another page exists, so loops that page until `totalResults` keep working.
- **Some links are Google redirects.** Google often hides each result's address behind a redirect (`https://www.google.com/goto?url=…`). The Actor follows it to the real address, but Google sometimes answers with a "Verifying your request" check instead. In tests on November 12, 2026, about 2 in 3 links came back with the real address and the rest stayed as Google's redirect. Such an item keeps the redirect in `link` (it still opens the right page in a browser), gets `"unresolvedLink": true`, and its `displayLink` still shows the real site. If you store or compare URLs, check that flag.
- **Speed.** Google's API answered in well under a second. Here every request reads a live Google page, so expect seconds, not milliseconds, and a little longer for the first request after a quiet period while the server starts.
- **Limit of 100 results per query**, 10 per request, the same as the API.

### Use it without code

The Actor also has a normal input form. Add your queries, choose how many results you want per query and press **Start**. Results go to a dataset you can download as JSON, CSV or Excel, or send onward with Apify integrations (Make, n8n, Zapier, webhooks).

| Field | What it does |
|---|---|
| Search queries | One search per line |
| Results per query | 10 results = 1 search; up to 100 |
| Only these sites | Restrict every search to up to 20 sites |
| Country, Interface language | The API's `gl` and `hl` |
| Only recent results | `d7`, `w2`, `m6`, `y1` |
| Exact phrase, Excluded words, File type | The API's `exactTerms`, `excludeTerms`, `fileType` |
| Output format | One row per result, or the API's JSON, one row per page |

One row per result:

```json
{
  "query": "web scraping tools",
  "position": 1,
  "title": "Scrapy — open source web scraping framework for Python",
  "link": "https://www.scrapy.org/",
  "displayLink": "www.scrapy.org",
  "snippet": "An open source and collaborative framework for extracting the data you need from websites.",
  "htmlSnippet": "An open source and collaborative framework for <b>extracting the data</b> you need from websites.",
  "totalResults": 126,
  "searchedAt": "2026-11-12T18:20:00.000Z"
}
```

Every run also saves a `REPORT` record with the status of each query, the results saved and the searches charged.

### Pricing

You pay per **search**: one request to the endpoint, or one page of up to 10 results in a run. This is the same unit Google billed. Requests that fail (400, 429, 503) are not charged. The current price per search is shown on this page.

The server runs in your own Apify account, so Apify's platform usage is billed to you as well, on top of the search price. In our test runs (November 2026) that came to about **$0.0028 per search**: $0.0025 for Google SERP proxy and about $0.0003 of compute. While the server waits for the next request after a burst, it keeps using a little compute (512 MB for up to 2 minutes, roughly $0.003 at Apify's standard rate). Your plan's prices apply, so check your own usage after a first batch.

### FAQ

**Is this Google's API?**
No. It is an independent Actor that reads public Google result pages and returns them in the format of the Custom Search JSON API. It is not affiliated with Google.

**Do I still need a Programmable Search Engine or a Google API key?**
No. You only need an Apify account and its API token.

**Can I keep `cx` in my requests?**
Yes. It is accepted and echoed back in `queries.request[0].cx`, so code that sends or checks it keeps working.

**I used the free 100 queries a day. Is there a free tier here?**
Apify's free plan includes monthly platform credit that you can spend on this Actor.

**Does image search (`searchType=image`) work?**
Not yet. The endpoint returns web results only and answers image requests with a 400 error.

**How many results can I get for a query?**
Up to 100, ten per request, by raising `start` (1, 11, 21, …) or following `queries.nextPage`, exactly as with the API.

**Something looks wrong.**
Open an issue on the Actor's **Issues** tab with the request you sent (without your token) and what you expected.

# Actor input Schema

## `queries` (type: `array`):

What you would send as the API's q parameter, one search per line. Google operators work ("exact phrase", -word, site:example.com, filetype:pdf). To call the Actor as an HTTP API instead, see the Server tab and the README.

## `maxResultsPerQuery` (type: `integer`):

Google lists 10 results per page and one page is one charged search, so 10 results cost one search and 100 cost ten. Google stops at 100, like the API did. A page sometimes has 9 results, so you can get slightly fewer than you asked for.

## `sites` (type: `array`):

Optional. Restrict every search to these sites, the way a Programmable Search Engine did: example.com, docs.example.com or example.com/blog. Up to 20.

## `countryCode` (type: `string`):

Optional two-letter country code that tunes results to a country, for example us, gb, br or de. Same as the API's gl.

## `languageCode` (type: `string`):

Optional. Same as the API's hl, for example en, pt-BR or es. Default: en.

## `dateRestrict` (type: `string`):

Optional. d7 = last 7 days, w2 = last 2 weeks, m6 = last 6 months, y1 = last year. Same as the API's dateRestrict.

## `exactTerms` (type: `string`):

Optional. A phrase every result must contain. Same as the API's exactTerms.

## `excludeTerms` (type: `string`):

Optional. Words no result may contain, separated by spaces. Same as the API's excludeTerms.

## `fileType` (type: `string`):

Optional. Only results of this file type, for example pdf, docx or xlsx. Same as the API's fileType.

## `safeSearch` (type: `boolean`):

Filter explicit results (the API's safe=active).

## `outputFormat` (type: `string`):

"One row per result" is easiest for spreadsheets. "API responses" saves one row per result page, exactly the JSON the /customsearch/v1 endpoint returns.

## Actor input object example

```json
{
  "queries": [
    "web scraping tools"
  ],
  "maxResultsPerQuery": 10,
  "safeSearch": false,
  "outputFormat": "results"
}
```

# Actor output Schema

## `results` (type: `string`):

Title, link, site and snippet of every result, with its position for the query.

## `report` (type: `string`):

Per-query status, results saved and searches charged.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "queries": [
        "web scraping tools"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("roomy_tweet/google-custom-search-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "queries": ["web scraping tools"] }

# Run the Actor and wait for it to finish
run = client.actor("roomy_tweet/google-custom-search-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "queries": [
    "web scraping tools"
  ]
}' |
apify call roomy_tweet/google-custom-search-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,roomy_tweet/google-custom-search-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/EUS23WMfMGlYaJjnn/builds/iXAU6ug5Qhy6RdKkl/openapi.json
