# Google Organic Search Results | Top Links for AI Agents (`wayturn/google-organic-search-for-agents`) Actor

Find up to 10 organic links for one Google query. Choose a country and language and get ranked URLs, titles, snippets and domains for a research agent. Each run requests one results page from Apify’s official Google Search Results Scraper. Upstream charges apply.

- **URL**: https://apify.com/wayturn/google-organic-search-for-agents.md
- **Developed by:** [Wayturn Hung](https://apify.com/wayturn) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 organic results

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

## Google Organic Search Results | Top Links for AI Agents

Give a research agent a ranked shortlist of sources. Choose a query, country and language. Each organic result is one row with the rank, title, URL, snippet and domain.

### Try a three-result search

This input returned three organic links in a US English test. Rankings can change. Pass a chosen URL to a page reader when you need the article text. The Actor requests one page from Apify’s official Google Search Results Scraper.

```json
{
  "query": "Apify Crawlee",
  "countryCode": "us",
  "languageCode": "en",
  "maxResults": 3
}
```

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `query` | string | `Apify Crawlee` | Required. Search terms. |
| `countryCode` | string | `us` | 2-letter country code, passed as Google's country (`gl`). |
| `languageCode` | string | `en` | 2-letter interface language (`hl`). |
| `maxResults` | integer | `5` | 1 to 10. Number of organic results to return. |

### Output

One dataset item per organic result:

```json
{
  "rank": 1,
  "title": "Crawlee: A web scraping and browser automation library",
  "url": "https://crawlee.dev/",
  "snippet": "...",
  "domain": "crawlee.dev",
  "query": "Apify Crawlee",
  "locale": { "countryCode": "us", "languageCode": "en" }
}
```

The key-value store record `OUTPUT` holds a run summary:

- `{ "status": "OK", "count": N, ... }` on success.
- `{ "status": "NO_RESULTS", ... }` when Google genuinely returns no organic results. The run succeeds with an empty dataset.
- `{ "status": "FAILED", "code": "...", "message": "..." }` on error.

### Error codes

- `INVALID_INPUT`: bad query, country, language, or maxResults.
- `UPSTREAM_FAILED`: the `apify/google-search-scraper` run did not succeed. The message includes its run ID.
- `UNEXPECTED_SHAPE`: the upstream output did not contain organic results or search info, so its format may have changed.
- `UNEXPECTED_ERROR`: anything else. Check the run log.

### Cost

Each organic result costs $0.001. The start fee is $0.008 per allocated GB (minimum one event). At 1 GB, three results incur $0.011 in this Actor’s events. The upstream scraper requests one page even if you ask for fewer results. Its page and start charges are separate. See the [upstream pricing](https://apify.com/apify/google-search-scraper/pricing) for current rates.

### Permissions

This Actor calls `apify/google-search-scraper` using the Apify account that runs it. That account needs permission to run Actors and must have enough credit for the upstream charge. No third-party API keys are used.

### Local development

```bash
npm install
apify login
apify run -p input.json
```

Running locally still calls the upstream Actor on your Apify account, so it incurs the same charge.

### Project layout

- `src/main.js`: input validation, upstream call, and result normalization.
- `.actor/`: Actor configuration and schemas (input, output, dataset).
- `Dockerfile`: builds the image.

# Actor input Schema

## `query` (type: `string`):

The search term to look up on Google.

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

Two-letter country code (ISO 3166-1 alpha-2) used for Google's localized results and the proxy location, for example us, gb, de, jp.

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

Two-letter interface language code (ISO 639-1), for example en, de, fr, ja.

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

Number of organic results to return, from 1 to 10.

## Actor input object example

```json
{
  "query": "Apify Crawlee",
  "countryCode": "us",
  "languageCode": "en",
  "maxResults": 5
}
```

# Actor output Schema

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

Each organic result as one dataset item: rank, title, url, snippet, domain, query and locale.

## `summary` (type: `string`):

Link to the run, including the status and the OUTPUT record.

# 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 = {
    "query": "Apify Crawlee",
    "countryCode": "us",
    "languageCode": "en",
    "maxResults": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("wayturn/google-organic-search-for-agents").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 = {
    "query": "Apify Crawlee",
    "countryCode": "us",
    "languageCode": "en",
    "maxResults": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("wayturn/google-organic-search-for-agents").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 '{
  "query": "Apify Crawlee",
  "countryCode": "us",
  "languageCode": "en",
  "maxResults": 5
}' |
apify call wayturn/google-organic-search-for-agents --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,wayturn/google-organic-search-for-agents"
        }
    }
}
```

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/dcZgkBZDHodQxSSa7/builds/ILztd0OfpcSWadbPh/openapi.json
