# RAG Web Search - Search the Web, Get Markdown for AI Agents (`rjmacarthy/rag-web-search`) Actor

Search the web and get the top result pages as clean Markdown for LLMs, RAG and AI agents, in one call. $0.001 per page returned: the search is free, failed pages are replaced and never charged. Content is cut to fit a context window, with a token estimate per page.

- **URL**: https://apify.com/rjmacarthy/rag-web-search.md
- **Developed by:** [rj](https://apify.com/rjmacarthy) (community)
- **Categories:** AI, Developer tools, MCP servers
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 page returneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## RAG Web Search - Search the Web, Get Markdown for AI Agents

Give it a search query and get back the **top result pages as clean Markdown**, each with its search rank, title and snippet. One call gives an LLM, a RAG pipeline or an AI agent grounded, current web content: no separate search API, no scraper, no HTML clean-up.

Why this one instead of other search-and-fetch Actors:

- **A 3-result query costs $0.003.** You pay $0.001 per page returned and nothing for the search. The best-known alternative, `apify/rag-web-browser`, charges $0.0029 per search plus $0.0019 per page on the Bronze plan: $0.0086 for the same query, 2.9x more.
- **Failed pages are replaced, not charged.** A result that times out, blocks the request, is a PDF or has no text is skipped and the next search result takes its place.
- **Results sized for a context window.** `maxContentChars` cuts each page at a paragraph boundary, and every row carries `tokensEstimate`.
- **Fast.** Plain HTTP, result pages fetched in parallel: a 3-result query took 2 to 3 seconds in our tests, five queries with 3 results each 7 seconds.

The honest limits: results come from **DuckDuckGo (with Bing as a fallback), not Google**; pages are fetched **without running JavaScript**; and this is a normal Actor run (agents can call it through the Apify MCP server), not an always-on Standby server. See [Tips and limits](#tips-and-limits).

### What data can you get

| Field | What it is |
|---|---|
| `query` | The search query (or URL) this row answers |
| `rank` | Position of the page among the search engine's organic results (1 = first) |
| `url`, `title` | Page URL after redirects and the page's `<title>` |
| `snippet` | The snippet the search engine showed for the result |
| `markdown` | Main content as clean Markdown: navigation, header, footer, sidebars, cookie banners and scripts removed; headings, lists, tables, code blocks and links kept |
| `text`, `html` | Optional plain text and cleaned HTML of the same content |
| `description`, `language` | Meta description and `<html lang>` |
| `wordCount`, `tokensEstimate` | Size of the returned content; tokens are estimated as characters / 4 |
| `truncated` | `true` when the content was cut at `maxContentChars` |
| `statusCode`, `needsJavaScript` | HTTP status; `true` when the page looks client-rendered |
| `searchResults`, `error` | Only on a row without a page: the search results (`rank`, `url`, `title`, `snippet`) and the reason |
| `id`, `fetchedAt`, `scrapedAt` | Stable ID (hash of query + URL) and fetch time |

### Use cases

- **Web search tool for an AI agent:** let Claude, a LangGraph agent or a custom assistant answer questions about current events, prices or documentation with sources.
- **RAG over the live web:** fetch the top pages for a question and put the Markdown straight into the prompt, with `tokensEstimate` to budget the context.
- **Research and fact-checking:** run a list of questions and get the leading sources for each, ranked and cleaned.
- **Content and SEO research:** read what the top-ranking pages for a keyword actually say.
- **URL to Markdown:** put URLs in the query list and get those pages as Markdown, no search involved.

### How to use

1. Type one or more queries into **Search queries or URLs**. A line that is an `http(s)://` URL is fetched directly.
2. Set **Pages per query** (default 3, max 10).
3. Run. Each row in the dataset is one page; rows of a query are in rank order.

Answer one question with three sources (the default):

```json
{
    "queries": ["what is retrieval augmented generation"],
    "maxResults": 3
}
```

Several questions in one run, shorter pages, no video or forum results:

```json
{
    "queries": ["python asyncio TaskGroup tutorial", "how does HTTP/3 differ from HTTP/2"],
    "maxResults": 4,
    "maxContentChars": 8000,
    "skipDomains": ["youtube.com", "reddit.com"],
    "includeLinks": false
}
```

Search in another country and language:

```json
{
    "queries": ["beste Wärmepumpe für Altbau"],
    "country": "DE",
    "language": "de",
    "maxResults": 4
}
```

Mix a search with pages you already know:

```json
{
    "queries": ["latest stable version of node.js", "https://nodejs.org/en/about/previous-releases"]
}
```

#### Input reference

| Field | Default | Notes |
|---|---|---|
| `queries` | required | Search queries; a URL is fetched directly without a search |
| `maxResults` | 3 | Pages returned per query, 1 to 10 (0 = 10) |
| `maxContentChars` | 20000 | Cut `markdown` and `text` at a paragraph boundary; 0 = no limit |
| `freshness` | `any` | `day`, `week` or `month` (see Tips and limits) |
| `country`, `language` | `US`, `en` | Select the search region, e.g. `DE` + `de` |
| `skipDomains` | none | Results on these domains and their subdomains are skipped |
| `outputFormats` | `["markdown"]` | Any of `markdown`, `text`, `html` |
| `includeLinks` | true | Off = link text only, which saves tokens |
| `requestTimeoutSecs` | 15 | Per result page; a slower page is replaced |
| `proxyConfiguration` | off | Apify datacenter proxy or your own proxy URLs; no residential |

### Output example

A real row from the default input (Markdown shortened here):

```json
{
  "id": "493c570498398ce2",
  "query": "what is retrieval augmented generation",
  "rank": 1,
  "url": "https://www.geeksforgeeks.org/nlp/what-is-retrieval-augmented-generation-rag/",
  "title": "What is Retrieval-Augmented Generation (RAG) - GeeksforGeeks",
  "snippet": "Retrieval-Augmented Generation (RAG) is a way to make AI answers more reliable by combining searching for …",
  "markdown": "Retrieval-Augmented Generation (RAG) is a way to make AI answers more reliable by combining searching for relevant information and then generating a response. Instead of guessing based only on old training data, it first finds useful data from external sources (like documents or databases) and then uses it to give a better answer.\n\n- Fetches up-to-date data and reduces incorrect or made-up answers\n- Works well with specialized data like medical or legal content\n- No need to retrain the model every time new data comes in\n- Can use user-specific data to give more relevant responses\n\nRetrieval Augmented Generation (RAG)\n\nFor example, a platform like GeeksforGeeks has its own large collection of ... (6,822 characters in total)",
  "text": null,
  "html": null,
  "description": "Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more.",
  "language": "en",
  "wordCount": 955,
  "tokensEstimate": 1706,
  "truncated": false,
  "statusCode": 200,
  "needsJavaScript": false,
  "searchResults": null,
  "error": null,
  "fetchedAt": "2026-11-18T16:09:33.178Z",
  "scrapedAt": "2026-11-18T16:09:33.178Z"
}
```

When no result page of a query can be fetched, you get one **uncharged** row with `markdown: null`, the reason in `error` and the results in `searchResults`, so an agent still has links to work with.

### Pricing

Pay per event, the same on every Apify plan:

| Event | Price |
|---|---|
| `page` - one page returned with content | $0.001 |
| `apify-actor-start` - once per run | $0.00005 |

The search itself is free. Pages that fail, time out, are not HTML or have no text are not charged, and neither are rows without a page.

- One query, 3 pages: **$0.003**
- 100 queries x 3 pages: **$0.30**
- 1,000 pages: **$1.00**

`maxResults` x the number of queries is the most a run can cost. You can also set a maximum cost per run in the run options; the Actor stops cleanly when it is reached.

### Tips and limits

- **DuckDuckGo, not Google.** Rankings differ from Google's. For most informational queries the top pages overlap heavily, but this is not a Google results scraper.
- **No JavaScript rendering.** Pages are fetched over plain HTTP. A search result that shows no text without JavaScript is replaced by the next result. A URL you give directly is returned with whatever text it has, and `needsJavaScript: true` tells you when that is little or nothing.
- **Some sites refuse automated requests.** Reddit, Forbes, Scribd, academic publishers and others answered HTTP 403 in our tests. Those results are skipped and replaced; add sites you never want to `skipDomains` to save time. A query whose results are mostly such sites can return fewer pages than `maxResults`: the Actor tries at most 2 x `maxResults` results.
- **Search results of fewer than 50 words are replaced** (login walls, redirect stubs, empty app shells).
- **`freshness` is best effort, and there is no `site:` filter.** The date filter is passed to the search engine as given; results it dates wrongly can still appear.
- **If the search is refused**, the Actor retries on fresh IP addresses (up to 4 on DuckDuckGo), then falls back to Bing. If every attempt fails, it says so in the log and the `RUN_SUMMARY` and charges nothing for those queries. Run again later.
- **PDFs and other files are skipped.** Only HTML and plain-text / Markdown responses are converted.
- **`maxContentChars` applies to `markdown` and `text`.** The optional `html` field is not cut.
- **One market per run.** `country` and `language` apply to every query of the run.
- **Speed.** Searches run one per second through a single session; result pages are fetched in parallel. Queries with many blocked results take longer because replacements are fetched.

### FAQ

**How is this different from apify/rag-web-browser?**
Same idea, different trade-offs. Theirs searches Google and can render JavaScript in a browser. This one searches DuckDuckGo over plain HTTP, charges only for pages returned ($0.001 each, no search fee), replaces failed pages for free and can cut content to a size you choose.

**Can I use it as a tool for Claude, ChatGPT or my own agent?**
Yes. Add the Actor through the Apify MCP server (`mcp.apify.com`) or call it with the Apify API and read the dataset. A typical call takes a few seconds.

**How many tokens will a result use?**
Each row has `tokensEstimate` (characters / 4). With the default `maxContentChars` of 20,000, a page is at most about 5,000 tokens, so three pages fit in roughly 15,000 tokens.

**Why did I get fewer pages than `maxResults`?**
The remaining results could not be fetched or had no text, and the Actor had already tried twice as many results as you asked for. The `RUN_SUMMARY` record lists every failed page with the reason.

**Why is there a row with `markdown: null`?**
No page could be returned for that query. The row is free and tells you why (`error`), with the search results in `searchResults` when the search itself worked.

**Can I use residential proxies?**
No. If you select the RESIDENTIAL group, the Actor logs a warning and uses the Apify datacenter proxy instead. Datacenter proxies and your own proxy URLs work.

**Is it legal?**
The Actor reads public search results and public web pages, the same content any visitor sees, without logging in. It does not collect personal contact data. You are responsible for how you use the content: respect copyright, the terms of the sites you read and the privacy laws that apply to you (GDPR, CCPA).

### Integrations

- **API:** start runs and read the dataset with the [Apify API](https://docs.apify.com/api/v2) or the JavaScript / Python clients. `GET /datasets/{id}/items?view=content` returns `query`, `rank`, `url`, `title` and `markdown`.
- **MCP:** call the Actor from Claude, Cursor or any MCP client through the Apify MCP server.
- **LangChain / LlamaIndex:** load the dataset with their Apify dataset loaders, mapping `markdown` to the document text and `url` to the source.
- **Make, Zapier, n8n:** run the Actor inside a workflow and pass the rows to your LLM step.
- **Webhooks:** trigger your own job when a run succeeds.

### Changelog

- **0.1.4** (2026-11-22): search moved from Bing to DuckDuckGo (Bing kept as the fallback). Bing had started returning unrelated results for many queries.
- **0.1** (2026-11-18): first version. Bing search, parallel page fetch, Markdown / text / HTML output, replacement of failed pages, `maxContentChars`, freshness and skip-domain filters.

### More scrapers by the same developer

- [AI Visibility Tracker: ChatGPT, Perplexity, Gemini, Claude](https://apify.com/rjmacarthy/ai-search-visibility-tracker)
- [AliExpress Scraper - Product Search, Prices, Ratings & Details](https://apify.com/rjmacarthy/aliexpress-scraper)
- [Apple App Store Scraper: Apps, Search & Reviews](https://apify.com/rjmacarthy/app-store-scraper)
- [AutoScout24 Scraper - Used Car Listings & Prices (Europe)](https://apify.com/rjmacarthy/autoscout24-scraper)
- [Bilibili Scraper - Videos, Search, Popular & Uploader Stats](https://apify.com/rjmacarthy/bilibili-scraper)
- [Bing Search Scraper: Organic Results, Ads & Related Searches](https://apify.com/rjmacarthy/bing-search-scraper)

Browse all my Actors on [my Apify Store profile](https://apify.com/rjmacarthy).

### Support

Got wrong or missing content for a query? Open an issue on the Actor's Issues tab with the query and the run ID, and it will be looked at.

# Actor input Schema

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

One search query per line. Each query is searched on the web (DuckDuckGo) and its top result pages are returned as Markdown. A line that is an http(s) URL is fetched directly, without a search.

## `maxResults` (type: `integer`):

How many result pages to fetch and return for each query (max 10; 0 = 10). Each page returned is one charged event ($0.001); the search itself is free. A page that fails, times out or is not HTML is replaced by the next search result and is not charged.

## `maxContentChars` (type: `integer`):

Cut each page's Markdown (and text) at a paragraph boundary so a result fits an LLM context window: 20,000 characters is about 5,000 tokens. 0 = no limit.

## `freshness` (type: `string`):

Only search results dated within this period. If the fallback search (Bing) ignores the filter for a run, the Actor returns an uncharged row with the reason instead of wrong pages.

## `country` (type: `string`):

Country to search in.

## `language` (type: `string`):

Two-letter language of the search, e.g. en, de, fr, es. Together with the country it selects the search region (de + DE = de-DE). If there is no market for the pair, the country's main language is used.

## `skipDomains` (type: `array`):

Search results on these domains (and their subdomains) are skipped, e.g. youtube.com, pinterest.com.

## `outputFormats` (type: `array`):

Which content fields to fill: markdown (default), text, html. The price per page is the same.

## `includeLinks` (type: `boolean`):

On: links stay as [text](https://absolute.url). Off: only the link text, which saves tokens.

## `requestTimeoutSecs` (type: `integer`):

Maximum time to wait for one result page. A page that takes longer is replaced by the next search result.

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

Off by default. Used for fetching result pages (and the Bing fallback search): turn on Apify Proxy (automatic = datacenter) if result pages block the run's IP. Residential proxies are not supported: if you select the RESIDENTIAL group the Actor logs a warning and uses the datacenter proxy instead.

## Actor input object example

```json
{
  "queries": [
    "what is retrieval augmented generation"
  ],
  "maxResults": 3,
  "maxContentChars": 20000,
  "freshness": "any",
  "country": "US",
  "language": "en",
  "skipDomains": [],
  "outputFormats": [
    "markdown"
  ],
  "includeLinks": true,
  "requestTimeoutSecs": 15,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

One row per page: query, rank, size and status.

## `content` (type: `string`):

Query, rank, URL, title and Markdown of every page.

## `search` (type: `string`):

Rank, title and snippet of every page as shown on the search page.

## `allItems` (type: `string`):

Every row with every field.

## `runSummary` (type: `string`):

Per-query status, replaced pages, warnings, request counts and duration.

# 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": [
        "what is retrieval augmented generation"
    ],
    "maxResults": 3,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("rjmacarthy/rag-web-search").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": ["what is retrieval augmented generation"],
    "maxResults": 3,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("rjmacarthy/rag-web-search").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": [
    "what is retrieval augmented generation"
  ],
  "maxResults": 3,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call rjmacarthy/rag-web-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rjmacarthy/rag-web-search"
        }
    }
}
```

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/ybxdvjOSj7A2INfro/builds/ZpfuiOpKtPybeb7dk/openapi.json
