Effortlessly Access Global News with Cognitive Actions

13 Dec 2025
Effortlessly Access Global News with Cognitive Actions

The Global News Access And Insights API offers developers a powerful toolset to tap into a vast reservoir of news articles from around the world. With the ability to retrieve articles using specific keywords, filter results by country, language, publisher, and date, this API simplifies the task of gathering and analyzing news content from over 100,000 sources in more than 25 languages. By integrating these cognitive actions, developers can enhance their applications with real-time news data, driving user engagement and providing valuable insights.

Common use cases for this API include building news aggregation platforms, developing personalized news feeds, enhancing research tools with up-to-date information, and providing businesses with competitive intelligence. Whether you're creating a media application, a market analysis tool, or simply want to stay informed, this API delivers speed and flexibility in accessing global news.

Prerequisites

To get started, you'll need a valid Cognitive Actions API key and a basic understanding of making API calls.

Find Articles by Keywords

The Find Articles by Keywords action is designed to help you locate articles based on specific search queries. This action solves the problem of efficiently retrieving relevant news content from a vast database, allowing developers to deliver curated news experiences to their users.

Input Requirements

To use this action, the following inputs are required:

  • query: The search term used to query the database (e.g., "nasa").
  • language: The language code for the query (following ISO 639-1 standards, e.g., "en" for English). Optional inputs include:
  • source: Data source from which to retrieve articles.
  • publisher: Name of the publisher.
  • maxResults: Maximum number of search results to return.
  • pageNumber: Page number for pagination.
  • destination: URL where the results will be sent.

Expected Output

The output will include an array of articles matching the query, with details such as:

  • url: Direct link to the article.
  • date: Publication date of the article.
  • title: Title of the article.
  • authors: List of authors.
  • excerpt: Brief summary of the article.
  • keywords: Relevant keywords associated with the article.
  • publisher: Publisher information including name and URL.
  • thumbnail: URL of the article thumbnail image.

Use Cases for this specific action

This action is particularly useful when:

  • Building a news aggregator that allows users to search for articles by topic.
  • Developing a research tool that needs to pull the latest news on specific subjects.
  • Creating personalized content feeds for applications that cater to user interests.
  • Enhancing customer service platforms with up-to-date news relevant to client inquiries.

By leveraging this action, developers can provide tailored news experiences that keep users informed and engaged.


```python
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "ed6b4c29-4558-4052-babb-dc44cf20dc15" # Action ID for: Find Articles by Keywords

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "query": "nasa",
  "language": "en"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Conclusion
The **Global News Access And Insights API** empowers developers to seamlessly integrate news retrieval functionalities into their applications. With the ability to find articles by keywords, this API significantly enhances the user experience by providing timely and relevant news content. As you explore the capabilities of this API, consider how it can be applied to your projects to deliver value and insights to your users. Start building today and transform the way your application interacts with global news!