# Google News Scraper (`logical_variety/google-news`) Actor

Get Google News search results and topic sections as structured JSON.

- **URL**: https://apify.com/logical_variety/google-news.md
- **Developed by:** [Logical Variety](https://apify.com/logical_variety) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.50 / 1,000 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 News Scraper

Get Google News search results and topic sections as structured JSON.

Pick an **action** and fill in its fields — the Actor fetches the data once and
stores the answer in the dataset: a list as one item per element.

### Input

`action` is required and selects what to fetch.

Each action uses only its own fields: fields of other actions are ignored and
not sent. A key that is not a field of this Actor (e.g. a typo) fails the run.
Required fields are checked before any request; an empty or whitespace-only
string counts as a missing value.

| Action | What it returns | Required | Optional |
|--------|-----------------|----------|----------|
| `search` | Search news | `query` | `hl`, `gl`, `ceid`, `limit`, `offset`, `after`, `before`, `when` |
| `topic` | Topic section | `topic` | `hl`, `gl`, `ceid`, `limit`, `offset` |

| Field | Type | Description |
|-------|------|-------------|
| `query` | string | Search query, e.g. artificial intelligence. |
| `topic` | string, one of `WORLD`, `NATION`, `BUSINESS`, `TECHNOLOGY`, `ENTERTAINMENT`, `SPORTS`, `SCIENCE`, `HEALTH` | Google News topic section. |
| `hl` | string, `search`: must be a language tag like "en" or "en-US" | Host language, e.g. en-US ("search" requires a language tag like en or en-US). |
| `gl` | string, `search`: must be a 2-letter uppercase country code like "US" | Host country, e.g. US ("search" requires a 2-letter uppercase code). |
| `ceid` | string, `search`: must be in COUNTRY:language format like "US:en" | Country edition ID, e.g. US:en ("search" requires COUNTRY:language). |
| `limit` | integer, >= 1 | Max number of results to return. |
| `offset` | integer, >= 0 | Result offset for pagination, starting from 0. |
| `after` | string, must be a date in YYYY-MM-DD format | Start of the date range, YYYY-MM-DD (inclusive). |
| `before` | string, must be a date in YYYY-MM-DD format | End of the date range, YYYY-MM-DD (inclusive). |
| `when` | string, must be a number followed by h, d or y, like "1h", "7d" or "1y" | Open-ended date range: a number followed by h (hours), d (days) or y (years), e.g. 1h, 7d, 1y. |

Example:

```json
{"action":"search","query":"artificial intelligence","hl":"en-US","gl":"US","ceid":"US:en"}
```

### Output

- `search` (`items`), `topic` (`items`): one dataset item per element of the list, as is. The rest
  of the answer (cursor, counters and other fields without the list) is stored
  in key-value store record `PAGE_INFO`; an answer with
  nothing but the list writes no record. An empty list stores no items.
- A rejected value (e.g. a query the source does not accept) or an item the source
  reports as missing is stored as one item
  `{ "success": false, "response": 2, "response_type": "invalid request", "message": "..." }`
  (`"response": 10`, `"page not found"` when the source reports 404 or 410) and the run
  still succeeds. Only error items have the `success` field.
- The run fails without storing data when the input is invalid (checked before
  any request), the data source is unavailable or returns an unexpected answer,
  or it does not answer within 60 seconds.

### Pricing

This Actor uses **pay-per-event** pricing: you pay for the Actor start and for
each result, platform usage (compute) is included. The prices are on the
Actor's page in Apify Store.

- A result is one dataset item with data: `search`, `topic` — each element of the list.
- Only the Actor start is charged for an error item, an empty list and a run that fails.
- With a maximum cost per run set, the Actor stores only as many items as the
  limit covers: the rest of the answer is not stored.

### Run via API

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/logical_variety~google-news/run-sync-get-dataset-items?token=<APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"action":"search","query":"artificial intelligence","hl":"en-US","gl":"US","ceid":"US:en"}'
```

# Actor input Schema

## `action` (type: `string`):

What to fetch. Only the fields of the selected action are sent; fields of other actions are ignored.

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

Search query, e.g. artificial intelligence. Actions: search (required).

## `topic` (type: `string`):

Google News topic section. Actions: topic (required).

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

Host language, e.g. en-US ("search" requires a language tag like en or en-US). Actions: search, topic.

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

Host country, e.g. US ("search" requires a 2-letter uppercase code). Actions: search, topic.

## `ceid` (type: `string`):

Country edition ID, e.g. US:en ("search" requires COUNTRY:language). Actions: search, topic.

## `limit` (type: `integer`):

Max number of results to return. Actions: search, topic.

## `offset` (type: `integer`):

Result offset for pagination, starting from 0. Actions: search, topic.

## `after` (type: `string`):

Start of the date range, YYYY-MM-DD (inclusive). Actions: search.

## `before` (type: `string`):

End of the date range, YYYY-MM-DD (inclusive). Actions: search.

## `when` (type: `string`):

Open-ended date range: a number followed by h (hours), d (days) or y (years), e.g. 1h, 7d, 1y. Actions: search.

## Actor input object example

```json
{
  "action": "search",
  "query": "artificial intelligence",
  "hl": "en-US",
  "gl": "US",
  "ceid": "US:en"
}
```

# Actor output Schema

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

Dataset items: search, topic — one item per element of the list; other actions — the answer as one item. Errors: one item { success: false, ... }.

## `pageInfo` (type: `string`):

PAGE_INFO record written by search, topic: the rest of the answer without the list (cursor, counters). Not written when the answer has nothing but the list.

# 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 = {
    "action": "search",
    "query": "artificial intelligence",
    "hl": "en-US",
    "gl": "US",
    "ceid": "US:en"
};

// Run the Actor and wait for it to finish
const run = await client.actor("logical_variety/google-news").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 = {
    "action": "search",
    "query": "artificial intelligence",
    "hl": "en-US",
    "gl": "US",
    "ceid": "US:en",
}

# Run the Actor and wait for it to finish
run = client.actor("logical_variety/google-news").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 '{
  "action": "search",
  "query": "artificial intelligence",
  "hl": "en-US",
  "gl": "US",
  "ceid": "US:en"
}' |
apify call logical_variety/google-news --silent --output-dataset

```

## MCP server setup

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

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/ENPPNNRAfS3WkDLFg/builds/mT3babdjt8t5qA3bc/openapi.json
