# Google News

The Google News API enables retrieval of Google News search results and returns structured JSON output.

It supports news search queries with filters such as language, geographic location, and pagination.

### API Setup

#### Endpoint

```
https://serp-api.netnut.io/search
```

#### Authentication

Use HTTP Basic Authentication:

```
Authorization: Basic <base64(username:password)>
```

Where `<base64(username:password)>` is the Base64-encoded string of your NetNut credentials.

### Request Format

The request is sent as a GET request. All parameters are passed directly in the URL query string.

#### Example Request

```http
https://serp-api.netnut.io/search?engine=google_news&q=ai&hl=en&gl=us&start=20&rawHtml=1
```

### Request Parameters

| Field     | Type    | Description                                                                                     | Parameter Type |
| --------- | ------- | ----------------------------------------------------------------------------------------------- | -------------- |
| `engine`  | string  | Search engine to use. For this product, use `google_news`.                                      | Required       |
| `q`       | string  | Search query or topic for the news search.                                                      | Required       |
| `hl`      | string  | Language of the Google News results. Example: `en`.                                             | Optional       |
| `gl`      | string  | Geographic location for the search results. Example: `us`.                                      | Optional       |
| `start`   | integer | Pagination offset. Use multiples of 10 to retrieve subsequent pages. Example: `10`, `20`.       | Optional       |
| `rawHtml` | integer | Controls whether raw HTML is returned. `1` = return parsed JSON + HTML, `2` = return HTML only. | Optional       |

### Code Examples

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X GET "https://serp-api.netnut.io/search?engine=google_news&q=ai&hl=en&gl=us&start=20&rawHtml=1" \
  -u "username:password"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from base64 import b64encode

headers = {
    "Authorization": "Basic " + b64encode(b"username:password").decode()
}

params = {
    "engine": "google_news",
    "q": "ai",
    "hl": "en",
    "gl": "us",
    "start": 20,
    "rawHtml": 1
}

response = requests.get("https://serp-api.netnut.io/search", headers=headers, params=params)
print(response.json())
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const username = "username";
const password = "password";

const params = new URLSearchParams({
  engine: "google_news",
  q: "ai",
  hl: "en",
  gl: "us",
  start: 20,
  rawHtml: 1
});

const response = await fetch(`https://serp-api.netnut.io/search?${params}`, {
  method: "GET",
  headers: {
    "Authorization": "Basic " + Buffer.from(`${username}:${password}`).toString("base64")
  }
});

const data = await response.json();
console.log(data);
```

{% endtab %}
{% endtabs %}

### Response Format

The Google News API returns structured JSON.

No HTML is returned by default. When `rawHtml=1`, the response includes both the parsed JSON and the raw HTML. When `rawHtml=2`, the response returns only the raw HTML.

#### Example JSON Response

```json
{
  "url": "https://www.google.com/search?gl=US&hl=en&q=ai&tbm=nws",
  "general": {
    "searchEngine": "google_news",
    "resultsCount": 13600000,
    "searchTime": 0.29,
    "language": "en",
    "device": "desktop",
    "searchType": "text",
    "pageTitle": "ai - Google Search",
    "timestamp": "2026-04-19T14:01:22.881836371Z",
    "render": false
  },
  "input": {
    "originalUrl": "https://www.google.com/search?gl=US&hl=en&q=ai&tbm=nws",
    "jobId": "95644424-e68a-4b09-bb4f-c977393fa455"
  },
  "newsResults": [
    {
      "title": "Starbucks Just Launched an AI Order-Picker on ChatGPT. Is It Genius or Insane?",
      "source": "Inc.com",
      "timeSince": "5 hours ago",
      "link": "https://www.inc.com/bill-murphy-jr/starbucks-just-launched-an-ai-order-picker-on-chatgpt-is-it-genius-or-insane/91333016",
      "image": "data:image/jpeg;base64,...",
      "description": "Starbucks just rolled out a ChatGPT app that lets customers order coffee using artificial intelligence.",
      "rank": 1
    },
    {
      "title": "No to laissez-faire on AI, yes to a light touch",
      "source": "The Economist",
      "timeSince": "53 minutes ago",
      "link": "https://www.economist.com/by-invitation/2026/04/19/no-to-laissez-faire-on-ai-yes-to-a-light-touch",
      "image": "data:image/jpeg;base64,...",
      "description": "Anthropic, a frontier AI company, revealed recently that it had trained a large language model called Mythos.",
      "rank": 2
    },
    {
      "title": "Trump-branded AI data center megaproject stalls, CEO departs",
      "source": "Axios",
      "timeSince": "47 minutes ago",
      "link": "https://www.axios.com/2026/04/19/ai-data-center-project-troubles-texas",
      "image": "data:image/jpeg;base64,...",
      "description": "Fermi America is emerging as a high-profile test of ambitious AI data center projects.",
      "rank": 3
    }
  ],
  "pagination": {
    "prevPageLink": "https://www.google.com/search?q=ai&tbm=nws&start=10",
    "nextPageLink": "https://www.google.com/search?q=ai&tbm=nws&start=30",
    "prevPageStart": 10,
    "nextPageStart": 30,
    "prevPage": 2,
    "currentPage": 3,
    "nextPage": 4,
    "otherPages": {
      "": "https://www.google.com/search?q=ai&tbm=nws&start=0",
      "2": "https://www.google.com/search?q=ai&tbm=nws&start=10",
      "4": "https://www.google.com/search?q=ai&tbm=nws&start=30"
    }
  },
  "pagesProcessed": 1
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.netnut.io/netnut-documentation/netnut-scraper-apis/serp-api/google-scraper/google-news.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
