# Custom Search API Replacement - Web Search JSON API (`scrapewise/custom-search-api-replacement`) Actor

Custom Search API replacement: the same parameters (q, cx, num, start, gl, hl, lr, safe, dateRestrict, siteSearch) and the same JSON (items\[], searchInformation, queries.nextPage) as the Google Custom Search JSON API. Batch runs or a live HTTP endpoint: change the base URL, keep your code.

- **URL**: https://apify.com/scrapewise/custom-search-api-replacement.md
- **Developed by:** [Scrapewise Data](https://apify.com/scrapewise) (community)
- **Categories:** 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 $2.28 / 1,000 search results pages

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Custom Search API replacement: web search in the same JSON

This Actor gives you **web search results in the exact format of the Custom Search JSON API**: the same request parameters (`q`, `cx`, `num`, `start`, `gl`, `hl`, `lr`, `cr`, `safe`, `dateRestrict`, `siteSearch`, `exactTerms`...) and the same response (`kind`, `queries` with `request` and `nextPage`, `searchInformation`, `items[]` with `title`, `link`, `displayLink`, `snippet`, `htmlSnippet`, `pagemap`...).

If your code was built around that API and you need a replacement, you can keep your parser. Run it in batch from the Apify Console or the API, or use it as a **live HTTP endpoint**: change the base URL, swap `key=` for `token=`, and your existing requests keep working.

**Important:** the results come from independent web search indexes, **not from Google**. The format is the same, but the ranking and the pages found can differ from what Google shows. See the FAQ.

### At a glance

| What | Price |
|---|---|
| Search results page (up to 10 results) | **US$ 3.00 per 1,000 pages** (US$ 0.003 each) |
| Run start | US$ 0.005 per run (in endpoint mode: once per started container, not per request) |

- 100 queries, first page each = 100 pages = **US$ 0.305** for one batch run.
- One page = one old API call (up to 10 results). Pages with no results, invalid parameters and errors are **never charged**.
- A spending limit set on the run stops it cleanly with everything delivered so far.

### Quick start

Batch run (one dataset item per page, in the old API JSON):

```json
{
  "queries": ["vector database comparison", "kubernetes operator tutorial"],
  "pagesPerQuery": 2,
  "gl": "us"
}
```

Paste old requests as they are. Full URLs and bare query strings both work. `key` is ignored and `cx` is only echoed back in `queries.request`:

```json
{
  "queries": [
    "https://www.googleapis.com/customsearch/v1?key=YOUR_KEY&cx=YOUR_CX&q=open+source+llm+benchmark&num=5",
    "q=postgres+vacuum+full&siteSearch=postgresql.org&dateRestrict=y1"
  ]
}
```

### Live endpoint (keep your code, change one URL)

The Actor also answers HTTP requests directly (Apify Standby mode), with the same path and parameters as before:

```text
Before: https://www.googleapis.com/customsearch/v1?key=YOUR_KEY&cx=YOUR_CX&q=hello+world
After:  https://scrapewise--custom-search-api-replacement.apify.actor/customsearch/v1?token=YOUR_APIFY_TOKEN&q=hello+world
```

- Authentication: your Apify API token as `?token=...` or the header `Authorization: Bearer ...`.
- `/customsearch/v1` and `/customsearch/v1/siterestrict` are both accepted. `cx` is optional: send it or not, it is echoed back in `queries.request` like before, so you don't need a search engine ID.
- Errors come back in the same shape as before (`{"error": {"code": 400, "message": ..., "errors": [...], "status": "INVALID_ARGUMENT"}}`), so your error handling keeps working too.
- A request that fails on our side returns HTTP 503 and is not charged. Retry after a few seconds.

Python example:

```python
import requests

BASE = "https://scrapewise--custom-search-api-replacement.apify.actor/customsearch/v1"
r = requests.get(BASE, params={"token": "YOUR_APIFY_TOKEN", "q": "vector database comparison", "num": 10})
for item in r.json().get("items", []):
    print(item["position"], item["title"], item["link"])
```

### Input

| Field | What it does |
|---|---|
| `queries` | One search per line: plain terms, search operators (`site:`, `filetype:`, `"exact phrase"`, `-word`) or a full old request URL / query string. |
| `pagesPerQuery` | Results pages per query (1 to 10). Pages follow `start`: 1, 11, 21... |
| `outputFormat` | `api` (default): one item per page in the old JSON. `results`: one flat row per result, ready for CSV and Sheets. |
| `num` | Results per page, 1 to 10. |
| `start` | First result index, 1 to 91 (`start + num` cannot pass 101, the old limit). |
| `gl`, `hl` | Country and language codes, for example `us` / `en`, `de` / `de`. `cr=countryXX` and `lr=lang_xx` are also read. |
| `safe` | `active` filters explicit results. |
| `dateRestrict` | `d7`, `w2`, `m6`, `y1`: only recent pages. |
| `siteSearch`, `siteSearchFilter` | Only one site (`i`) or everything except it (`e`). |
| `lr`, `cr` | Old style language and country restricts (`lang_de`, `countryDE`). Used when `hl` / `gl` are empty. |
| `exactTerms`, `excludeTerms`, `orTerms`, `fileType`, `hq` | Same meaning as before. They are added to the query as search operators. |

Fields set in the form apply to every query. Parameters inside a pasted URL or query string override them for that line.

### Output

Example from our own run (`"queries": ["vector database comparison"], "num": 3`), shortened:

```json
{
  "query": "vector database comparison",
  "startIndex": 1,
  "kind": "customsearch#search",
  "queries": {
    "request": [{"searchTerms": "vector database comparison", "count": 3, "startIndex": 1, "gl": "us", "hl": "en", "safe": "off", "totalResults": "6"}],
    "nextPage": [{"searchTerms": "vector database comparison", "count": 3, "startIndex": 4}]
  },
  "searchInformation": {"searchTime": 8.625, "formattedSearchTime": "8.63", "totalResults": "6", "formattedTotalResults": "6"},
  "items": [
    {
      "kind": "customsearch#result",
      "title": "Vector Database Comparison | Superlinked",
      "htmlTitle": "<b>Vector</b> <b>Database</b> <b>Comparison</b> | Superlinked",
      "link": "https://superlinked.com/vector-db-comparison",
      "displayLink": "superlinked.com",
      "snippet": "Compare 47+ vector databases across features, performance, and adoption. Filter by license, languages, index types.",
      "htmlSnippet": "Compare 47+ <b>vector</b> databases across features, performance, and adoption. Filter by license, languages, index types.",
      "formattedUrl": "https://superlinked.com/vector-db-comparison",
      "htmlFormattedUrl": "https://superlinked.com/vector-db-comparison",
      "pagemap": {},
      "position": 1
    },
    {
      "kind": "customsearch#result",
      "title": "We Tried and Tested 10 Best Vector Databases for RAG Pipelines - ZenML Blog",
      "link": "https://www.zenml.io/blog/vector-databases-for-rag",
      "displayLink": "www.zenml.io",
      "snippet": "For this article, we evaluated and tested the 10 best vector databases for RAG pipelines...",
      "pagemap": {},
      "position": 3,
      "date": "October 1, 2025"
    }
  ]
}
```

| Field | Meaning |
|---|---|
| `items[].title`, `htmlTitle` | Page title. The HTML version has the query words in `<b>`. |
| `items[].link`, `formattedUrl`, `htmlFormattedUrl` | The final page URL. |
| `items[].displayLink` | Host name of the result. |
| `items[].snippet`, `htmlSnippet` | Text excerpt. It can be empty for some pages. |
| `items[].position` | Absolute position (1, 2, ... 11, 12 on page 2). Extra field. |
| `items[].date` | Publication date or age when the index has it ("October 1, 2025", "4 weeks ago"). Extra field. |
| `items[].pagemap` | Always present, as an empty object. Code that reads `item["pagemap"]` keeps working. |
| `items[].mime`, `fileFormat` | On document results (PDF, Word, Excel, PowerPoint), the same values as before, for example `application/pdf` and `PDF/Adobe Acrobat`. |
| `queries.request`, `queries.nextPage`, `queries.previousPage` | Same pagination blocks as before. `nextPage` is present only when a next page exists. |
| `searchInformation.totalResults` | A **lower bound** (results seen so far, plus one page when this one was full), not an index-wide estimate. |
| `query`, `startIndex`, `scrapedAt`, `errorCode`, `error` | Batch mode only: which line of your input produced the item. |

The extra fields don't break parsers written for the old response. In `results` format each row is one item from `items[]` with `query`, `startIndex` and `totalResults` added.

### Errors you may see

Error rows are free and keep your input line in `query`, so you can see which search failed.

| `errorCode` | Meaning |
|---|---|
| `INVALID_INPUT` | A parameter is out of range or malformed (for example `num=50`). The message names the parameter. |
| `NO_RESULTS` | The search returned nothing, or there are no more pages. |
| `SEARCH_UNAVAILABLE` | The search did not answer after several retries. Run it again in a few minutes. |
| `NOT_REACHED` | The run timeout arrived before this search. Raise the timeout or split the input. |

### Integrations, scheduling and AI agents

- **Schedules:** run the same queries every day or hour from Apify Schedules to track who ranks for your keywords.
- **Export:** download the dataset as JSON, CSV, Excel or XML, or read it from the Apify API (`/datasets/{id}/items`).
- **Make, n8n, Zapier:** use the Apify integration to run the Actor and get the dataset, or call the live endpoint from an HTTP node.
- **AI agents:** the endpoint is a plain GET that returns compact JSON, which suits tool calls from LangChain, LlamaIndex or your own agent. The Actor also works through the Apify MCP server.

### FAQ

**Are these Google results?**
No. The results come from independent web search indexes. The response format is the same as the Custom Search JSON API, so your integration keeps working, but rankings and coverage differ. If you need Google's ranking exactly, this is not the right tool.

**Do I need a `cx` search engine ID or an API key from Google?**
No. `key` is ignored and `cx` is optional (only echoed back). You only need an Apify account and token.

**Can I restrict results to my own website, like a site search?**
Yes. Use `siteSearch=yourdomain.com` (or put `site:yourdomain.com` in the query). How many pages show up depends on how well the site is indexed.

**How many results can I get per query?**
Up to 100, the same as before: 10 per page, `start` from 1 to 91.

**Is there a free daily quota?**
Apify's free plan includes monthly platform credit you can use here. Beyond that you pay per page with results.

**Image search?**
Not supported. `searchType=image` returns a clear 400 error.

### Limitations

- Results are not Google's. Rankings, freshness and the number of pages found differ.
- `totalResults` is a lower bound, not an estimate of the whole index.
- `pagemap` is always empty (no thumbnails or metatags). `labels`, `spelling`, `promotions` and `cacheId` are not returned.
- `sort`, `filter`, `linkSite`, `relatedSite`, `lowRange` and `highRange` are accepted but have no effect (`sort` and `filter` are echoed back).
- Very specific queries (rare file types, small sites) may return fewer than 10 results per page.

### Changelog

- **6 Nov 2026:** first version. Batch mode with the old API JSON or flat rows, live endpoint on `/customsearch/v1`, old request URLs accepted as input.
- **8 Nov 2026:** output fields updated: `pagemap` on every result, `mime` and `fileFormat` on documents, `cx`, `sort` and `filter` echoed in `queries.request`. New input fields `lr`, `cr` and `hq`.

*Custom Search JSON API is a product of Google LLC. This Actor is not affiliated with or endorsed by Google.*

# Actor input Schema

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

One search per line. Plain terms (vector database comparison), search operators (site:, filetype:, quotes, -word) or a full old API request URL / query string (q=...\&gl=de\&num=5): its parameters are used and key and cx are ignored.

## `pagesPerQuery` (type: `integer`):

How many results pages to fetch for each query (each page = num results, up to 10). Pages follow the start parameter: 1, 11, 21... Each page with results is one charge.

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

api: each dataset item is the same JSON the old API returned (kind, queries, searchInformation, items). results: one row per result with query, position, title, link, displayLink, snippet and date.

## `num` (type: `integer`):

Results per page, 1 to 10 (same limit as the old API).

## `start` (type: `integer`):

Index of the first result, 1 to 91 (start + num cannot pass 101).

## `gl` (type: `string`):

Two-letter country code for the results, for example us, gb, de. Default us.

## `hl` (type: `string`):

Interface language, for example en, de, fr. Default en.

## `lr` (type: `string`):

Language restrict, as in the old API: lang_en, lang_de, lang_fr... Used when hl is empty.

## `cr` (type: `string`):

Country restrict, as in the old API: countryUS, countryDE... Used when gl is empty.

## `safe` (type: `string`):

active filters explicit results.

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

Only results from the last N days, weeks, months or years: d7, w2, m6, y1.

## `siteSearch` (type: `string`):

Restrict to (or exclude) a site, for example github.com. Several sites: separate with spaces.

## `siteSearchFilter` (type: `string`):

i = only siteSearch, e = everything except siteSearch. Default i.

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

A phrase every result must contain.

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

Words that must not appear, separated by spaces.

## `orTerms` (type: `string`):

Extra words where at least one must appear, separated by spaces.

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

Only this file type, for example pdf.

## `hq` (type: `string`):

Extra query terms appended to every search (the old hq parameter).

## `proxyConfiguration` (type: `object`):

Apify Proxy by default. Change it only if you know you need to.

## Actor input object example

```json
{
  "queries": [
    "vector database comparison"
  ],
  "pagesPerQuery": 1,
  "outputFormat": "api",
  "num": 10,
  "start": 1,
  "gl": "us",
  "safe": "off",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

No description

## `resultsCsv` (type: `string`):

No description

# 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": [
        "vector database comparison"
    ],
    "gl": "us",
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapewise/custom-search-api-replacement").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": ["vector database comparison"],
    "gl": "us",
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("scrapewise/custom-search-api-replacement").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": [
    "vector database comparison"
  ],
  "gl": "us",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call scrapewise/custom-search-api-replacement --silent --output-dataset

```

## MCP server setup

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

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/dSp70u0aJDwYLdVbA/builds/jyLfIfBx0NWDjABYw/openapi.json
