# GDELT News Data Enrichment Pipeline (`visita/gdelt-news`) Actor

This actor is the central intelligence hub for a multi-pipeline news aggregation system. Its primary role is to fetch, unify, cleanse, and analyze raw news data from multiple Apify news pipeline actors, preparing a structured dataset of topical trends for downstream AI services.

- **URL**: https://apify.com/visita/gdelt-news.md
- **Developed by:** [Visita Intelligence](https://apify.com/visita) (community)
- **Categories:** News, AI, Agents
- **Features:** Limited permissions
- **Stats:** 17 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 gdelt article retrievals

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

## 📰 GDELT Data Enrichment Pipeline

This actor is a specialized data analysis tool designed to enrich raw article metadata retrieved from the **GDELT 2.0 Global Knowledge Graph** API.

It takes broad GDELT queries and converts the resulting article links into **structured, actionable intelligence** by performing a secondary **DuckDuckGo News Search** and advanced LLM (OpenAI) analysis on the original article's topic.

This pipeline is crucial for research, geopolitical monitoring, and threat intelligence gathering, as GDELT provides vast, global coverage that is then refined and analyzed for risk.

***

### How to Use

The primary function of this actor is to transform raw metadata from the GDELT API into a refined dataset suitable for immediate analysis or consumption by downstream systems.

1. **As a Standalone Tool:** Run this actor to generate high-quality, structured news intelligence. Download the resulting dataset for your own geopolitical or security analysis, reports, or to feed into custom dashboards.
2. **As a Data Source for Downstream Systems:** The resulting structured data can be easily consumed by other tools (e.g., our **Content Blueprint AI** actor) to generate reports, threat briefings, and risk summaries based on the enriched GDELT output.

***

### Features

- **GDELT Data Retrieval**: Fetches a defined maximum number of articles from GDELT based on a user-defined query, time range, and language filter.
- **DuckDuckGo Grounding (Priority)**: For every GDELT article, the pipeline executes a targeted **DuckDuckGo News Search** to retrieve fresh, corroborating snippets. This ensures the analysis is based on the most current and validated context, overriding the unverified nature of raw GDELT records.
- **LLM Synthesis and Translation**: An LLM (OpenAI) synthesizes the DuckDuckGo snippets into a concise, coherent summary, **automatically translating the summary into English** for universal consumption, even if the source snippets were in a foreign language.
- **Advanced Risk Analysis**: A second LLM call analyzes the English summary to categorize the topic (e.g., `Malware/Ransomware`), assign a risk level (`High Risk`, `Medium Risk`), and extract key entities.
- **Date Enrichment**: Uses the most consistent date found in the DuckDuckGo snippets as a robust publication date fallback if the original GDELT date is missing or inconsistent.
- **Cost-Saving Test Mode**: Includes a test mode to run the full workflow with dummy data, allowing for development and testing without incurring API costs.

***

### Setup and Configuration

Before running the actor, you only need to provide an API key for the LLM service.

1. **OpenAI API Key**:
   - You will need an API key from your OpenAI account.

#### Add Keys to Apify Secrets

For security, add this key as a **secret environment variable** in your Apify Actor settings:

- `OPENAI_API_KEY`: Your OpenAI API Key.

***

### Cost of Usage 💸

**Important Note:** The costs listed below are for **this actor only**.

#### Costs for This Actor

1. **Apify Platform Usage**: Standard platform costs for running the actor.
2. **GDELT API**: The GDELT API is generally **free**. The actor makes **one call** to GDELT to retrieve the list of articles.
3. **DuckDuckGo Search**: This service is **free**. The actor performs **one search query for every article** it processes.
4. **OpenAI API**: This is the primary cost. The actor makes **two LLM calls for every article**: one to summarize/translate the DuckDuckGo Search snippets and another to perform the final structured analysis (sentiment, category, etc.). The total consumption is tracked via the `llm-analysis-tokens-used` event.

***

### Input

| Field | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `query` | String | `\"Global Economy\" OR theme:ECON_BUSINESS` | The mandatory GDELT search query (e.g., `'\"stock market\" OR theme:CYBER_THREAT'`). |
| `max_records_limit` | Integer | `100` | The maximum number of GDELT articles to retrieve (Max 250). |
| `timespan_offset` | String | `3 days` | A relative time span (e.g., '1week') or an absolute date range. |
| `sort_by` | String | `HybridRel` | The field to sort GDELT results by (e.g., `DateDesc`, `ToneAsc`). |
| `source_lang` | String | `null` | Filter GDELT results to articles originally published in a specific language (e.g., 'english' or 'EN'). |
| `region` | String | `wt-wt` | Region for DuckDuckGo search results (e.g., 'us-en' for US, 'wt-wt' for World). |
| `timeLimit` | String | `w` | Time limit for DuckDuckGo search results ('d' for day, 'w' for week). |
| `runTestMode` | Boolean | `false` | Bypasses all external API calls for zero-cost testing. **Do not enable in production.** |

***

### Output

The actor saves its structured results in the dataset. Each item is a structured JSON object designed for easy consumption:

| Field | Type | Description |
| :--- | :--- | :--- |
| `source` | String | The name of the news source (derived from the URL). |
| `title` | String | The original title of the GDELT article. |
| `url` | String | The URL of the original article. |
| `published` | String | The publication date/time in ISO 8601 format (from GDELT or DuckDuckGo). |
| `summary` | String | The **English, AI-generated summary** of the article content. |
| `sentiment` | String | The AI-analyzed risk/impact (e.g., `High Risk`, `Low Risk/Informational`). |
| `category` | String | The AI-assigned category (e.g., `Vulnerability/CVE`, `Geopolitical`). |
| `key_entities` | Array of Strings | A list of key entities (companies, groups, vulnerabilities, countries). |

# Actor input Schema

## `mode` (type: `string`):

Choose how the actor runs. 'user_query' searches our pre-enriched database. 'admin_ingest' fetches from GDELT, enriches, and stores into Supabase.

## `topic_preset` (type: `string`):

Pick a topic category to fetch from GDELT, or choose 'Custom Query' to enter your own. Only used in Admin Ingest mode.

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

In User Query mode: free-text search (e.g., 'stock market crash'). In Admin Ingest with 'Custom Query' preset: GDELT query (e.g., '"stock market" OR theme:ECON_BUSINESS'). Short words like 'US' are auto-quoted for GDELT compatibility.

## `max_records_limit` (type: `integer`):

Maximum number of articles to return (applies to both modes, max 250).

## `sort_by` (type: `string`):

Sort order for results.

## `filter_category` (type: `string`):

Optional: filter results to a specific category (e.g., 'Malware/Ransomware', 'Policy/Compliance').

## `filter_sentiment` (type: `string`):

Optional: filter results by risk level.

## `timespan_offset` (type: `string`):

GDELT time span back from present (e.g., '3days', '1week'). Only used in Admin Ingest mode.

## `source_lang` (type: `string`):

Filter GDELT results to a specific source language (e.g., 'english').

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

Brave Search freshness filter for enrichment results.

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

Select Apify Proxy or add your own proxies to avoid GDELT rate limits (Admin Ingest mode).

## Actor input object example

```json
{
  "mode": "user_query",
  "topic_preset": "latest_headlines",
  "query": "",
  "max_records_limit": 100,
  "sort_by": "HybridRel",
  "timespan_offset": "3 days",
  "freshness": "pw"
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("visita/gdelt-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("visita/gdelt-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 '{}' |
apify call visita/gdelt-news --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,visita/gdelt-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/aoOJcr4VjQhWifZNA/builds/FlE4dQb2bZ6p9iNwx/openapi.json
