# Google News API (Async)

The `Google News API` endpoint will retrieve news data from a Google news result page and transform it into usable JSON.

**Single Query Request**

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

```bash
curl -X POST \
	-H "Content-Type: application/json" \
	-d '{
			"apiKey": "API_KEY",
			"query": "QUERY",
			"country_code": "COUNTRY_CODE",
			"tld": "TLD",
			"hl": "LANGUAGE",
			"gl": "GEOLOCATION",
			"start": "STARTING_POSITION",
			"callback": {
				"type": "webhook",
				"url": "YYYYY"
			}
		}' \
"https://async.scraperapi.com/structured/google/news"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://async.scraperapi.com/structured/google/news"
headers = {
    "Content-Type": "application/json"
}
data = {
    "apiKey": "API_KEY",
    "query": "QUERY",
    "country_code": "COUNTRY_CODE",
    "tld": "TLD",
    "hl": "LANGUAGE",
		"gl": "GEOLOCATION",
		"start": "STARTING_POSITION",
    "callback": {
        "type": "webhook",
        "url": "YYYYY"
    }
}

response = requests.post(url, json=data, headers=headers)
print(response.text)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import fetch from 'node-fetch';

const options = {
  method: 'POST',
  body: JSON.stringify({
    apiKey: 'API_KEY',
    query: 'QUERY',
    country_code: 'COUNTRY_CODE',
    tld: 'TLD',
    hl: 'LANGUAGE',
		gl: 'GEOLOCATION',
		start: 'STARTING_POSITION',
    callback: {
            type: 'webhook',
            url: 'YYYYY' }}),
  headers: {
    'Content-Type': 'application/json',
  },
}

fetch('https://async.scraperapi.com/structured/google/news', options)
  .then(response => {
    response.text().then(text => console.log(text));
  })
  .catch(error => {
    console.log(error)
  })
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$curl = curl_init();
$data = json_encode(array(
    'apiKey' => 'API_KEY',
    'query' => 'QUERY',
    'country_code' => 'COUNTRY_CODE',
    'tld' => 'TLD',
    'hl' => 'LANGUAGE',
    'gl' => 'GEOLOCATION',
    'start' => 'STARTING_POSITION',
    'callback' => array(
        'type' => 'webhook',
        'url' => 'YYYYY'
    )
));
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://async.scraperapi.com/structured/google/news',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));
$response = curl_exec($curl);
if (curl_errno($curl)) {
    echo 'Error:' . curl_error($curl);
} else {
    echo $response;
}
curl_close($curl);
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://async.scraperapi.com/structured/google/news')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
  apiKey: 'API_KEY',
  query: 'QUERY',
  country_code: 'COUNTRY_CODE',
  tld: 'TLD',
  hl: 'LANGUAGE',
  gl: 'GEOLOCATION',
  start: 'STARTING_POSITION',
  callback: {
    type: 'webhook',
    url: 'YYYYY'
  }
}.to_json
begin
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end
  puts response.body
rescue => e
  puts "Error: #{e.message}"
end
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "API_KEY";
            String jsonInputString = "{"
                + "\"apiKey\": \"" + apiKey + "\", "
                + "\"query\": \"QUERY\", "
                + "\"country_code\": \"COUNTRY_CODE\", "
                + "\"tld\": \"TLD\", "
                + "\"hl\": \"LANGUAGE\", "
                + "\"gl\": \"GEOLOCATION\", "
                + "\"start\": \"STARTING_POSITION\", "
                + "\"callback\": {"
                + "    \"type\": \"webhook\", "
                + "    \"url\": \"YYYYY\""
                + "}}";

            URL url = new URL("https://async.scraperapi.com/structured/google/news");
            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("Accept", "*/*");
            connection.setDoOutput(true);
            try (OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                os.write(input, 0, input.length);
            }
            int responseCode = connection.getResponseCode();
            StringBuilder response = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String readLine;
            while ((readLine = in.readLine()) != null) {
                response.append(readLine);
            }
            in.close();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                System.out.println("Response: " + response.toString());
            } else {
                throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Multiple Queries Request**

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

```bash
curl -X POST \
	-H "Content-Type: application/json" \
	-d '{
			"apiKey": "API_KEY",
			"queries": ["QUERY1", "QUERY2"],
			"country_code": "COUNTRY_CODE",
			"tld": "TLD",
			"hl": "LANGUAGE",
			"gl": "GEOLOCATION",
			"start": "STARTING_POSITION",
			"callback": {
				"type": "webhook",
				"url": "YYYYY"
			}
		}' \
"https://async.scraperapi.com/structured/google/news"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://async.scraperapi.com/structured/google/news"
headers = {
    "Content-Type": "application/json"
}
data = {
    "apiKey": "API_KEY",
    "queries": ["QUERY1", "QUERY2"],
    "country_code": "COUNTRY_CODE",
    "tld": "TLD",
    "hl": "LANGUAGE",
		"gl": "GEOLOCATION",
		"start": "STARTING_POSITION",
    "callback": {
        "type": "webhook",
        "url": "YYYYY"
    }
}

response = requests.post(url, json=data, headers=headers)
print(response.text)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import fetch from 'node-fetch';

const options = {
  method: 'POST',
  body: JSON.stringify({
    apiKey: 'API_KEY',
    queries: ['QUERY1', 'QUERY2'],
    country_code: 'COUNTRY_CODE',
    tld: 'TLD',
    hl: 'LANGUAGE',
		gl: 'GEOLOCATION',
		start: 'STARTING_POSITION',
    callback: {
            type: 'webhook',
            url: 'YYYYY' }}),
  headers: {
    'Content-Type': 'application/json',
  },
}

fetch('https://async.scraperapi.com/structured/google/news', options)
  .then(response => {
    response.text().then(text => console.log(text));
  })
  .catch(error => {
    console.log(error)
  })
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$curl = curl_init();
$data = json_encode(array(
    'apiKey' => 'API_KEY',
    'queries' => ['QUERY1', 'QUERY2'],
    'country_code' => 'COUNTRY_CODE',
    'tld' => 'TLD',
    'hl' => 'LANGUAGE',
    'gl' => 'GEOLOCATION',
    'start' => 'STARTING_POSITION',
    'callback' => array(
        'type' => 'webhook',
        'url' => 'YYYYY'
    )
));
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://async.scraperapi.com/structured/google/news',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));
$response = curl_exec($curl);
if (curl_errno($curl)) {
    echo 'Error:' . curl_error($curl);
} else {
    echo $response;
}
curl_close($curl);
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://async.scraperapi.com/structured/google/news')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
  apiKey: 'API_KEY',
  queries: ['QUERY1', 'QUERY2'],
  country_code: 'COUNTRY_CODE',
  tld: 'TLD',
  hl: 'LANGUAGE',
  gl: 'GEOLOCATION',
  start: 'STARTING_POSITION',
  callback: {
    type: 'webhook',
    url: 'YYYYY'
  }
}.to_json
begin
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end
  puts response.body
rescue => e
  puts "Error: #{e.message}"
end
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "API_KEY";
            String jsonInputString = "{"
                + "\"apiKey\": \"" + apiKey + "\", "
                + "\"queries\": [\"QUERY1\", \"QUERY2\"], "
                + "\"country_code\": \"COUNTRY_CODE\", "
                + "\"tld\": \"TLD\", "
                + "\"hl\": \"LANGUAGE\", "
                + "\"gl\": \"GEOLOCATION\", "
                + "\"start\": \"STARTING_POSITION\", "
                + "\"callback\": {"
                + "    \"type\": \"webhook\", "
                + "    \"url\": \"YYYYY\""
                + "}}";

            URL url = new URL("https://async.scraperapi.com/structured/google/news");
            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("Accept", "*/*");
            connection.setDoOutput(true);
            try (OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                os.write(input, 0, input.length);
            }
            int responseCode = connection.getResponseCode();
            StringBuilder response = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String readLine;
            while ((readLine = in.readLine()) != null) {
                response.append(readLine);
            }
            in.close();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                System.out.println("Response: " + response.toString());
            } else {
                throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Supported Parameters**

<table><thead><tr><th width="264">Parameter</th><th>Details</th></tr></thead><tbody><tr><td><code>API_KEY</code>(required)</td><td>Your API Key.</td></tr><tr><td><code>QUERY</code>(required)</td><td>Example: Space News</td></tr><tr><td><code>TLD</code></td><td>Country of Google domain to scrape. This is an optional argument and defaults to “com” (google.com). Valid values include:<br><strong>com</strong> (google.com)<br><strong>co.uk</strong> (google.co.uk)<br><strong>ca</strong> (google.ca)<br><strong>de</strong> (google.de)<br><strong>es</strong> (google.es)<br><strong>fr</strong> (google.fr)<br><strong>it</strong> (google.it)<br><strong>co.jp</strong> (google.co.jp)<br><strong>in</strong> (google.in)<br><strong>cn</strong> (google.cn)<br><strong>com.sg</strong> (google.com.sg)<br><strong>com.mx</strong> (google.com.mx)<br><strong>ae</strong> (google.ae)<br><strong>com.br</strong> (google.com.br)<br><strong>nl</strong> (google.nl)<br><strong>com.au</strong> (google.com.au)<br><strong>com.tr</strong> (google.com.tr)<br><strong>sa</strong> (google.sa)<br><strong>se</strong> (google.se)<br><strong>pl</strong> (google.pl)</td></tr><tr><td><code>COUNTRY_CODE</code></td><td>Valid values are two letter country codes for which we offer Geo Targeting (e.g. “<strong>au</strong>”, “<strong>es</strong>”, “<strong>it</strong>”, etc.). Where a Google domain needs to be scraped from another country (e.g. scraping google.com from Canada), both <strong>TLD</strong> and <strong>COUNTRY_CODE</strong> parameters must be specified.</td></tr><tr><td><code>OUTPUT_FORMAT</code></td><td><p>For structured data methods we offer CSV and JSON output. JSON is default if parameter is not added. Options:</p><ul><li>csv</li><li>json (default)</li></ul></td></tr></tbody></table>

### **Google parameters supported by this endpoint** <a href="#google-parameters-supported-by-this-endpoint" id="google-parameters-supported-by-this-endpoint"></a>

<table><thead><tr><th width="205">Google Parameters</th><th>Details</th></tr></thead><tbody><tr><td><code>UULE</code></td><td>Set a region for a search. For example: w+CAIQICINUGFyaXMsIEZyYW5jZQ. You can find an online UULE generator <a href="https://site-analyzer.pro/services-seo/uule/">here</a>.</td></tr><tr><td><code>HL</code></td><td>Host Language. For example: <code>DE</code></td></tr><tr><td><code>GL</code></td><td>Boosts matches whose country of origin matches the parameter value. For example: <code>DE</code></td></tr><tr><td><code>TBS</code></td><td><p>Limits results to a specific time range. For example: <code>tbs=d</code> returns results from the past day. Possible values:<br><code>tbs=h</code> - Hour</p><p><code>tbs=d</code> - Day</p><p><code>tbs=w</code> - Week</p><p><code>tbs=m</code> - Month</p><p><code>tbs=y</code> - Year</p></td></tr><tr><td><code>IE</code></td><td>Character encoding how the engine interpret the query string. For example: <code>UTF8</code></td></tr><tr><td><code>OE</code></td><td>Character encoding used for the results. For example: <code>UTF8</code></td></tr><tr><td><code>START</code></td><td>Set the starting offset in the result list. When <code>start=10</code> set the first element in the result list will be the 10th search result. (meaning it starts with page 2 of results if the "num" is 10)</td></tr></tbody></table>

### Sample Response

Single Query Request

```json
{
	"id": "89b388bf-0cea-49c1-8db6-9e00042c8c3a",
	"status": "running",
	"statusUrl": "http://async.scraperapi.com/structured/google/news/89b388bf-0cea-49c1-8db6-9e00042c8c3a",
	"query": "US economy"
}
```

Multiple Queries Request

```json
[
	{
		"id": "2955ad23-c812-475c-bc52-572576815d78",
		"status": "running",
		"statusUrl": "http://async.scraperapi.com/structured/google/news/2955ad23-c812-475c-bc52-572576815d78",
		"query": "US Economy"
	},
	{
		"id": "120a7344-7832-4fd0-a64f-ce9cd39726f3",
		"status": "running",
		"statusUrl": "http://async.scraperapi.com/structured/google/news/120a7344-7832-4fd0-a64f-ce9cd39726f3",
		"query": "Crowdfunding"
	}
]
```

After the job(s) finish, you will find the result under the <mark style="color:red;">response</mark> key in the response JSON object. The structure is the same as in the corresponding SYNC data endpoint.


---

# 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://docs.scraperapi.com/structured-data-endpoints/search-and-insights/google/google-news-api-async.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.
